replace some orders/bar occurences

This commit is contained in:
Christian Tzolov
2019-05-17 20:28:20 +02:00
parent 90ba371006
commit 4686ceb8d8
2 changed files with 4 additions and 4 deletions

View File

@@ -45,20 +45,20 @@ class Router:
except TopicAlreadyExistsError:
print ('Topic: {} already exists!')
def process_orders(self):
def process_timestamps(self):
"""
Continuously consumes timestamps form the input channel and send even or odd timestamps to the output channels.
"""
while True:
for message in self.consumer:
if message.value is not None:
if self.is_even_order(message.value):
if self.is_even_timestamp(message.value):
self.producer.send(self.even_topic, b'Even timestamp: ' + message.value)
else:
self.producer.send(self.odd_topic, b'Odd timestamp:' + message.value)
@staticmethod
def is_even_order(value):
def is_even_timestamp(value):
return int(value[-1:]) % 2 == 0
@@ -68,4 +68,4 @@ Router(
get_channel_topic('input'),
get_channel_topic('even'),
get_channel_topic('odd')
).process_orders()
).process_timestamps()