The apmec.common.rpc Module

The apmec.common.rpc Module

class apmec.common.rpc.BackingOffClient(transport, target, timeout=None, version_cap=None, serializer=None, retry=None, call_monitor_timeout=None)

Bases: oslo_messaging.rpc.client.RPCClient

An oslo messaging RPC Client that implements a timeout backoff.

This has all of the same interfaces as oslo_messaging.RPCClient but if the timeout parameter is not specified, the _ContextWrapper returned will track when call timeout exceptions occur and exponentially increase the timeout for the given call method.

prepare(*args, **kwargs)

Prepare a method invocation context.

Use this method to override client properties for an individual method invocation. For example:

def test(self, ctxt, arg):
    cctxt = self.prepare(version='2.5')
    return cctxt.call(ctxt, 'test', arg=arg)
Parameters:
  • exchange (str) – see Target.exchange
  • topic (str) – see Target.topic
  • namespace (str) – see Target.namespace
  • version (str) – requirement the server must support, see Target.version
  • server (str) – send to a specific server, see Target.server
  • fanout (bool) – send to all servers on topic, see Target.fanout
  • timeout (int or float) – an optional default timeout (in seconds) for call()s
  • version_cap (str) – raise a RPCVersionCapError version exceeds this cap
  • retry (int) – an optional connection retries configuration: None or -1 means to retry forever. 0 means no retry is attempted. N means attempt at most N retries.
  • call_monitor_timeout (int) – an optional timeout (in seconds) for active call heartbeating. If specified, requires the server to heartbeat long-running calls at this interval (less than the overall timeout parameter).
static set_max_timeout(max_timeout)

Set RPC timeout ceiling for all backing-off RPC clients.

class apmec.common.rpc.Connection

Bases: object

close()
consume_in_threads()
create_consumer(topic, endpoints, fanout=False, exchange='apmec', host=None)
class apmec.common.rpc.RequestContextSerializer(base=None)

Bases: oslo_messaging.serializer.Serializer

convert RPC common context int apmec Context.

deserialize_context(ctxt)

Deserialize a dictionary into a request context.

Parameters:ctxt – Request context dictionary
Returns:Deserialized form of entity
deserialize_entity(ctxt, entity)

Deserialize something from primitive form.

Parameters:
  • ctxt – Request context, in deserialized form
  • entity – Primitive to be deserialized
Returns:

Deserialized form of entity

serialize_context(ctxt)

Serialize a request context into a dictionary.

Parameters:ctxt – Request context
Returns:Serialized form of context
serialize_entity(ctxt, entity)

Serialize something to primitive form.

Parameters:
  • ctxt – Request context, in deserialized form
  • entity – Entity to be serialized
Returns:

Serialized form of entity

class apmec.common.rpc.Service(host, topic, manager=None, serializer=None)

Bases: oslo_service.service.Service

Service object for binaries running on hosts.

A service enables rpc by listening to queues based on topic and host.

start()

Start a service.

stop()

Stop a service.

Parameters:graceful – indicates whether to wait for all threads to finish or terminate them instantly
class apmec.common.rpc.VoidConnection

Bases: object

close()
consume_in_threads()
create_consumer(topic, endpoints, fanout=False, exchange='apmec', host=None)
apmec.common.rpc.add_extra_exmods(*args)
apmec.common.rpc.cleanup()
apmec.common.rpc.clear_extra_exmods()
apmec.common.rpc.create_connection()
apmec.common.rpc.get_allowed_exmods()
apmec.common.rpc.get_client(target, version_cap=None, serializer=None)
apmec.common.rpc.get_notifier(service=None, host=None, publisher_id=None)
apmec.common.rpc.get_server(target, endpoints, serializer=None)
apmec.common.rpc.init(conf)
apmec.common.rpc.init_action_rpc(conf)
Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.