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

refactor: subscription predicate #770

Closed
wants to merge 1 commit into from
Closed

Conversation

neurosnap
Copy link
Collaborator

@neurosnap neurosnap commented Sep 28, 2023

Motivation

This PR attempts to improve the performance of filtering streams by allowing a subscription to be called with a predicate. So instead of filtering on top of a stream (via filter()) we apply the filter logic within the stream. This makes it so when stream.send(...) gets called, the consumers only get activated if the item passes the predicate filter.

BEFORE

// create 100 consumers where 10 are listening for "action"
stream.send({ type: "action" });
// all 100 consumers get activated, but only 10 matching consumers continue their operation

Screenshot 2023-11-01 at 11 30 53 AM

AFTER

// create 100 consumers
stream.send({ type: "action" });
// only 10 consumers get activated and continue their operation

Screenshot 2023-11-01 at 11 26 13 AM

Base automatically changed from cl/remove-some-event-streams-from-block to v3 September 29, 2023 15:25
@neurosnap neurosnap force-pushed the v3-subscription-predicate branch from 333a733 to 1fb4535 Compare October 2, 2023 14:55
@neurosnap neurosnap force-pushed the v3-subscription-predicate branch from 4212526 to f42d865 Compare November 1, 2023 15:34
@neurosnap neurosnap closed this Dec 7, 2023
@neurosnap neurosnap deleted the v3-subscription-predicate branch December 7, 2023 14:53
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.

1 participant