b_rabbit package

Submodules

b_rabbit.b_rabbit module

Main module.

class b_rabbit.b_rabbit.BRabbit(host: str = 'localhost', port: int = 5672)[source]

Bases: object

class EventPublisher(b_rabbit, publisher_name: str, exchange_type: str = 'topic', external: bool = False)[source]

Bases: object

event publisher, which sends events to all subscribers. Internal and External Publishers are now together in one Implementation

publish(routing_key: str, payload: str, important: bool = True)[source]

Publish of internal event. All internal subscribers will receive it. Parameters: :param str routing_key: Routing key for event :param str payload: Payload of event :param str important: indicate whether the publishing important or not,

if yes it will set the mandatory publishing Feature
class EventSubscriber(b_rabbit, routing_key: str, publisher_name: str, exchange_type: str = 'topic', external: bool = False, important_subscription: bool = True, event_listener: Callable = None)[source]

Bases: object

Subscribe to events send by publisher

subscribe_on_thread(*thread_args, **thread_kwargs)[source]

start Subscriber on an independent Thread

class TaskExecutor(b_rabbit, executor_name: str, routing_key: str, task_listener)[source]

Bases: object

channel = None

TaskExecutor registers on Task which is triggered by TaskRequester.

corr_id = None
run_task_on_thread(*thread_args, **thread_kwargs)[source]

start task Executor on an independent Thread

send_return(payload: str)[source]

Send return to TaskRequester which contains the results of task. :param str payload: payload of task response

class TaskRequesterAsynchron(b_rabbit, executor_name: str, routing_key: str, response_listener)[source]

Bases: object

TaskRequesterSynchron requests tasks asynchon.

request_task(payload: str)[source]

Do request task from executor. :param str payload: Data needed for task execution.

class TaskRequesterSynchron(b_rabbit, executor_name: str, routing_key: str, response_listener)[source]

Bases: object

TaskRequesterSynchron requests tasks synchronously.

corr_id = None
request_task(payload: str, queue_name='')[source]

Do request task from executer. :param str payload: payload of task Request :param str queue_name: name of the callback queue to consume the response

add_active_queues(queue)[source]
close_connection()[source]
connection = None
b_rabbit.b_rabbit.calc_execution_time(func)[source]

calculate execution Time of a function

Module contents

Top-level package for b_rabbit.