Xirsys.XTurn.Plugin.Instance (xturn v2.0.0)

Copy Markdown View Source

GenServer wrapper for a passive (out-of-band) relay plugin.

What problem this solves

Passive plugins must not run on the relay thread. This GenServer receives {:frame, payload, frame} messages from Plugin.Dispatch, forwards them to the plugin module's handle_frame/3, and decrements the shared inflight counter when processing completes. close/2 invokes handle_close/2 with the allocation's teardown reason so plugins learn why the relay ended, not only the supervisor's :shutdown.

Internal: one instance per passive plugin per allocation. Plugin authors implement the behaviour module; this wrapper is framework plumbing.

RFCs

Summary

Functions

Returns a specification to start this module under a supervisor.

Runs handle_close/2 with the allocation's own teardown reason and stops the instance. Without this the only reason a plugin could ever observe is the :shutdown the supervisor sends, which says nothing about why the allocation actually ended.

Starts a passive plugin instance under the dynamic supervisor.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

close(pid, reason)

Runs handle_close/2 with the allocation's own teardown reason and stops the instance. Without this the only reason a plugin could ever observe is the :shutdown the supervisor sends, which says nothing about why the allocation actually ended.

start_link(arg)

Starts a passive plugin instance under the dynamic supervisor.