17
17
# License for the specific language governing permissions and limitations
18
18
# under the License.
20
from nova import flags
21
A remote procedure call (rpc) abstraction.
23
For some wrappers that add message versioning to rpc, see:
21
28
from nova.openstack.common import cfg
22
from nova import utils
25
rpc_backend_opt = cfg.StrOpt('rpc_backend',
26
default='nova.rpc.impl_kombu',
27
help="The messaging module to use, defaults to kombu.")
30
FLAGS.register_opt(rpc_backend_opt)
29
from nova.openstack.common import importutils
33
cfg.StrOpt('rpc_backend',
34
default='nova.rpc.impl_kombu',
35
help="The messaging module to use, defaults to kombu."),
36
cfg.IntOpt('rpc_thread_pool_size',
38
help='Size of RPC thread pool'),
39
cfg.IntOpt('rpc_conn_pool_size',
41
help='Size of RPC connection pool'),
42
cfg.IntOpt('rpc_response_timeout',
44
help='Seconds to wait for a response from call or multicall'),
45
cfg.ListOpt('allowed_rpc_exception_modules',
46
default=['nova.exception'],
47
help='Modules of exceptions that are permitted to be recreated'
48
'upon receiving exception data from an rpc call.'),
54
def register_opts(conf):
57
_CONF.register_opts(rpc_opts)
58
_get_impl().register_opts(_CONF)
33
61
def create_connection(new=True):
44
72
:returns: An instance of nova.rpc.common.Connection
46
return _get_impl().create_connection(new=new)
74
return _get_impl().create_connection(_CONF, new=new)
49
77
def call(context, topic, msg, timeout=None):
65
93
:raises: nova.rpc.common.Timeout if a complete response is not received
66
94
before the timeout is reached.
68
return _get_impl().call(context, topic, msg, timeout)
96
return _get_impl().call(_CONF, context, topic, msg, timeout)
71
99
def cast(context, topic, msg):
85
return _get_impl().cast(context, topic, msg)
113
return _get_impl().cast(_CONF, context, topic, msg)
88
116
def fanout_cast(context, topic, msg):
105
return _get_impl().fanout_cast(context, topic, msg)
133
return _get_impl().fanout_cast(_CONF, context, topic, msg)
108
136
def multicall(context, topic, msg, timeout=None):
131
159
:raises: nova.rpc.common.Timeout if a complete response is not received
132
160
before the timeout is reached.
134
return _get_impl().multicall(context, topic, msg, timeout)
162
return _get_impl().multicall(_CONF, context, topic, msg, timeout)
137
165
def notify(context, topic, msg):
175
return _get_impl().cast_to_server(context, server_params, topic, msg)
203
return _get_impl().cast_to_server(_CONF, context, server_params, topic,
178
207
def fanout_cast_to_server(context, server_params, topic, msg):
190
return _get_impl().fanout_cast_to_server(context, server_params, topic,
219
return _get_impl().fanout_cast_to_server(_CONF, context, server_params,
198
"""Delay import of rpc_backend until FLAGS are loaded."""
227
"""Delay import of rpc_backend until configuration is loaded."""
200
229
if _RPCIMPL is None:
201
_RPCIMPL = utils.import_object(FLAGS.rpc_backend)
230
_RPCIMPL = importutils.import_module(_CONF.rpc_backend)