Tyrex.Runtime (Tyrex v0.4.0)

Copy Markdown View Source

State of a running Tyrex GenServer.

This is an opaque value managed internally by Tyrex — you should not create or modify it directly.

The :reference field is the opaque NIF resource handle (a Rustler ResourceArc) that keeps the underlying Deno worker alive for as long as this struct is reachable. Dropping the struct without a matching Tyrex.stop/1 lets the resource be garbage-collected, which terminates the isolate and signals the worker to shut down.

Summary

Types

A single entry of the :apply allowlist, keyed by the exact strings guest JavaScript passes to Tyrex.apply and the argument count it supplies.

t()

Tyrex runtime state: the opaque NIF resource reference, the resolved Tyrex.apply allowlist (nil when the bridge is disabled), and the map of in-flight eval callers to their deadline timers.

Types

allowlist()

@type allowlist() ::
  %{required({binary(), binary(), arity()}) => {module(), atom()}} | nil

A single entry of the :apply allowlist, keyed by the exact strings guest JavaScript passes to Tyrex.apply and the argument count it supplies.

t()

@type t() :: %Tyrex.Runtime{
  apply_allowlist: allowlist(),
  inflight: %{required(GenServer.from()) => reference()},
  reference: reference()
}

Tyrex runtime state: the opaque NIF resource reference, the resolved Tyrex.apply allowlist (nil when the bridge is disabled), and the map of in-flight eval callers to their deadline timers.