forked from bahrmichael/aws-scheduler
-
Notifications
You must be signed in to change notification settings - Fork 1
/
handler.py
34 lines (25 loc) · 879 Bytes
/
handler.py
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
import json
from consumer import handle as consumer_handle
from emitter import handle as emitter_handle
from event_loader import run
from scheduler import handle as schedule_batch_handle
def consumer(event, context):
items = []
for record in event['Records']:
message = record['Sns']['Message']
payload = json.loads(message)
items.append(payload)
consumer_handle(items)
def emitter(event, context):
items = []
for record in event['Records']:
body = json.loads(record['body'])
items.append(body)
emitter_handle(items)
def scheduler(event, context):
# the invocation of this lambda function passes the events array as a bytes
# this lets us use the array directly
schedule_batch_handle(event)
def event_loader(event, context):
# this is triggered by a cronjob, no need to pass data
run()