Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BLOCKED] Server properties #107

Merged
merged 4 commits into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kiwipy/communications.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def broadcast_send(self, body, sender=None, subject=None, correlation_id=None) -

class CommunicatorHelper(Communicator):
# Have to disable this linter because this class remains abstract and it is
# just used by calsses that will themselves be concrete
# just used by classes that will themselves be concrete
# pylint: disable=abstract-method

def __init__(self):
Expand Down
9 changes: 8 additions & 1 deletion kiwipy/rmq/communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import copy
import logging
import typing
from typing import Union, Optional
from typing import Union, Optional, Dict

import shortuuid
import aio_pika
Expand Down Expand Up @@ -345,6 +345,13 @@ async def __aexit__(self, exc_type, exc_val, exc_tb):
def __str__(self):
return f'RMQCommunicator({self._connection})'

@property
def server_properties(self) -> Dict:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add a docstring

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

if self._connection is None:
return {}

return self._connection.connection.server_properties

@property
def loop(self):
"""Get the event loop instance driving this communicator connection."""
Expand Down
6 changes: 5 additions & 1 deletion kiwipy/rmq/threadcomms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from concurrent.futures import Future as ThreadFuture
import functools
import logging
from typing import Union
from typing import Union, Dict

import aio_pika
import deprecation
Expand Down Expand Up @@ -148,6 +148,10 @@ def start(self):
def stop(self):
self.close()

@property
def server_properties(self) -> Dict:
return self._communicator.server_properties

def __enter__(self):
return self

Expand Down
9 changes: 9 additions & 0 deletions test/rmq/test_coroutine_communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,12 @@ def broadcast_subscriber(_comm, _body, _sender=None, _subject=None, _correlation


# endregion


@pytest.mark.asyncio
async def test_server_properties(communicator: kiwipy.rmq.RmqCommunicator):
props = communicator.server_properties
assert isinstance(props, dict)

assert props['product'] == b'RabbitMQ'
sphuber marked this conversation as resolved.
Show resolved Hide resolved
assert props['platform'].startswith(b'Erlang')