-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
214f621
commit 2cc23a2
Showing
4 changed files
with
36 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from typing import Any | ||
|
||
import redis.asyncio as redis | ||
|
||
from pubsub.pubsub import PubSubBase | ||
|
||
|
||
class Publisher(PubSubBase): | ||
"""Publisher class for pub/sub.""" | ||
|
||
def _create_client(self) -> redis.Redis | None: | ||
if self.redis_endpoint and self.channel: | ||
return redis.Redis.from_url(self.redis_endpoint, decode_responses=True) | ||
|
||
return None | ||
|
||
async def publish(self, message: Any) -> None: | ||
"""Publishes a message to the channel.""" | ||
if self.client and self.channel: | ||
await self.client.publish(self.channel, message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters