/
app.py
28 lines (24 loc) · 906 Bytes
/
app.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
import pyrowire
import settings
# configure the pyrowire application
pyrowire.configure(settings)
# all app.processor methods need to be annotated with the topic for which they process
# and take one arg, 'message_data'
@pyrowire.handler(topic='my_topic')
def my_processor(message_data):
if not message_data:
raise TypeError("message_data must not be None")
# insert handler logic here
# always return message_data
return message_data
# all pyro.filter methods need to be annotated with the name of the filter
# and take one arg, 'message_data'
@pyrowire.validator(name='my_validator')
def my_filter(message_data):
if not message_data:
raise TypeError("message_data must not be None")
# insert validation logic here
# validators should try to prove that the message is invalid, i.e., return True
return True
if __name__ == '__main__':
pyrowire.run()