ExMaude.Server (ExMaude v0.2.0)

View Source

GenServer that manages a single Maude process.

This module delegates to the configured backend (Port, C-Node, or NIF). See ExMaude.Backend for backend selection.

Architecture

Each Server maintains a persistent Maude session. Commands are sent via the configured backend and responses are collected until complete.

Usage

This module is typically used via ExMaude.Pool rather than directly:

{:ok, pid} = ExMaude.Server.start_link([])
{:ok, result} = ExMaude.Server.execute(pid, "reduce in NAT : 1 + 2 .")

Configuration

The following options can be passed to start_link/1:

  • :maude_path - Path to Maude executable (default: bundled or from config)
  • :preload_modules - List of Maude files to load on startup
  • :timeout - Default command timeout in ms (default: 5000)

Application Configuration

config :ex_maude,
  backend: :port,              # :port | :cnode | :nif
  maude_path: nil,             # nil = auto-detect bundled binary
  use_pty: true                # For Port backend only

Summary

Functions

Checks if the Maude process is alive.

Returns the default timeout in milliseconds.

Executes a Maude command and waits for the result.

Loads a Maude file into this server's session.

Starts a new Maude server process using the configured backend.

Stops the Maude server.

Functions

alive?(server)

@spec alive?(GenServer.server()) :: boolean()

Checks if the Maude process is alive.

default_timeout()

@spec default_timeout() :: 5000

Returns the default timeout in milliseconds.

execute(server, command, opts \\ [])

@spec execute(GenServer.server(), String.t(), keyword()) ::
  {:ok, String.t()} | {:error, term()}

Executes a Maude command and waits for the result.

Options

  • :timeout - Maximum time to wait in ms (default: 5000)

load_file(server, path)

@spec load_file(GenServer.server(), Path.t()) :: :ok | {:error, term()}

Loads a Maude file into this server's session.

start_link(opts \\ [])

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

Starts a new Maude server process using the configured backend.

stop(server)

@spec stop(GenServer.server()) :: :ok

Stops the Maude server.