GameServer.Hooks.DynamicRpcs (GameServer v1.0.509)

Runtime registry for dynamic RPC function names exported by hook plugins.

Goal

Allow hook plugins to expose additional callable function names without defining them as exported Elixir functions (eg. without def my_fn/1).

The intended pattern is:

  • Plugin implements after_startup/0 and returns a list of maps describing which dynamic RPC names should be callable.
  • Plugin implements rpc/2 (or rpc/3) to handle these names at runtime.
  • GameServer.Hooks.PluginManager.call_rpc/4 falls back to the registry when the requested function is not exported.

Export format

after_startup/0 may return a list like:

[
  %{hook: "my_dynamic_fn"},
  %{"hook" => "other_fn", "meta" => %{...}}
]

Required:

  • hook (string): the callable function name.

Optional:

  • meta (map): arbitrary metadata.

Names are validated to contain only letters, digits, and underscores.

Note: this registry is in-memory and is rebuilt on plugin reload.

Summary

Types

export()

@type export() :: %{hook: hook_name(), meta: map()}

hook_name()

@type hook_name() :: String.t()

plugin_name()

@type plugin_name() :: String.t()

Functions

allowed?(plugin_name, hook_name)

@spec allowed?(plugin_name(), hook_name()) :: boolean()

ensure_table!()

@spec ensure_table!() :: :ok

list_all()

@spec list_all() :: %{optional(plugin_name()) => [export()]}

lookup(plugin_name, hook_name)

@spec lookup(plugin_name(), hook_name()) :: {:ok, export()} | {:error, :not_found}

register_exports(plugin_name, raw)

@spec register_exports(plugin_name(), any()) ::
  {:ok, non_neg_integer()} | {:error, term()}

reset_all()

@spec reset_all() :: :ok