eventbus Module
Main module implementing the event bus
-
class geeteventbus.eventbus.eventbus(max_queued_event=10000, executor_count=8, synchronus=False, subscribers_thread_safe=True)[source]
Creates an eventbus object
Parameters: |
- max_queued_event (int) – total number of un-ordered events queued.
- executor_count (int) – number of threads to process the queued event by calling the
corresponding subscribers.
- synchronus (bool) – if the events are processed synchronously, i.e. if they are proccessed
by subscribers on the same event submitting thread.
- subscribers_thread_safe (bool) – if the subscribers can be invoked for processing multiple
events simultaneously.
|
-
get_subscribers(topic)[source]
Returns the list of subscribes currently registered for the topic.
-
is_subscribed(consumer, topic)[source]
Checks if a subscriber is a consumer for some topic
Returns: | True if the consumer is subscribing to the topic |
Return type: | bool |
-
post(eventobj)[source]
posts an event to the eventbus
Parameters: | eventobj – the event posted. It must be type of event class or its subclass. |
Returns: | True if event is successfully postedb, False otherwise. |
-
register_consumer(consumer, topic)[source]
registers a consumer to the eventbus that subscribes to a topic
Parameters: |
- consumer (subscriber subclass) – the subscriber object
- topic (str) – the topic the consumer will subscribe for
|
-
register_consumer_topics(consumer, topic_list)[source]
registers a consumer to the eventbus that subscribes to the list of topics in topic_list
Parameters: |
- consumer – the subscriber object
- topic_list – the list of topics the consumer will subscribe for
|
-
shutdown()[source]
Stops the event bus. The event bus will stop all its executor threads.
It will try to flush out already queued events by calling the subscribers
of the events. This flush wait time is 2 seconds.
-
unregister_consumer(consumer)[source]
Unregister the consumer.
The consumer will no longer receieve any event to process for any topic
Parameters: | conumer – the subscriber object to unregister |
-
geeteventbus.eventbus.get_crc32(data)[source]
Returns the crc32 value of the input string.