Skip to content

Commit

Permalink
WIP: add redis broker driver [skip-ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
zerlok committed Dec 1, 2024
1 parent d210c52 commit f75fca9
Show file tree
Hide file tree
Showing 11 changed files with 445 additions and 55 deletions.
7 changes: 6 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
version: '3.3'
version: '3.7'

services:
rabbitmq:
image: rabbitmq:4.0.2-management-alpine
ports:
- "5672:5672"
- "15672:15672"

redis:
image: redis:7.4.1-alpine
ports:
- "6379:6379"
58 changes: 56 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ protobuf = {version = "^5.26.1", optional = true}
googleapis-common-protos = {version = "^1.65.0", optional = true}
aiormq = {version = "^6.8.1", optional = true}
aiofiles = {version = "^24.1.0", optional = true}
redis = {version = "^5.2.0", optional = true}

[tool.poetry.extras]
cli = ["aiofiles"]
protobuf = ["protobuf", "googleapis-common-protos"]
aiormq = ["aiormq"]
redis = ["redis"]

[tool.poetry.scripts]
brokrpc = "brokrpc.cli:main"
Expand Down
1 change: 1 addition & 0 deletions src/brokrpc/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ async def consume(self, inner: S, message: U) -> V:
raise NotImplementedError


# TODO: consider interface (e.g. make is_alive async)
class BoundConsumer(metaclass=abc.ABCMeta):
@abc.abstractmethod
def is_alive(self) -> bool:
Expand Down
5 changes: 5 additions & 0 deletions src/brokrpc/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ def connect(options: BrokerConnectOptions) -> t.AsyncContextManager[BrokerDriver

return AiormqBrokerDriver.connect(clean_options)

elif clean_options.driver == "redis":
from brokrpc.driver.redis import RedisBrokerDriver

return RedisBrokerDriver.connect(clean_options)

else:
details = "unsupported driver"
raise ValueError(details, clean_options)
Expand Down
Loading

0 comments on commit f75fca9

Please sign in to comment.