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

Event streaming shouldn't be limited to the number of threads in executor service #16

Open
cardil opened this issue Apr 13, 2023 · 0 comments
Labels
kind/enhancement New feature or request

Comments

@cardil
Copy link
Member

cardil commented Apr 13, 2023

As discussed #11 (comment) the current implementation is limited to the number of threads in the executor service.

private final ExecutorService executorService =
Executors.newFixedThreadPool(12);
Multi<CloudEvent> stream() {
var p = new EventsPuller();
return Multi.createBy()
.repeating()
.supplier(p::pull)
.indefinitely()
.runSubscriptionOn(executorService);
}

It should be possible to rewrite it to better solution, which either:

  • Make an 'artificial' stream that emits a 'heartbeat' every 25ms and only then wakes up, looks at events and goes to sleep. That should handle any number of calls on a single thread
  • Use a different implementation of events that is event-driven, that is, it tells you when something appears in it. Maybe using MultiCreate#emitter(java.util.function.Consumer) is a good idea. We can use a factory like this and just call emit on it as we get the next event. The stream emits nothing, and everything non-blocking sleeps.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant