Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
ó
čEYc@sÞdZdddgZddlZddlZddlmZddlmZddlm	Z
dd	lmZ
ejeƒZd
e
jfd„ƒYZedde
jd
dddƒdddd„ƒZd„Zd„ZdS(s
An RPC server exposes a number of endpoints, each of which contain a set of
methods which may be invoked remotely by clients over a given transport.

To create an RPC server, you supply a transport, target and a list of
endpoints.

A transport can be obtained simply by calling the get_rpc_transport() method::

    transport = messaging.get_rpc_transport(conf)

which will load the appropriate transport driver according to the user's
messaging configuration. See get_rpc_transport() for more details.

The target supplied when creating an RPC server expresses the topic, server
name and - optionally - the exchange to listen on. See Target for more details
on these attributes.

Multiple RPC Servers may listen to the same topic (and exchange)
simultaneously. See RPCClient for details regarding how RPC requests are
distributed to the Servers in this case.

Each endpoint object may have a target attribute which may have namespace and
version fields set. By default, we use the 'null namespace' and version 1.0.
Incoming method calls will be dispatched to the first endpoint with the
requested method, a matching namespace and a compatible version number.

The first parameter to method invocations is always the request context
supplied by the client.  The remaining parameters are the arguments supplied to
the method by the client.  Endpoint methods may return a value.  If so the RPC
Server will send the returned value back to the requesting client via the
transport.

The executor parameter controls how incoming messages will be received and
dispatched. Refer to the Executor documentation for descriptions of the types
of executors.

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

The RPC reply operation is best-effort: the server will consider the message
containing the reply successfully sent once it is accepted by the messaging
transport.  The server does not guarantee that the reply is processed by the
RPC client.  If the send fails an error will be logged and the server will
continue to processing incoming RPC requests.

Parameters to the method invocation and values returned from the method are
python primitive types. However the actual encoding of the data in the message
may not be in primitive form (e.g. the message payload may be a dictionary
encoded as an ASCII string using JSON). A serializer object is used to convert
incoming encoded message data to primitive types.  The serializer is also used
to convert the return value from primitive types to an encoding suitable for
the message payload.

RPC servers have start(), stop() and wait() methods to begin handling
requests, stop handling requests, and wait for all in-process requests to
complete after the Server has been stopped.

A simple example of an RPC server with multiple endpoints might be::

    from oslo_config import cfg
    import oslo_messaging
    import time

    class ServerControlEndpoint(object):

        target = oslo_messaging.Target(namespace='control',
                                       version='2.0')

        def __init__(self, server):
            self.server = server

        def stop(self, ctx):
            if self.server:
                self.server.stop()

    class TestEndpoint(object):

        def test(self, ctx, arg):
            return arg

    transport = oslo_messaging.get_rpc_transport(cfg.CONF)
    target = oslo_messaging.Target(topic='test', server='server1')
    endpoints = [
        ServerControlEndpoint(None),
        TestEndpoint(),
    ]
    server = oslo_messaging.get_rpc_server(transport, target, endpoints,
                                           executor='eventlet')
    try:
        server.start()
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        print("Stopping server")

    server.stop()
    server.wait()

tget_rpc_servertexpected_exceptionstexposeiÿÿÿÿN(tupdated_kwarg_default_value(t_LE(t
dispatcher(tservert	RPCServercBs&eZdd„Zd„Zd„ZRS(tblockingcCs)tt|ƒj|||ƒ||_dS(N(tsuperRt__init__t_target(tselft	transportttargetRtexecutor((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/server.pyR
ˆscCs|jj|jddƒS(Ni(R
t_listenRtNone(R((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/server.pyt_create_listenerŒscCs#|d}y|jƒWn%tk
r?tjtdƒƒdSXd}y|jj|ƒ}Wn^tj	k
r}|j
}tjd|ƒn0tk
r¼tj
ƒ}tjtdƒƒnXz[y0|dkrß|j
|ƒn|j
d|ƒWn$tk
rtjtdƒƒnXWd~XdS(Nis,Can not acknowledge message. Skip processingu/Expected exception during message handling (%s)s!Exception during message handlingtfailuresCan not send reply for message(tacknowledget	ExceptiontLOGt	exceptionRRRtdispatchtrpc_dispatchertExpectedExceptiontexc_infotdebugtsystreply(RtincomingtmessageRtreste((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/server.pyt_process_incomings.

	

(t__name__t
__module__R
RR#(((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/server.pyR‡s	t
access_policyR s¡access_policy defaults to LegacyRPCAccessPolicy which exposes private methods. Explicitly set access_policy to DefaultRPCAccessPolicy or ExplicitRPCAccessPolicy.tversiont?RcCs(tj|||ƒ}t||||ƒS(s€Construct an RPC server.

    :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 message executor - available values are
                     'eventlet' and 'threading'
    :type executor: str
    :param serializer: an optional entity serializer
    :type serializer: Serializer
    :param access_policy: an optional access policy.
           Defaults to LegacyRPCAccessPolicy
    :type access_policy: RPCAccessPolicyBase
    (Rt
RPCDispatcherR(R
Rt	endpointsRt
serializerR&R((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/server.pyR²s	cs‡fd†}|S(sàDecorator for RPC endpoint methods that raise expected exceptions.

    Marking an endpoint method with this decorator allows the declaration
    of expected exceptions that the RPC server should not consider fatal,
    and not log as if they were generated in a real error scenario.

    Note that this will cause listed exceptions to be wrapped in an
    ExpectedException, which is used internally by the RPC sever. The RPC
    client will see the original exception type.
    cs‡‡fd†}|S(Ncs5yˆ||ŽSWnˆk
r0tjƒ‚nXdS(N(RR(targstkwargs(t
exceptionstfunc(sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/server.pytinnerßs
((R/R0(R.(R/sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/server.pytouterÞs((R.R1((R.sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/server.pyRÓs
cCs
t|_|S(s™Decorator for RPC endpoint methods that are exposed to the RPC client.

    If the dispatcher's access_policy is set to ExplicitRPCAccessPolicy then
    endpoint methods need to be explicitly exposed.::

        # foo() cannot be invoked by an RPC client
        def foo(self):
            pass

        # bar() can be invoked by an RPC client
        @rpc.expose
        def bar(self):
            pass

    (tTruetexposed(R/((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/server.pyRîs	(t__doc__t__all__tloggingRtdebtcollector.updatingRtoslo_messaging._i18nRtoslo_messaging.rpcRRtoslo_messagingRt
msg_servert	getLoggerR$RtMessageHandlingServerRRtDefaultRPCAccessPolicyRRR(((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/server.pyt<module>ss$	+