lexbor_erl_pool (lexbor_erl v0.3.0)

View Source

Worker pool coordinator for lexbor_erl.

This module manages a pool of worker processes and routes requests to them. It implements intelligent routing based on operation type:

  • Stateless operations: Time-based hash distribution across workers
  • New documents: Assigned to worker via time-based selection
  • Stateful operations: Routed by DocId to ensure same worker

The pool uses DocId encoding to embed worker information, allowing stateful operations to automatically route to the correct worker.

Workers are discovered dynamically by registered name, allowing them to be supervised independently. This provides fault isolation - if a worker crashes, only that worker restarts.

Summary

Functions

alive()

-spec alive() -> boolean().

Check if the pool is alive and has at least one worker.

call(Key, _)

-spec call(undefined | {new_doc, pos_integer()} | non_neg_integer(), {binary(), binary()}) ->
              {ok, binary()} | {error, term()}.

code_change(OldVsn, State, Extra)

get_pool_size()

-spec get_pool_size() -> pos_integer().

Get the configured pool size.

handle_call(Request, From, State)

handle_cast(Msg, State)

handle_info(Info, State)

init(_)

start_link(PoolSize)

-spec start_link(pos_integer()) -> {ok, pid()} | {error, term()}.

Start the pool coordinator.

terminate(Reason, State)