Rho.Dyn.Config (rho v0.1.0)

Copy Markdown View Source

The host's settings for the Dyn layer, config :rho, :dyn, [...] (see Rho.Dyn). Every key has a default; a host that doesn't use Dyn sets none of them.

  • :enabled: Rho.Supervisor starts the Dyn processes (the Keeper and the approval store), adds the dyn_* tools to the registry's core tools and Rho.Dyn.Source to its sources. Default false; Rho.Supervisor's :dyn option overrides it.
  • :namespace: the module namespace the agent writes in (defmodule Dyn.Weather), compiled as <namespace>.G<n>.*. Default Dyn. Fixed for an install: generations on disk name it. It may be below a Core prefix (Operator's Operator.Dyn, below Operator), but not below Rho (rho's own modules live there), nor at or above a Core prefix (the Core's modules would count as Dyn code and drop out of the runtime digest): Rho.Dyn.Keeper refuses to start then (validate!/0).
  • :app: the host's OTP application. Its version and modules are part of the Core (Rho.Dyn.Compiler.runtime/0: a new Core rebuilds every generation). Default nil (rho's own only).
  • :core: the host's own module prefixes ([MyApp]): its Core code, in the runtime digest and off limits to Dyn code except :allowed. Rho is always one. Default [].
  • :allowed: Core modules Dyn code may call ([MyApp.Files]). Rho.Tool is always one. Default [].
  • :check: the static check's lists, merged over its defaults (Rho.Dyn.Check.defaults/0: Operator's, except the entries naming Operator's own code): :banned (%{module => why}), :banned_erlang (%{atom => why}), :partial (%{module => [function]}: allowed modules with forbidden functions), :gated (%{prefix => [module]}: only those modules below the prefix), :forging (%{atom => why}: atoms Dyn code may not hold), :sigils (%{sigil_atom => module}: template sigils whose expressions are code, expanded by that module's macro before the check), :handlers ([{module, function, arity, index}]: calls whose argument index is a {Module, :function} handler run later, checked as a call). A nil value drops a default entry.
  • :screens: the host's screen integration, a Rho.Dyn.Screens module. Default Rho.Dyn.Screens.None (no screens: the first "render" is the boot); a mob app sets Rho.Dyn.Screens.Mob.
  • :guide: text appended to Rho.Dyn.agent_guide/0 (the host's own rules: its file roots, a menu Dyn code adds rows to, ...), a string or an MFA / 0-arity function. Default none.
  • The Keeper's options (Rho.Dyn.Keeper): :approval, :probation_ms, :crash_limit, :on_stable, ...

Summary

Functions

The Core modules Dyn code may call, as written.

The host's OTP application (:app), or nil.

The :check overrides as given (Rho.Dyn.Check merges them over its defaults).

The Core's module prefixes as written (["Rho", "MyApp"]).

Is :enabled set to true?

The prefix of generation n's module names, as atoms print ("Elixir.Dyn.G3.").

The whole config :rho, :dyn keyword list ([] when unset).

The :guide text, resolved; nil when unset.

A module as written: MyApp.Files and "MyApp.Files" are "MyApp.Files".

The namespace module (Dyn by default).

The namespace as written ("Dyn", "MyApp.Dyn").

The namespace's alias segments ([:MyApp, :Dyn]).

The :screens module (Rho.Dyn.Screens.None by default).

Is name (as written) prefix or below it?

Raises ArgumentError if the namespace is below Rho, or is a Core prefix or above one (see :namespace).

Functions

allowed()

@spec allowed() :: [String.t()]

The Core modules Dyn code may call, as written.

app()

@spec app() :: atom() | nil

The host's OTP application (:app), or nil.

check()

@spec check() :: keyword()

The :check overrides as given (Rho.Dyn.Check merges them over its defaults).

core()

@spec core() :: [String.t()]

The Core's module prefixes as written (["Rho", "MyApp"]).

enabled?()

@spec enabled?() :: boolean()

Is :enabled set to true?

generation_prefix(n)

@spec generation_prefix(non_neg_integer()) :: String.t()

The prefix of generation n's module names, as atoms print ("Elixir.Dyn.G3.").

get()

@spec get() :: keyword()

The whole config :rho, :dyn keyword list ([] when unset).

guide()

@spec guide() :: String.t() | nil

The :guide text, resolved; nil when unset.

name(name)

@spec name(module() | String.t()) :: String.t()

A module as written: MyApp.Files and "MyApp.Files" are "MyApp.Files".

namespace()

@spec namespace() :: module()

The namespace module (Dyn by default).

namespace_name()

@spec namespace_name() :: String.t()

The namespace as written ("Dyn", "MyApp.Dyn").

namespace_segments()

@spec namespace_segments() :: [atom()]

The namespace's alias segments ([:MyApp, :Dyn]).

screens()

@spec screens() :: module()

The :screens module (Rho.Dyn.Screens.None by default).

under?(name, prefix)

@spec under?(String.t(), String.t()) :: boolean()

Is name (as written) prefix or below it?

validate!()

@spec validate!() :: :ok

Raises ArgumentError if the namespace is below Rho, or is a Core prefix or above one (see :namespace).