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

Allow setting keys in outbox messages #1

Closed
mgibowski opened this issue Oct 25, 2023 · 4 comments · Fixed by #2
Closed

Allow setting keys in outbox messages #1

mgibowski opened this issue Oct 25, 2023 · 4 comments · Fixed by #2

Comments

@mgibowski
Copy link
Contributor

mgibowski commented Oct 25, 2023

The problem

At the moment, published messages have always an empty key:

case :brod.produce_sync(client_id, topic, partition, "", values) do

This prevents key-based retention via topic compaction:
https://developer.confluent.io/courses/architecture/compaction/#topic-compaction-key-based-retention

The solution

That would be a breaking change, but I think the MyApp.Outbox.publish/2 function should accept three arguments and become:

MyApp.Outbox.publish("topic", "key", %{hello: :kafka})

Similarly, the Kafkaesque.publish/4 function would become Kafkaesque.publish/5 and accept key argument just before the payload.

And the structure of Kafkaesque.Message schema would be extended with the key field.


@v0idpwn What do you think?

@v0idpwn
Copy link
Owner

v0idpwn commented Oct 25, 2023

Hi, @mgibowski. I agree we should support key, I'm not 100% sure we should make it required, though, as its very common to use empty keys in Kafka.

:brod has the following interface:

Perhaps we could follow along and have publish(topic, key, payload) and publish(topic, payload)? (i.e.: this would be publish(topic, key \\ "", payload)

@mgibowski
Copy link
Contributor Author

Perhaps we could follow along and have publish(topic, key, payload) and publish(topic, payload)? (i.e.: this would be publish(topic, key \ "", payload)

Yes, that makes sense!

@v0idpwn v0idpwn mentioned this issue Oct 25, 2023
@v0idpwn
Copy link
Owner

v0idpwn commented Oct 25, 2023

I started #2 adding this feature. It will be a breaking change, but I'll try to make it smooth.
Do you intend to use Kafkaesque in production? I can try to cut 1.0 for that :)

@mgibowski
Copy link
Contributor Author

I started #2 adding this feature. It will be a breaking change, but I'll try to make it smooth.

So far looks great!

Do you intend to use Kafkaesque in production? I can try to cut 1.0 for that :)

Yes, we plan to release code that uses Kafkaesque to production in middle November. 1.0 by that time would be awesome :)

@mgibowski mgibowski mentioned this issue Nov 1, 2023
@v0idpwn v0idpwn closed this as completed in #2 Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants