Skip to content

Commit

Permalink
correct args in method docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
mackenzie-grimes-noaa committed Nov 18, 2024
1 parent 429ebab commit 45a2536
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions python/idsse_common/idsse/common/rabbitmq_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,19 +454,23 @@ def setup(self, channel_args: Conn | Channel):
"""
Method that initializes the RabbitMQ connection, channel, exchange, and queue to be used
to publish messages in a threadsafe way.
Can be overridden to customize how Publisher establishes these RMQ resources.
Automatically called when a new Publisher() is instantiated. Can be overridden by child
classes to customize how Publisher establishes these RMQ resources.
Args:
rmq_args (Conn | None)
channel_args (Conn | pika.channel.Channel): either connection parameters (Conn)
to establish a new RabbitMQ connection and channel, or an existing, pre-connected
pika Channel. Raises ValueError if channel_args is not one of these types.
"""
if isinstance(channel_args, Channel):
# reuse the existing RabbitMQ Connection and Channel passed to setup()
self.connection = channel_args.connection
self.channel = channel_args
elif isinstance(channel_args, Conn):
if isinstance(channel_args, Conn):
# create new RabbitMQ Connection and Channel using the provided params
self.connection = BlockingConnection(channel_args.connection_parameters)
self.channel = self.connection.channel()
elif isinstance(channel_args, Channel):
# reuse the existing RabbitMQ Connection and Channel passed to setup()
self.connection = channel_args.connection
self.channel = channel_args
else:
raise ValueError('Publisher expects RabbitMQ params (Conn) or existing Channel to run setup')

Expand Down

0 comments on commit 45a2536

Please sign in to comment.