-
Notifications
You must be signed in to change notification settings - Fork 180
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
6996788
commit fbf58af
Showing
2 changed files
with
47 additions
and
2 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
29 changes: 29 additions & 0 deletions
29
robot-server/robot_server/service/notifications/publishers/client_data_publisher.py
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,29 @@ | ||
from typing import Annotated | ||
import fastapi | ||
from robot_server.service.notifications import topics | ||
from robot_server.service.notifications.notification_client import ( | ||
NotificationClient, | ||
get_notification_client, | ||
) | ||
|
||
|
||
class ClientDataPublisher: | ||
"""Publishes clientData topics.""" | ||
|
||
def __init__(self, client: NotificationClient) -> None: | ||
self._client = client | ||
|
||
async def publish_client_data(self, client_data_key: str) -> None: | ||
"""Publish the equivalent of `GET /clientData/{key}`.""" | ||
await self._client.publish_advise_refetch_async( | ||
topics.client_data(client_data_key) | ||
) | ||
|
||
|
||
async def get_client_data_publisher( | ||
notification_client: Annotated[ | ||
NotificationClient, fastapi.Depends(get_notification_client) | ||
], | ||
) -> ClientDataPublisher: | ||
"""Return a ClientDataPublisher for use by FastAPI endpoints.""" | ||
return ClientDataPublisher(notification_client) |