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

Normalize broker interfaces __init__ signatures #7

Open
DontPanicO opened this issue Feb 11, 2023 · 0 comments
Open

Normalize broker interfaces __init__ signatures #7

DontPanicO opened this issue Feb 11, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request websocket-manager issues or PRs related to WebSocketManager

Comments

@DontPanicO
Copy link
Owner

Feature or enhancement

Ensure that __init__ method signature of interfaces inheriting from BrokerInterface contains a positional arg for the broker url.

Ptich

Interfaces inheriting from BrokerInterface now have different __init__ signatures. We should at least make sure that they accept a positional parameter for the broker url.
That will also improve the _init_broker method used by WebSocketManager.
We could then accept *args, **kwargs for user convenience:

# ./_broker.py

class BrokerInterface(ABC):
    @abstractmethod
    def __init__(broker_url: str, *args, **kwargs):
        ...
# Also `InMemoryBroker` and `RedisBroker`
# should be updated to match that

# ./manager.py

# this require also `create_broker` signature to
# be updated to match `*args`.
def _init_broker(url: str, broker_class: Any | None = None, *args, **kwargs) -> BrokerT:
    if broker_class:
        assert is_valid_broker(
            broker_class
        ), 'Invalid broker class. Use distributed_websocket.utils.is_valid_broker to check if your broker_class is valid.'
    broker_factory = broker_class or create_broker
    return broker_factory(url, *args, **kwargs)
@DontPanicO DontPanicO added enhancement New feature or request websocket-manager issues or PRs related to WebSocketManager labels Feb 11, 2023
@DontPanicO DontPanicO self-assigned this Feb 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request websocket-manager issues or PRs related to WebSocketManager
Projects
None yet
Development

No branches or pull requests

1 participant