ExMaude. Backend. Port
(ExMaude v0.3.0)
View Source
Port-based backend for ExMaude.
This backend communicates with Maude via an Erlang Port over plain pipes,
passing -interactive so Maude prints its prompt for response detection
(the same mode the C-Node and NIF backends use).
Features
- Full process isolation - Maude crashes don't affect the BEAM
- Works with any Maude installation
- No native code compilation required
Trade-offs
- Higher latency than the NIF backend due to port messaging and text parsing
- Regex-based error detection
- Larger memory footprint per worker
Configuration
config :ex_maude,
backend: :port,
use_pty: false # Set to true to wrap Maude in a PTY (script/unbuffer)Timeouts and worker lifecycle
Each command carries its own timeout. When it fires, the caller receives
{:error, %ExMaude.Error{type: :timeout}} and the worker stops with
{:shutdown, :command_timeout} so the pool replaces it with a fresh
process. Maude has no way to cancel an in-flight computation, so a
timed-out session is in an indeterminate state — reusing it could deliver
the previous command's response to the next caller.
Summary
Functions
Returns a specification to start this module under a supervisor.
Types
@type pending() :: %{ from: GenServer.from(), ref: reference(), timer: reference(), timeout: pos_integer() }
The in-flight command, if any.
The ref ties the pending command to its {:command_timeout, ref} timer
message: a timer that fires after its command completed carries a stale
ref and is ignored instead of cutting into the next command.
@type t() :: %ExMaude.Backend.Port{ buffer: String.t() | nil, maude_path: String.t() | nil, os_pid: non_neg_integer() | nil, pending: pending() | nil, port: port() | nil }
Internal state for the Port backend GenServer.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.