backend.component.docomponent()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 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