geeteventbus Package

event Module

Event super class

class geeteventbus.event.event(topic, data, ordered=None)[source]
get_data()[source]

Returns the data associated with the event object

Returns:the data of the event object
get_ordered()[source]

Returns the event ordering field.

Event ordering field may be none, specifying the events may get processed out of order

Returns:the ordering field of the event object
Return type:str
get_topic()[source]

Returns the topic associated with the topic

Returns:the topic of the event
Return type:str

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.

subscriber Module

Subscriber super-class

class geeteventbus.subscriber.subscriber[source]
process(eventobj)[source]

Called by the eventbus.

Parameters:eventobj (event or subclass of event) – The event object

This method implements the logic for processing the event. This method should not block for long time as that will affect the performance of the eventbus.

Table Of Contents

Previous topic

Welcome to geeteventbus’s documentation!

This Page