ReactiveDag.Config (reactive_dag v0.17.0-rc.2)

Copy Markdown View Source

Boot-time validation of config :reactive_dag, ….

Misconfiguration otherwise surfaces at the first query — a missing :repo raises on the first drain, which may be a long way into a deploy and in whatever process happened to trigger it. Worse, only :repo raises at all: a :coordination_writer pointing at a module that does not implement the behaviour, or a table name that is not a valid identifier, fails later and less legibly.

Call it once at boot:

def start(_type, _args) do
  ReactiveDag.Config.validate!()
  Supervisor.start_link(children, opts)
end

It reports every problem it finds, not the first — a config with two mistakes should take one deploy to fix, not two.

Why the host calls it

Deliberately not an Application callback of our own. The library starting its own app would mean it has a supervision tree and an opinion about when it starts, and the check could not be skipped by tests that deliberately run unconfigured (this library's own suite has several). An explicit call is testable, skippable, and works whether or not :reactive_dag is started as an application.

What it does not check

Only what is definitely wrong. A validator that warns about the suspicious-but-legal gets wrapped in a try and stops being read — so a default :coordination_writer on a host that clearly has extension columns passes silently. Nothing here touches the database: whether the tables exist is ReactiveDag.Migration's business, and a boot check that queries would make boot depend on the database being reachable.

Summary

Functions

The problems as a list of strings, for a host that would rather log or surface them than raise. [] means the configuration is sound.

Validate the configuration, raising ReactiveDag.Config.Error listing every problem. Returns :ok when there is nothing wrong.

Functions

problems()

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

The problems as a list of strings, for a host that would rather log or surface them than raise. [] means the configuration is sound.

validate!()

@spec validate!() :: :ok

Validate the configuration, raising ReactiveDag.Config.Error listing every problem. Returns :ok when there is nothing wrong.