dashbitco / dashbitco/nimble_pool

New callback for generic message handling

Open
#48 0 comments 0 reactions 0 assignees View on GitHub

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:

  1. Adding a handle_info/2 clause to NimblePool that matches messages like {:pool_info, term}.

  2. Adding pool_send/2 and pool_send_after/2 functions to send a term to the pool, wrapping it in the :pool_info tuple.

  3. The new handle_info/2 would unwrap and forward the term to a user-defined handle_pool_info/2 callback, which would receive the term and the pool state.

  4. The handle_pool_info/2 may return the same options as the GenServer's handle_info callback and it will in fact be the return value of the new handle_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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.