events.dispatcher

Event dispatcher sends events.

Module Contents

Classes

EventDispatcher(self,connection=None,hostname=None,enabled=True,channel=None,buffer_while_offline=True,app=None,serializer=None,groups=None,delivery_mode=1,buffer_group=None,buffer_limit=24,on_send_buffered=None) Dispatches event messages.
class EventDispatcher(connection=None, hostname=None, enabled=True, channel=None, buffer_while_offline=True, app=None, serializer=None, groups=None, delivery_mode=1, buffer_group=None, buffer_limit=24, on_send_buffered=None)

Dispatches event messages.

Arguments:

connection (kombu.Connection): Connection to the broker.

hostname (str): Hostname to identify ourselves as,
by default uses the hostname returned by anon_nodename().
groups (Sequence[str]): List of groups to send events for.
send() will ignore send requests to groups not in this list. If this is None, all events will be sent. Example groups include "task" and "worker".
enabled (bool): Set to False to not actually publish any
events, making send() a no-op.
channel (kombu.Channel): Can be used instead of connection to specify
an exact channel to use when sending events.
buffer_while_offline (bool): If enabled events will be buffered
while the connection is down. flush() must be called as soon as the connection is re-established.
Note:
You need to close() this after use.
__init__(connection=None, hostname=None, enabled=True, channel=None, buffer_while_offline=True, app=None, serializer=None, groups=None, delivery_mode=1, buffer_group=None, buffer_limit=24, on_send_buffered=None)
__enter__()
__exit__(*exc_info)
enable()
disable()
publish(type, fields, producer, blind=False, Event=Event, **kwargs)

Publish event using custom Producer.

Arguments:
type (str): Event type name, with group separated by dash (-).
fields: Dictionary of event fields, must be json serializable.
producer (kombu.Producer): Producer instance to use:
only the publish method will be called.

retry (bool): Retry in the event of connection failure. retry_policy (Mapping): Map of custom retry policy options.

See ensure().
blind (bool): Don’t set logical clock value (also don’t forward
the internal logical clock).
Event (Callable): Event type used to create event.
Defaults to Event().
utcoffset (Callable): Function returning the current
utc offset in hours.
_publish(event, producer, routing_key, retry=False, retry_policy=None, utcoffset=utcoffset)
send(type, blind=False, utcoffset=utcoffset, retry=False, retry_policy=None, Event=Event, **fields)

Send event.

Arguments:

type (str): Event type name, with group separated by dash (-). retry (bool): Retry in the event of connection failure. retry_policy (Mapping): Map of custom retry policy options.

See ensure().
blind (bool): Don’t set logical clock value (also don’t forward
the internal logical clock).
Event (Callable): Event type used to create event,
defaults to Event().
utcoffset (Callable): unction returning the current utc offset
in hours.

**fields (Any): Event fields – must be json serializable.

flush(errors=True, groups=True)

Flush the outbound buffer.

extend_buffer(other)

Copy the outbound buffer of another instance.

close()

Close the event dispatcher.

_get_publisher()
_set_publisher(producer)