dashbitco / dashbitco/nimble_pool
New callback for generic message handling
Nobody has claimed this yet.
- Dominant language
- Elixir
- Stars
- 390
- Forks
- 29
- Avg merge
- 1h 12m
- Merged PRs (30d)
- 1
Description
As discussed in https://github.com/dashbitco/nimble_pool/issues/46, introducing a new callback for generic message handling inside the pool process could be very useful!
It would enable at least two features:
-
Idle termination of empty pools (currently not possible with
handle_ping/2, as it only pings workers). -
Safe pool termination, avoiding race conditions when a checkout occurs just as the pool is about to terminate due to idleness.
From what I understand of the proposed solution, it would involve:
-
Adding a
handle_info/2clause to NimblePool that matches messages like{:pool_info, term}. -
Adding
pool_send/2andpool_send_after/2functions to send a term to the pool, wrapping it in the:pool_infotuple. -
The new
handle_info/2would unwrap and forward the term to a user-definedhandle_pool_info/2callback, which would receive the term and the pool state. -
The
handle_pool_info/2may return the same options as the GenServer'shandle_infocallback and it will in fact be the return value of the newhandle_info/2
I think this approach is as flexible as we could get and may enable the user side implementation of pretty much everything.
If you're on board with this idea and implementation, I can probably start working on it by the weekend.
Let me know your thoughts! Thanks!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading NimblePool's existing handle_ping/2 behavior and the pool process message-handling path. Define the pool_send/2, pool_send_after/2, handle_info/2, and handle_pool_info/2 callback behavior described in the issue, including supported return options. Done means generic pool messages support idle termination and safe pool termination without checkout races.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- elixir
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100