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

single-threaded mode? #712

Open
jlevon opened this issue Jan 19, 2024 · 1 comment
Open

single-threaded mode? #712

jlevon opened this issue Jan 19, 2024 · 1 comment
Labels
proposal Enhancement idea or proposal

Comments

@jlevon
Copy link

jlevon commented Jan 19, 2024

Proposed change

I'm curious if there's been any discussion of a single-threaded mode for when using an event loop.
We would like to integrate with our (private) event loop instead of using a threaded model.

While the existing SetEventLoop callbacks work great for my needs (which is just publishing to a jetstream stream, no need for replies or any other stuff), with SendASAP set, this all falls apart during reconnection handling, where the reconnection happens off thread. This includes ping interval processing.

The example libuv code (thank you for writing this!) goes through some gymnastics to make sure the reconnection is processed back on the main event thread safely, but this would all be much simpler if for example, the event loop could process the timers itself rather than on the thread.

I'm not quite clear on the asyncCB and GC threads, but apparently I haven't hit them actually being used yet.

Use case

See above.

Contribution

I don't think I understand the core code well enough.

@jlevon jlevon added the proposal Enhancement idea or proposal label Jan 19, 2024
@calvin2021y
Copy link

This is very classic single-threaded use case, with a busy event loop, error callback and timer handle in main thread can speed up a lot, and much fast without lock. also be able to handle a lot connection.

And when there is an error, the callback should be able to handle the original message/request with context. (let user decide what to do, or auto resent when reconnected)

There are many libraries available for reference, such as libzmq, rdkafaka.

@kozlovic @wallyqs @derekcollison

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal Enhancement idea or proposal
Projects
None yet
Development

No branches or pull requests

2 participants