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

Copy Markdown View Source

Loads relay plugins and monitors allocation lifetimes.

What problem this solves

XTurn extensions implement the plugin behaviour to observe or transform relay traffic (logging, recording, policy). This GenServer reads :plugins from application env, validates callback exports, caches the enabled list in :persistent_term, and registers Process.monitor/1 refs for allocation owners and passive plugin instances.

When an allocation owner exits, teardown runs in a spawned process so slow handle_close/2 callbacks cannot block monitor handling. Call reload/0 after changing plugin config at runtime.

RFCs

  • RFC 5766 (TURN relay path plugins attach to)

Summary

Functions

Returns a specification to start this module under a supervisor.

Reads a framework option from plugin config with a default.

Returns plugin-specific options, stripping framework keys.

Returns the enabled plugin list loaded from application env.

Reloads the plugin list from application env and updates :persistent_term.

Starts the plugin manager (registered as __MODULE__).

Registers monitors for one allocation: its owning Allocate.Client and each of its passive instances.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

framework_opt(opts, key, default)

Reads a framework option from plugin config with a default.

plugin_opts(opts)

Returns plugin-specific options, stripping framework keys.

plugins()

Returns the enabled plugin list loaded from application env.

reload()

Reloads the plugin list from application env and updates :persistent_term.

start_link(opts \\ [])

Starts the plugin manager (registered as __MODULE__).

watch(tuple5, owner_pid, instances)

Registers monitors for one allocation: its owning Allocate.Client and each of its passive instances.

Synchronous on purpose. A cast could land after the monitored process had already died, and Process.monitor/1 on a dead pid reports :noproc rather than the real exit reason -- which is exactly the reason plugins are told about in handle_close/2. One call per allocation, never per frame.