Skip to content

Feature: Publish messages with a pattern destination #2450

Description

@Lancetnik

We would like to support publishing messages with a specific pattern, such as logs.{level}.

Here is an example of how this could be implemented:

publisher = broker.publisher("logs.{level}")
await publisher.publish("Hi!", level="info") # should be interpreted as "logs.info" destination

Suggested implementation:

async def publish(self, message: SendableMessage, **kwargs: Any) -> None:
    dest = self.destination.format(**kwargs)
    await self._publish(message, dest)

As a reference we can use current compile_path function using for pattern-based subscribers: https://github.com/search?q=repo%3Aag2ai%2Ffaststream%20compile_path&type=code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

CoreIssues related to core FastStream functionality and affects to all brokersenhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions