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

Export backend classes #145

Merged
merged 1 commit into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 broadcaster/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from ._backends.base import BroadcastBackend
from ._base import Broadcast, Event
from .backends.base import BroadcastBackend

__version__ = "0.3.1"
__all__ = ["Broadcast", "Event", "BroadcastBackend"]
12 changes: 6 additions & 6 deletions broadcaster/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from urllib.parse import urlparse

if TYPE_CHECKING: # pragma: no cover
from broadcaster._backends.base import BroadcastBackend
from broadcaster.backends.base import BroadcastBackend


class Event:
Expand Down Expand Up @@ -34,27 +34,27 @@ def __init__(self, url: str | None = None, *, backend: BroadcastBackend | None =
def _create_backend(self, url: str) -> BroadcastBackend:
parsed_url = urlparse(url)
if parsed_url.scheme in ("redis", "rediss"):
from broadcaster._backends.redis import RedisBackend
from broadcaster.backends.redis import RedisBackend

return RedisBackend(url)

elif parsed_url.scheme == "redis-stream":
from broadcaster._backends.redis import RedisStreamBackend
from broadcaster.backends.redis import RedisStreamBackend

return RedisStreamBackend(url)

elif parsed_url.scheme in ("postgres", "postgresql"):
from broadcaster._backends.postgres import PostgresBackend
from broadcaster.backends.postgres import PostgresBackend

return PostgresBackend(url)

if parsed_url.scheme == "kafka":
from broadcaster._backends.kafka import KafkaBackend
from broadcaster.backends.kafka import KafkaBackend

return KafkaBackend(url)

elif parsed_url.scheme == "memory":
from broadcaster._backends.memory import MemoryBackend
from broadcaster.backends.memory import MemoryBackend

return MemoryBackend(url)
raise ValueError(f"Unsupported backend: {parsed_url.scheme}")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/test_broadcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pytest

from broadcaster import Broadcast, BroadcastBackend, Event
from broadcaster._backends.kafka import KafkaBackend
from broadcaster.backends.kafka import KafkaBackend


class CustomBackend(BroadcastBackend):
Expand Down
Loading