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

Forward unhandled messages to optional subscriber handle_info callback #2

Merged
merged 2 commits into from
Jun 6, 2024

Conversation

urmastalimaa
Copy link
Member

The motivation for adding handle_info callbacks is to allow subscriber worker processes which are spawned by brod to participate in message passing, supporting a variety of use cases utilizing async acking and committing.

An example use case:

  • Start a group subscriber using brod_group_subscriber_v2
  • In a partition worker spawn a new process for every message under a supervisor specific to the worker's topic-partition
  • When the supervisor has <= N processes, ack last seen offset to fetch new messages. When the supervisor has > N processes, messages are not acked to apply backpressure
  • When all processes up to offset O1 have completed, commit offset O1

Allowing arbitrary message passing in the topic and group subscriber workers supports not only that use case but many others.

@urmastalimaa urmastalimaa requested review from indrekj and oskarkook June 6, 2024 07:04
@urmastalimaa urmastalimaa force-pushed the consumer_info_callbacks branch from 6de7feb to 7ed6aa7 Compare June 6, 2024 07:06
@urmastalimaa
Copy link
Member Author

I'll make a PR upstream after approved here.

Copy link

@oskarkook oskarkook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a cursory review, might be missing some details, but LGTM.

src/brod_topic_subscriber.erl Outdated Show resolved Hide resolved
Copy link
Member

@indrekj indrekj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

@urmastalimaa urmastalimaa force-pushed the consumer_info_callbacks branch 2 times, most recently from 5eab124 to 0db2802 Compare June 6, 2024 09:47
The motivation for adding handle_info callbacks is to allow subscriber
worker processes which are spawned by brod to participate in message
passing, supporting a variety of use cases utilizing async acking and
committing.

An example use case:
* Start a group subscriber using `brod_group_subscriber_v2`
* In a partition worker spawn a new process for every message under a
  supervisor specific to the worker's topic-partition
* When the supervisor has <= N processes, ack last seen offset to fetch
  new messages. When the supervisor has > N processes, messages are not
  acked to apply backpressure
* When all processes up to offset O1 have completed, commit offset O1

Allowing arbitrary message passing in the topic and group subscriber
workers supports not only that use case but many others.
@urmastalimaa urmastalimaa force-pushed the consumer_info_callbacks branch from 0db2802 to 20ca6c2 Compare June 6, 2024 10:03
@urmastalimaa urmastalimaa merged commit a39d136 into master Jun 6, 2024
21 checks passed
@urmastalimaa urmastalimaa deleted the consumer_info_callbacks branch June 6, 2024 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants