Rajath Agasthya 03b6f18f80 Warn when wrong transport instance is used
Since RPC and notifications can have different backends, it is
useful to warn users if they use a notification transport in RPC
and vice versa. This patch introduces RPCTransport and
NotificationTransport subclasses of Transport, so it's easier to
add different behavior for them if need be.

Related-Bug: #1680192
Change-Id: Iab60544d69053c8e74c28a2d5c84665be749013f
2017-09-11 07:07:30 -07:00

49 lines
1.9 KiB
Python

# Copyright 2017 OpenStack Foundation.
# All Rights Reserved.
# Copyright 2017 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
__all__ = [
'get_rpc_transport'
]
from oslo_messaging import transport as msg_transport
def get_rpc_transport(conf, url=None,
allowed_remote_exmods=None):
"""A factory method for Transport objects for RPCs.
This method should be used to ensure the correct messaging functionality
for RPCs. RPCs and Notifications may use separate messaging systems
that utilize different drivers, different access permissions,
message delivery, etc.
Presently, this function works exactly the same as get_transport. It's
use is recommended as disambiguates the intended use for the transport
and may in the future extend functionality related to the separation of
messaging backends.
:param conf: the user configuration
:type conf: cfg.ConfigOpts
:param url: a transport URL, see :py:class:`transport.TransportURL`
:type url: str or TransportURL
:param allowed_remote_exmods: a list of modules which a client using this
transport will deserialize remote exceptions
from
:type allowed_remote_exmods: list
"""
return msg_transport._get_transport(
conf, url, allowed_remote_exmods,
transport_cls=msg_transport.RPCTransport)