def __init__(self, source_service, event_type, handler_type=SERVICE_POOL,
                 reliable_delivery=True, requeue_on_error=False, **kwargs):
        r"""
        Decorate a method as a handler of ``event_type`` events on the service
        called ``source_service``.
        :Parameters:
            source_service : str
                Name of the service that dispatches the event
            event_type : str
                Type of the event to handle
            handler_type : str
                Determines the behaviour of the handler in a cluster:
                - ``events.SERVICE_POOL``:
                    Event handlers are pooled by service type and method,
                    and one service instance from each pool receives the
                    event. ::
                                   .-[queue]- (service X handler-meth-1)
                                  /
                        exchange o --[queue]- (service X handler-meth-2)
                                  \
                                   \          (service Y(inst. 1) handler-meth)
                                    \       /
                                     [queue]
                                            \
                                              (service Y(inst. 2) handler-meth)
                - ``events.SINGLETON``:
                    Events are received by only one registered handler,
                    regardless of service type. If requeued on error, they may
                    be handled by a different service instance. ::
                                               (service X handler-meth)
                                             /
                        exchange o -- [queue]
                                             \
                                               (service Y handler-meth)
                - ``events.BROADCAST``:
                    Events will be received by every handler. Events are
                    broadcast to every service instance, not just every service
                    type. Instances are differentiated using
                    :attr:`EventHandler.broadcast_identifier`. ::
                                    [queue]- (service X(inst. 1) handler-meth)
                                  /
                        exchange o - [queue]- (service X(inst. 2) handler-meth)
                                  \
                                    [queue]- (service Y handler-meth)

            requeue_on_error : bool  # TODO: defined by Consumer actually..
                If true, handlers will return the event to the queue if an
                error occurs while handling it. Defaults to False.
            reliable_delivery : bool
                If true, events will be held in the queue until there is a
                handler to consume them. Defaults to True.
        """
        self.source_service = source_service
        self.event_type = event_type
        self.handler_type = handler_type
        self.reliable_delivery = reliable_delivery

        super(EventHandler, self).__init__(
            queue=None, requeue_on_error=requeue_on_error, **kwargs
        )
def __init__ ( self , source_service , event_type , handler_type = SERVICE_POOL , reliable_delivery = True , requeue_on_error = False , ** kwargs ) : self . source_service = source_service self . event_type = event_type self . handler_type = handler_type self . reliable_delivery = reliable_delivery super ( EventHandler , self ) . __init__ ( queue = None , requeue_on_error = requeue_on_error , ** kwargs )
r"""
        Decorate a method as a handler of ``event_type`` events on the service
        called ``source_service``.
        :Parameters:
            source_service : str
                Name of the service that dispatches the event
            event_type : str
                Type of the event to handle
            handler_type : str
                Determines the behaviour of the handler in a cluster:
                - ``events.SERVICE_POOL``:
                    Event handlers are pooled by service type and method,
                    and one service instance from each pool receives the
                    event. ::
                                   .-[queue]- (service X handler-meth-1)
                                  /
                        exchange o --[queue]- (service X handler-meth-2)
                                  \
                                   \          (service Y(inst. 1) handler-meth)
                                    \       /
                                     [queue]
                                            \
                                              (service Y(inst. 2) handler-meth)
                - ``events.SINGLETON``:
                    Events are received by only one registered handler,
                    regardless of service type. If requeued on error, they may
                    be handled by a different service instance. ::
                                               (service X handler-meth)
                                             /
                        exchange o -- [queue]
                                             \
                                               (service Y handler-meth)
                - ``events.BROADCAST``:
                    Events will be received by every handler. Events are
                    broadcast to every service instance, not just every service
                    type. Instances are differentiated using
                    :attr:`EventHandler.broadcast_identifier`. ::
                                    [queue]- (service X(inst. 1) handler-meth)
                                  /
                        exchange o - [queue]- (service X(inst. 2) handler-meth)
                                  \
                                    [queue]- (service Y handler-meth)

            requeue_on_error : bool  # TODO: defined by Consumer actually..
                If true, handlers will return the event to the queue if an
                error occurs while handling it. Defaults to False.
            reliable_delivery : bool
                If true, events will be held in the queue until there is a
                handler to consume them. Defaults to True.