Ejemplo n.º 1
0
def get_rpc_server(transport,
                   target,
                   endpoints,
                   executor='blocking',
                   serializer=None):
    """Construct an RPC server.

    The executor parameter controls how incoming messages will be received and
    dispatched. By default, the most simple executor is used - the blocking
    executor.

    If the eventlet executor is used, the threading and time library need to be
    monkeypatched.

    :param transport: the messaging transport
    :type transport: Transport
    :param target: the exchange, topic and server to listen on
    :type target: Target
    :param endpoints: a list of endpoint objects
    :type endpoints: list
    :param executor: name of a message executor - for example
                     'eventlet', 'blocking'
    :type executor: str
    :param serializer: an optional entity serializer
    :type serializer: Serializer
    """
    dispatcher = rpc_dispatcher.RPCDispatcher(target, endpoints, serializer)
    return msg_server.MessageHandlingServer(transport, dispatcher, executor)
Ejemplo n.º 2
0
def get_notification_listener(transport, targets, endpoints,
                              executor='blocking', serializer=None,
                              allow_requeue=False, pool=None):
    """Construct a notification listener

    The executor parameter controls how incoming messages will be received and
    dispatched. By default, the most simple executor is used - the blocking
    executor.

    If the eventlet executor is used, the threading and time library need to be
    monkeypatched.

    :param transport: the messaging transport
    :type transport: Transport
    :param targets: the exchanges and topics to listen on
    :type targets: list of Target
    :param endpoints: a list of endpoint objects
    :type endpoints: list
    :param executor: name of a message executor - for example
                     'eventlet', 'blocking'
    :type executor: str
    :param serializer: an optional entity serializer
    :type serializer: Serializer
    :param allow_requeue: whether NotificationResult.REQUEUE support is needed
    :type allow_requeue: bool
    :param pool: the pool name
    :type pool: str
    :raises: NotImplementedError
    """
    dispatcher = notify_dispatcher.NotificationDispatcher(targets, endpoints,
                                                          serializer,
                                                          allow_requeue, pool)
    return msg_server.MessageHandlingServer(transport, dispatcher, executor)
Ejemplo n.º 3
0
def get_server(target, endpoints, serializer=None):
    assert TRANSPORT is not None
    if serializer is None:
        serializer = DesignateObjectSerializer()
    serializer = RequestContextSerializer(serializer)

    dispatcher = RPCDispatcher(target, endpoints, serializer)
    return msg_server.MessageHandlingServer(TRANSPORT, dispatcher, 'eventlet')
Ejemplo n.º 4
0
def get_notification_server(targets, endpoints, serializer=None):
    """Retrieve notification server

    This Notification server uses same transport configuration as used by
    other barbican functionality like async order processing.

    Assumption is that messaging infrastructure is going to be shared (same)
    among different barbican features.
    """
    allow_requeue = getattr(getattr(CONF, KS_NOTIFICATIONS_GRP_NAME),
                            'allow_requeue')
    TRANSPORT._require_driver_features(requeue=allow_requeue)
    dispatcher = notfiy_dispatcher.NotificationDispatcher(
        targets, endpoints, serializer, allow_requeue)
    # we don't want blocking executor so use eventlet as executor choice
    return msg_server.MessageHandlingServer(TRANSPORT,
                                            dispatcher,
                                            executor='eventlet')
Ejemplo n.º 5
0
def get_server(target, endpoints, serializer=None):
    assert TRANSPORT is not None
    if serializer is None:
        serializer = DesignateObjectSerializer()
    serializer = RequestContextSerializer(serializer)

    # TODO(kiall): Remove when oslo.messaging 5 is the min in requirements
    argspec = inspect.getargspec(rpc_dispatcher.RPCDispatcher.__init__)
    if 'target' in argspec.args:
        # We're on oslo.messaging < 5
        dispatcher = RPCDispatcher(target, endpoints, serializer)

        return msg_server.MessageHandlingServer(TRANSPORT, dispatcher,
                                                'eventlet')

    else:
        # We're on oslo.messaging >= 5
        dispatcher = RPCDispatcher(endpoints, serializer)

        return rpc_server.RPCServer(TRANSPORT, target, dispatcher, 'eventlet')
Ejemplo n.º 6
0
 def test_defaults(self):
     transport = mock.Mock()
     transport.conf = self.conf
     server.MessageHandlingServer(transport, mock.Mock())
     opts.set_defaults(self.conf, executor_thread_pool_size=100)
     self.assertEqual(100, self.conf.executor_thread_pool_size)