Letterpress.Compiler.Worker (Letterpress v0.1.0)

Copy Markdown View Source

Owns one framed JSON connection to the bundled Node compiler.

Requests are serialized per worker. Timeouts, malformed frames, mismatched IDs, and process exits fail queued callers and terminate the worker so its supervisor establishes a fresh protocol boundary.

This is an implementation module. Applications supervise Letterpress.Compiler.Supervisor and use Letterpress or Letterpress.Compiler, rather than starting or calling workers directly.

Summary

Functions

Returns a specification to start this module under a supervisor.

Queues a request on a worker in the default compiler pool.

Starts one compiler worker for the configured pool and index.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

request(index, operation, payload, timeout)

@spec request(non_neg_integer(), atom(), map(), timeout()) ::
  {:ok, map()} | {:error, term()}

Queues a request on a worker in the default compiler pool.

Prefer Letterpress.Compiler.request/3, which selects an available worker and converts a missing pool into a tagged error.

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()

Starts one compiler worker for the configured pool and index.

Called by Letterpress.Compiler.Supervisor; it is not a host application integration point.