Total Complexity | 3 |
Total Lines | 25 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | '''a component that gathers stats and hearbeats from other components |
||
2 | evaluate if this is going to be used or not |
||
3 | ''' |
||
4 | |||
5 | from helpers.queuehelper import QueueName |
||
6 | from backend.fcmapp import ApplicationService |
||
7 | |||
8 | APP = ApplicationService(component='component') |
||
9 | |||
10 | def when_component(channel, method, properties, body): |
||
11 | '''when the event happens''' |
||
12 | try: |
||
13 | print("[{0}] Received component message".format(APP.now())) |
||
14 | docomponent(body.decode()) |
||
15 | except Exception as ex: |
||
16 | APP.logexception(ex) |
||
17 | |||
18 | def docomponent(msg): |
||
19 | '''do this''' |
||
20 | APP.telegram.sendmessage(msg) |
||
21 | print("Sent telegram {0}".format(msg)) |
||
22 | |||
23 | Q = APP.subscribe(QueueName.Q_COMPONENT, when_component) |
||
24 | APP.bus.listen(Q) |
||
25 |