libero/codegen_dispatch

Server-side dispatch generator.

Produces dispatch source from a list of handler endpoints. The generated module pattern-matches incoming wire envelopes onto handler function calls and produces ETF-encoded responses.

Each handler call is wrapped in trace.try_call so a panicked handler produces a structured InternalError response (with trace ID for log correlation) instead of crashing the caller’s process.

Types

pub type ExtraParam {
  ExtraParam(name: String, type_ref: String, import_line: String)
}

Constructors

  • ExtraParam(name: String, type_ref: String, import_line: String)

Values

pub fn generate(
  endpoints endpoints: List(scanner.HandlerEndpoint),
  context_module context_module: String,
  context_type_name context_type_name: String,
  wire_module_tag wire_module_tag: String,
  atoms_module atoms_module: option.Option(String),
  wire_module wire_module: option.Option(String),
) -> String

Generate dispatch.gleam source from scanned endpoints.

pub fn generate_atoms_erl(
  endpoints endpoints: List(scanner.HandlerEndpoint),
  discovered discovered: List(walker.DiscoveredType),
  atoms_module atoms_module: String,
  wire_module wire_module: option.Option(String),
) -> String

Generate an Erlang FFI file that pre-registers all constructor atoms discovered from handler endpoints, plus framework atoms used by libero’s wire protocol. Calling ensure/0 from this module creates the atoms in the BEAM atom table so that binary_to_term([safe]) can decode client ETF payloads without rejecting unknown atoms.

Under the wire-identity scheme there is no AtomMap: identity is baked into the per-type transformer functions in <consumer>_wire.erl at codegen time, so the runtime carries no qualification table.

pub fn generate_with_extra_params(
  endpoints endpoints: List(scanner.HandlerEndpoint),
  context_module context_module: String,
  context_type_name context_type_name: String,
  wire_module_tag wire_module_tag: String,
  atoms_module atoms_module: option.Option(String),
  wire_module wire_module: option.Option(String),
  extra_params extra_params: List(ExtraParam),
) -> String

Generate dispatch with additional pass-through parameters on handle() and every handler call. Each ExtraParam adds an import, a function parameter, and a labeled argument threaded to handlers.

Search Document