lexbor_erl_pool (lexbor_erl v0.3.0)
View SourceWorker 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
Check if the pool is alive and has at least one worker.
Get the configured pool size.
Start the pool coordinator.
Functions
-spec alive() -> boolean().
Check if the pool is alive and has at least one worker.
-spec call(undefined | {new_doc, pos_integer()} | non_neg_integer(), {binary(), binary()}) -> {ok, binary()} | {error, term()}.
-spec get_pool_size() -> pos_integer().
Get the configured pool size.
-spec start_link(pos_integer()) -> {ok, pid()} | {error, term()}.
Start the pool coordinator.