b_rabbit package

Submodules

b_rabbit.b_rabbit module

Main module.

class b_rabbit.b_rabbit.BRabbit(host: str = 'localhost', port: int = 5672, user: str = None, password: str = None)[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, properties=None)[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
Parameters:properties (BRabbit.Properties) – properties object containing the properties dictionary that will be loaded into the rabbitpy.message object.
class EventSubscriber(b_rabbit, routing_key: str, publisher_name: str, exchange_type: str = 'topic', routing_key_only: bool = False, external: bool = False, important_subscription: bool = True, event_listener: Callable = None, verbose: bool = False)[source]

Bases: object

Subscribe to events send by publisher

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

start Subscriber on an independent Thread

class Properties(**kwargs)[source]

Bases: object

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.