Kepler.Config (Kepler v0.1.0)

Copy Markdown View Source

Reads and validates Kepler's application environment.

Everything is validated at boot and invalid configuration raises, because the failure mode this prevents — a Kepler that runs happily and delivers nowhere — is the one you would not notice until you needed it.

config :kepler,
  watches: MyApp.Watches,
  sinks: [{Kepler.Sink.Webhook, url: System.fetch_env!("KEPLER_WEBHOOK_URL")}]

Keys

  • :enabled — set to false to start the supervision tree without installing anything. Defaults to true.
  • :watches — a module using Kepler, or a list of them.
  • :sinks — a keyword list of name: spec, where spec is a Kepler.Sink.spec/0. Watches route to sinks by name. An empty list logs a warning at boot: watches with no sink evaluate and then discard.
  • :tick — milliseconds between evaluation passes. Defaults to 1_000. Below 100 is refused; that is a poller, not a profiler.
  • :buffer — emitter limits. :max_size (default 500), :drop (:oldest or :newest, default :oldest), :max_in_flight (default 4), and :delivery_timeout (default 15_000 ms), after which a sink that has stopped responding is killed rather than holding an in-flight slot forever.
  • :budget — self-limiting. :share is the fraction of one node's compute Kepler may use before shedding, default 0.01. :shed_after and :restore_after are how many consecutive ticks over or under the limit it takes to act, defaulting to 3 and 10. :max_tick caps the slowed-down interval, default 30 seconds. Set share: :infinity to disable shedding.
  • :system_monitor:takeover decides what to do when something else already holds the node's single system monitor. Defaults to false, which yields and logs rather than stomping :observer or :recon.

Summary

Functions

Builds a validated config from the application environment.

Types

t()

@type t() :: %Kepler.Config{
  budget: %{
    share: float() | :infinity,
    shed_after: pos_integer(),
    restore_after: pos_integer(),
    max_tick: pos_integer()
  },
  buffer: %{
    max_size: pos_integer(),
    drop: :oldest | :newest,
    max_in_flight: pos_integer(),
    delivery_timeout: pos_integer()
  },
  enabled: boolean(),
  sinks: keyword(Kepler.Sink.spec()),
  system_monitor: %{takeover: boolean()},
  tick: pos_integer(),
  watches: [module()]
}

Functions

load(overrides \\ [])

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

Builds a validated config from the application environment.

overrides take precedence, which is how tests start Kepler with a specific setup without touching global state.