feat: add custom thread pool name options#771
feat: add custom thread pool name options#771gabrielfranca95 wants to merge 3 commits intoclj-commons:masterfrom
Conversation
|
First of all: Thanks for your contribution! Looking at it now, I'm thinking that a better approach would be to allow passing in a custom thread factory. Then we can leave the caching / re-use concern up to the caller. They could still use |
Thank you for your feedback! I understand the point about Inversion of Control and removing the caching logic; I will apply the suggestions. |
- Add thread-pool-name parameter to start-server for custom server pool names - Add thread-pool-name parameter to connection-pool for custom client pool names - Custom client pools with same name share the same EventLoopGroup - Defaults to 'aleph-server-pool' and existing client pool for backwards compatibility - Update documentation in aleph.http namespace Closes clj-commons#769
Based on maintainer feedback on PR clj-commons#771: - Make enumerating-thread-factory public for users to create custom ThreadFactory - Server: replace :thread-pool-name with :thread-factory parameter - Client: replace :thread-pool-name with :event-loop-group parameter - Remove client-group-cache and get-client-group (leave caching to caller) - Update docstrings in aleph.http namespace This follows the Inversion of Control principle, allowing users full control over thread creation (not just naming) and EventLoopGroup lifecycle management. Closes clj-commons#769
ea741e2 to
751be85
Compare
Based on maintainer feedback on PR clj-commons#771: - Make enumerating-thread-factory public for users to create custom ThreadFactory - Server: replace :thread-pool-name with :thread-factory parameter - Client: replace :thread-pool-name with :event-loop-group parameter - Remove client-group-cache and get-client-group (leave caching to caller) - Update docstrings in aleph.http namespace This follows the Inversion of Control principle, allowing users full control over thread creation (not just naming) and EventLoopGroup lifecycle management. Closes clj-commons#769
751be85 to
ef33c04
Compare
|
I've updated the PR to implement your suggestions: Server now accepts :thread-factory instead of :thread-pool-name "First received frame was not SETTINGS" - HTTP/2 protocol error Please let me know if there's anything else I should address! |
|
Thanks! The test failure is indeed a known flake which has recently started happening (see #772). I've triggered a re-run of the job. As for the patch: I'm a bit unhappy about the asymmetry between client and server now (one accepting Furthermore, we should then also expose and document |
|
Thanks for the feedback! I totally agree that addressing the asymmetry is much cleaner, so I went ahead and implemented event-loop-group for both client and server. Regarding your question about the conflict: instead of making them mutually exclusive, I implemented a way to make them work together. I added validation that checks if the provided group is compatible with the requested transport; if not, it throws an exception. This feels like the most robust approach. I also exposed and documented transport-event-loop-group as suggested. |
Description
This PR addresses issue #769, which has been open since the community identified the need for better observability of Aleph's thread pools.
Problem
When running multiple Aleph servers or connection pools in the same process, all threads share hardcoded names like
aleph-server-pool-1,aleph-netty-client-event-pool-1, etc. This makes it impossible to distinguish which threads belong to which server/client in:Solution
Added a new
:thread-pool-nameoption that allows users to assign meaningful, distinguishable names to their thread pools while maintaining full backwards compatibility.Changes
Server-side: Add
:thread-pool-nameparameter tostart-server"aleph-server-pool"preserving existing behaviorClient-side: Add
:thread-pool-nameparameter toconnection-poolDocumentation: Updated docstrings in
aleph.httpnamespaceBackwards Compatibility
✅ Fully backwards compatible - All existing code continues to work without any changes. The new parameter is optional with sensible defaults matching previous behavior.
Example Usage