lexbor_erl_worker (lexbor_erl v0.3.0)

View Source

Individual worker process managing a Lexbor C port.

Each worker manages an independent C port process that communicates with the Lexbor library. Workers are:

  • Single-threaded: Process one request at a time
  • Isolated: Have their own document registry
  • Supervised: Restarted independently if they crash
  • Registered: Can be discovered by name

Workers register themselves with a unique name based on their worker ID, allowing the pool to discover them dynamically and enabling independent supervision.

Summary

Functions

Send a command to a worker and wait for reply.

Start a worker and register it with a unique name.

Generate the registered name for a worker.

Functions

call(Worker, CmdTag, Payload)

-spec call(pid(), binary(), binary()) -> {ok, binary()} | {error, term()}.

Send a command to a worker and wait for reply.

code_change(OldVsn, State, Extra)

handle_call(_, From, State)

handle_cast(Msg, S)

handle_info(Msg, State)

init(_)

start_link(WorkerId)

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

Start a worker and register it with a unique name.

The worker opens a port to the Lexbor C executable and registers itself as lexbor_erl_worker_N where N is the WorkerId.

terminate(Reason, State)

worker_name(WorkerId)

Generate the registered name for a worker.