backend.component   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 3

2 Functions

Rating   Name   Duplication   Size   Complexity  
A docomponent() 0 4 1
A when_component() 0 7 2
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