Letterpress.Compiler.Supervisor (Letterpress v0.1.0)

Copy Markdown View Source

A caller-owned supervisor for a pool of isolated compiler workers.

Letterpress does not start this supervisor automatically. Add it to the host application's supervision tree on nodes that perform authoring work. Nodes that only render stored artifacts do not need a compiler pool or Node.

Each pool has a registered :pool name. Pass that name as :compiler_pool to the functions in Letterpress when using a non-default pool.

Example

children = [
  {Letterpress.Compiler.Supervisor,
   pool: MyApp.LetterpressCompiler,
   pool_size: 2,
   max_frame_bytes: 2_000_000}
]

Supervisor.start_link(children, strategy: :one_for_one)

A protocol failure restarts only the affected worker. Calls already queued on that worker receive an explicit error.

Summary

Functions

Returns a child specification for a compiler pool.

Starts a compiler pool linked to the caller.

Functions

child_spec(init_arg)

@spec child_spec(keyword()) :: Supervisor.child_spec()

Returns a child specification for a compiler pool.

Options

  • :pool - registered pool name; defaults to Letterpress.Compiler.Pool
  • :pool_size - number of compiler workers; defaults to 2
  • :max_frame_bytes - largest accepted response frame; defaults to 2_000_000

Use a distinct :pool for each independently configured instance. The pool name is also the child specification ID, so several pools can share one host supervisor.

start_link(opts \\ [])

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

Starts a compiler pool linked to the caller.

Applications normally start the child specification returned by child_spec/1 instead of calling this function directly.