Distributer Reference¶
The distributer package responsible for distributing data in between the inner system parts.
And exposes the Distributer class.
Distributer¶
- class Distributer(url: str)¶
This class defines distribute functionality. It receives url which is being used to load the corresponding distribute driver from drivers/ directory.
- publish(self, data, topic)¶
Publish data to topic. data must be in JSON format (we want to support many drivers).
- subscribe(self, callback, *topics, subscriber_group='')¶
Subscribe to topics and upon receiving data calling the callback with the received data (in JSON format) as an argument. subscriber_group argument meant to enable distribute work between different subscribers which are part of the same group, empty group means every subscriber will get the same work.
- connect(self)¶
Returns and calls directly to the driver’s connect is exists. Used also as the enter part of Distributer’s with statement.
- close(self)¶
Returns and calls directly to the driver’s close is exists. Used also as the exit part of Distributer’s with statement.
- publish_server(self, data)¶
Publish user information by publish_user __or__ snapshot information by publish_raw_snapshot if possible. data must be in JSON format (we want to support many drivers).
- publish_user(self, data)¶
Publish user information to user topic. data must be in JSON format (we want to support many drivers).
- publish_raw_snapshot(self, data)¶
Publish data to raw.X where X is every possible topic in a snapshot. data must be in JSON format (we want to support many drivers).
- publish_parsed_topic(self, parsed_topic_data, topic)¶
Publish data to f’parsed.{topic}’. parsed_topic_data must be in JSON format (we want to support many drivers).
- subscribe_parsed_topic(self, callback, topic, subscriber_group='')¶
Subscribe to f’parsed.{topic}’ and upon receiving data calling the callback with the received data (in JSON format) as an argument. subscriber_group argument meant to enable distribute work between different subscribers which are part of the same group, empty group means every subscriber will get the same work.
- subscribe_raw_topic(self, callback, topic, subscriber_group='')¶
Subscribe to f’raw.{topic}’ and upon receiving data calling the callback with the received data (in JSON format) as an argument. subscriber_group argument meant to enable distribute work between different subscribers which are part of the same group, empty group means every subscriber will get the same work.
Developers Note¶
To added a new driver all you have to do is: