An in-BEAM stand-in for the runner daemon, speaking the exact wire
protocol Managoat.Runner.Connection speaks, so the adapter and the
connection process are exercised end to end without a Go binary or a
network.
It lives under lib/, not test/support, for the same reason
Managoat.Sandbox.Fake does: a host application's tests and any
consumer's tests drive it, so it is compiled in every environment.
Two processes:
- a socket process running
Managoat.Runner.Connectionas aWebSockhandler would — it is the registered connection process: messages from callers reach it ashandle_info/2, frames from the daemon reach it ashandle_in/2, and pushed frames go to the daemon; - the daemon process, which implements the ops. Sandboxes are maps
of files; commands speak the same scripted vocabulary as
Managoat.Sandbox.Fake(out:,err:,exit:,stay,drop) and run as real processes emitting real frames; sessions journal every frame andattachreplays from byte zero.
start/2 connects a daemon for runner_id; stop/1 disconnects it (the
socket process exits, so callers see the disconnected errors). It is the
executable form of the protocol description in Connection's moduledoc —
the Go daemon must agree with it.
Summary
Functions
Connect a fake daemon for the runner. Returns {:ok, %{socket: pid, daemon: pid}}.
The socket process registers with the host, so whereis/1 finds it.
Disconnect: the socket process stops through terminate/2 — as Bandit
runs a WebSock handler's on close — so the offline broadcast and the
pending-reply failures fire as they do live; the daemon is killed.
Functions
Connect a fake daemon for the runner. Returns {:ok, %{socket: pid, daemon: pid}}.
The socket process registers with the host, so whereis/1 finds it.
Options: :name (the runner's display name, default "fake"), :meta
(the opaque map handed to the host, default %{}) and :host (a
Managoat.Runner.Host for this connection, overriding the configured one).
Disconnect: the socket process stops through terminate/2 — as Bandit
runs a WebSock handler's on close — so the offline broadcast and the
pending-reply failures fire as they do live; the daemon is killed.