Rulestead.Config (rulestead v1.0.0)

Copy Markdown View Source

Validated host-app seam configuration for Rulestead.

Rulestead.Config is stable in the 1.x contract (api_stability.md — "Stable rulestead Modules"). It owns the validated configuration schema for the Plug, LiveView, Oban, Runtime, and Tenancy integration points.

Configuration

Rulestead reads its configuration from Application.get_env(:rulestead, :host). All keys are optional — the defaults below are used for any key not supplied.

# config/config.exs
config :rulestead, :host,
  environment_key: "production",
  plug: [
    context_assign: :rulestead_context,
    targeting_key_sources: [
      {:session, "targeting_key"},
      {:cookie, "rulestead_targeting_key"},
      {:header, "x-rulestead-targeting-key"}
    ]
  ],
  runtime: [
    api: Rulestead.Runtime,
    pubsub: MyApp.PubSub
  ]

Public API

  • validate/1 — validate a keyword list, returning {:ok, config} or {:error, reason}
  • validate!/1 — validate a keyword list, raising on invalid input
  • load/1 — load from application env, merge overrides, and validate; raises on invalid config
  • defaults/0 — return the compiled default configuration keyword list
  • schema/0 — return the raw NimbleOptions schema keyword list

Defaults

KeyDefault
environment_key"dev"
plug.context_assign:rulestead_context
live_view.assign_flags_mode:enabled
oban.enabledtrue
runtime.notifierRulestead.Runtime.Notifier.PhoenixPubSub
tenancy.moduleRulestead.Tenancy.SingleTenant

The full default set is returned by defaults/0.

Summary

Types

t()

@type t() :: keyword() | map()

Functions

defaults()

@spec defaults() :: keyword()

load(overrides \\ [])

@spec load(keyword()) :: t()

schema()

@spec schema() :: keyword()

validate(opts \\ [])

@spec validate(keyword()) :: {:ok, t()} | {:error, NimbleOptions.ValidationError.t()}

validate!(opts \\ [])

@spec validate!(keyword()) :: t()

validate_optional_module(module)

validate_pubsub(pubsub)