A pool of Deno runtimes with pluggable dispatch strategies.
Tyrex.Pool is a Supervisor that starts multiple Tyrex GenServer children
and distributes eval calls across them using a configurable strategy.
Usage
# In your supervision tree
children = [
{Tyrex.Pool, name: :js_pool, size: 4}
]
# Evaluate code on a pool-selected runtime
{:ok, result} = Tyrex.Pool.eval(:js_pool, "1 + 2")Strategies
Tyrex.Pool.Strategy.RoundRobin(default) — cycles through runtimes sequentiallyTyrex.Pool.Strategy.Random— picks a random runtimeTyrex.Pool.Strategy.Hash— routes by:keyoption for sticky sessions
See Tyrex.Pool.Strategy for implementing custom strategies.
Lifecycle
The pool registers its metadata in :persistent_term and may own ETS tables
via its strategy. Both are cleaned up automatically when the supervisor is
stopped — Tyrex.Pool is safe to start and stop dynamically (e.g. one pool
per tenant) without leaking persistent_term or ETS resources.
Summary
Functions
Returns a specification to start this module under a supervisor.
Run JavaScript code on a runtime selected by the pool's strategy.
Same as eval/3, but raises Tyrex.Error on error.
Start a pool of Tyrex runtimes.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec eval(atom(), binary(), Keyword.t()) :: {:ok, term()} | {:error, Tyrex.Error.t()}
Run JavaScript code on a runtime selected by the pool's strategy.
Options
:key- Dispatch key (used by hash strategy for sticky sessions).:timeout- Timeout for the call.:blocking- Whether to use blocking mode.
Same as eval/3, but raises Tyrex.Error on error.
@spec start_link(Keyword.t()) :: Supervisor.on_start()
Start a pool of Tyrex runtimes.
Options
:name- Required. The name of the pool.:size- Number of runtimes. Defaults toSystem.schedulers_online().:strategy- Dispatch strategy module. Defaults toTyrex.Pool.Strategy.RoundRobin.:main_module_path- Path to the main JS module for all runtimes.:permissions- Runtime permissions. SeeTyrex.start/1for details.