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

Feature: Multiple messages per channel #1566

Open
febus982 opened this issue Jul 1, 2024 · 0 comments
Open

Feature: Multiple messages per channel #1566

febus982 opened this issue Jul 1, 2024 · 0 comments
Labels
Core Issues related to core FastStream functionality and affects to all brokers enhancement New feature or request

Comments

@febus982
Copy link

febus982 commented Jul 1, 2024

Is your feature request related to a problem? Please describe.
I have an existing application ecosystem that produces multiple messages per channel, with different headers per message types.

I have tried this:

broker.publisher(topic, schema=Union[EventA, EventB], headers={"aaa": "ccc"})

It generated multiple payloads in the AsyncAPI json file, but headers seem to be ignored (and it would be the same headers for all messages)

Describe the solution you'd like

  • Be able to register multiple message types per channel
  • It should be possible to specify custom headers for each message, as per OpenAPI spec

Feature code example
Something like this would be great. Maybe using a base message class that defines get_payload and get_headers methods.

class BaseMessage:
    @classmethod
    def get_headers(cls):
        ...
    @classmethod
    def get_payload(cls):
        ...

class MessageA:
    ...
class MessageB:
    ...

broker.publisher("channel_name", messages: Union[MessageA, MessageB])
...

Describe alternatives you've considered
N/A

Additional context
N/A

@febus982 febus982 added the enhancement New feature or request label Jul 1, 2024
@Lancetnik Lancetnik added the Core Issues related to core FastStream functionality and affects to all brokers label Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Issues related to core FastStream functionality and affects to all brokers enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants