This repository was archived by the owner on May 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.py
More file actions
55 lines (44 loc) · 1.34 KB
/
app.py
File metadata and controls
55 lines (44 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""This is the main file of the lambda application
This module contains the handler method
"""
import boot
from flambda_app.flambda import Flambda
from flambda_app import APP_NAME, APP_VERSION
from flambda_app.logging import get_logger, set_debug_mode
from flambda_app.services.v1.carrier_notifier_service import CarrierNotifierService
from flambda_app.config import get_config
from flambda_app import helper
# load directly by boot
ENV = boot.get_environment()
# boot.load_dot_env(ENV)
# config
CONFIG = get_config()
# debug
DEBUG = helper.debug_mode()
# keep in this order, the app generic stream handler will be removed
APP = Flambda(APP_NAME)
# Logger
LOGGER = get_logger(force=True)
# override the APP logger
APP.logger = LOGGER
# override the log configs
if DEBUG:
# override to the level desired
set_debug_mode(LOGGER)
# general vars
APP_QUEUE = CONFIG.get('APP_QUEUE')
# TODO revisar logger com saída duplicada
@APP.on_sqs_message(queue=APP_QUEUE, batch_size=1)
def index(event):
"""
Lambda handler
:param event:
:return:
:rtype: str
"""
body = {"app": '%s:%s' % (APP_NAME, APP_VERSION)}
LOGGER.info('Env: {} App Info: {}'.format(ENV, body))
LOGGER.info('Handling event: {}'.format(event.to_dict()))
service = CarrierNotifierService(logger=LOGGER)
result = service.process(event)
return result