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 subscriptions to filter the events they receive #114

Merged
merged 5 commits into from
May 13, 2018

Conversation

christianjgreen
Copy link
Contributor

Based on #109 this would follow GenStage's lead by implementing a selector function that is run first filtering all events before being sent to subscribers.

Subscriptions will wait until the last event sent to the subscriber has been successfully acknowledge. If this event is filtered, then the subscriber cannot ack it, instead the subscription will remain stuck.
@slashdotdash
Copy link
Member

slashdotdash commented May 5, 2018

@ArThien Thanks for taking the time to add this feature. The selector function for subscriptions will be useful.

Unfortunately there's an issue with the implementation due to the way that subscribers must successfully acknowledge each received event. If an event is filtered by the selector function and not sent to the subscriber, it won't be acknowledged. The subscription will then become stuck waiting for the ack it'll never be sent.

I've added a failing unit test to branch pr/114 to demonstrate the problem. I haven't thought of a way to resolve the issue, yet. The subscription process will likely need to remember which events have been filtered so it doesn't need to wait for the acknowledgement.

@christianjgreen
Copy link
Contributor Author

@slashdotdash how do you feel about resolving the ack on the producer's end? Instead of :nil when a filtered event is received, we ack the filtered events.

@slashdotdash
Copy link
Member

I’m looking at reworking the subscription FSM so that it remembers filtered event numbers and can automatically acknowledge them as required.

@christianjgreen
Copy link
Contributor Author

@slashdotdash we could add the filtered events to the state struct and keep track of them in a similar way pending_events are.

@slashdotdash
Copy link
Member

slashdotdash commented May 6, 2018

I've reworked the subscription FSM to track the event number for any filtered events in the feature/rework-subscription-catch-up branch. This allows the subscription to acknowledge any subsequent filtered events when the subscriber acks an event.

slashdotdash and others added 2 commits May 6, 2018 23:10
Add failing test for subscription selector function. Subscriptions will wait until the last event sent to the subscriber has been successfully acknowledge. If this event is filtered, then the subscriber cannot ack it, instead the subscription will remain stuck.
Remove separate catch-up subscription process.
Rename `last_seen` to `last_sent` in subscription FSM.
@christianjgreen
Copy link
Contributor Author

Merged!

@slashdotdash slashdotdash merged commit 4ea0185 into commanded:master May 13, 2018
@slashdotdash slashdotdash changed the title Initial proposal for event filtering Allow subscriptions to filter the events they receive May 13, 2018
slashdotdash added a commit that referenced this pull request May 13, 2018
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 this pull request may close these issues.

2 participants