Reads SquatchMail's application configuration.
The host application configures SquatchMail like any other library:
config :squatch_mail,
repo: MyApp.Repo,
otp_app: :my_app,
prefix: "squatch_mail",
enabled: true,
capture: [
store_html: true,
store_text: true,
sample_rate: 1.0,
max_queue: 10_000,
max_concurrency: 50
],
guard: [
complaint_rate_pause: true,
complaint_rate_threshold: 0.001,
complaint_rate_window_days: 30,
min_volume: 100,
prune_interval_ms: :timer.hours(24)
]Options
:repo(required) - theEcto.RepoSquatchMail uses to read and write its own tables. This is expected to be the host application's existing repo; SquatchMail keeps its tables isolated in their own Postgres schema (see:prefix).:otp_app- the OTP application configuring SquatchMail. Used by future installer/asset tasks to locate the host app's directories.:prefix- the Postgres schema all SquatchMail tables live in. Defaults to"squatch_mail".:enabled- whether SquatchMail's capture/ingestion machinery is active. Defaults totrue. Useful for disabling SquatchMail in specific environments (e.g. test) without removing its configuration.:capture- options for the telemetry capture engine (SquatchMail.Capture), a keyword list::store_html- whether to persist the HTML body. Defaults totrue. Set tofalseto keep engagement/status data while dropping potentially sensitive HTML content.:store_text- whether to persist the plain-text body. Defaults totrue, same rationale as:store_html.:sample_rate- the fraction (0.0..1.0) of outgoing emails the capture engine persists. Defaults to1.0(capture every send). Lower this for very high-volume mailers where full capture would be too much write load;1.0and0.0are treated as exact (no random sampling overhead at the extremes).:max_queue- the maximum number of captured emails theSquatchMail.Capture.Recorderwill hold pending persistence before it starts dropping new captures (and emitting[:squatch_mail, :capture, :dropped]) rather than let the queue grow unbounded under a burst. Defaults to10_000.:max_concurrency- the maximum number of captures being persisted to the database at once. Distinct from:max_queue::max_queuebounds how many captures can be waiting, while:max_concurrencybounds how many of those waiting captures are simultaneously checking out a connection from the host'sRepopool, so a burst can't itself exhaust that pool. Defaults to50.
:guard- options forSquatchMail.Guard, a keyword list::complaint_rate_pause- whether the complaint-rate circuit breaker is active at all. Defaults totrue; set tofalseto disable it entirely (suppression checks still run).:complaint_rate_threshold- the fraction (0.0..1.0) of sent emails, over the trailing:complaint_rate_window_days, that have been complained about beforeSquatchMail.Guardauto-pauses sending. Defaults to0.001(0.1%), matching SES's own account-suspension threshold.:complaint_rate_window_days- the trailing window, in days, the complaint rate is computed over. Defaults to30.:min_volume- the minimum number of sent emails in the trailing window before the complaint-rate breaker can trip. Defaults to100, so e.g. 1 complaint out of 5 sends doesn't falsely read as a 20% complaint rate.:prune_interval_ms- retained for backwards compatibility; prefer:pruner's:intervalbelow.
:pruner- options forSquatchMail.Pruner, a keyword list::interval- how often, in milliseconds, the pruner callsSquatchMail.Tracker.prune/0. Defaults to 6 hours.:enabled- whether the pruner runs at all. Defaults totrue.
Summary
Functions
Returns a single capture option, falling back to its default when the host
hasn't configured :capture at all, or has configured it but omitted this
particular key.
Returns the minimum number of sent emails in the trailing window required before the complaint-rate breaker can trip.
Returns whether SquatchMail.Guard's complaint-rate circuit breaker is
active.
Returns the complaint-rate fraction (0.0..1.0) at or above which
SquatchMail.Guard blocks sending.
Returns the trailing window, in days, the complaint rate is computed over.
Returns whether SquatchMail is enabled.
Returns a single guard option, falling back to its default when the host
hasn't configured :guard at all, or has configured it but omitted this
particular key.
Returns the maximum number of captures SquatchMail.Capture.Recorder
will persist to the database concurrently.
Returns the maximum number of pending captures
SquatchMail.Capture.Recorder will queue before dropping new ones.
Returns the configured OTP application, if any.
Returns the Postgres schema SquatchMail's tables live in.
Returns how often, in milliseconds, SquatchMail.Guard.Pruner runs
SquatchMail.Tracker.prune/0.
Returns a single pruner option, falling back to its default when the host
hasn't configured :pruner at all, or has configured it but omitted this
particular key.
Returns whether SquatchMail.Pruner runs at all.
Returns how often, in milliseconds, SquatchMail.Pruner runs
SquatchMail.Tracker.prune/0.
Returns the configured sample rate for the telemetry capture engine.
Returns whether the HTML body should be persisted for captured emails.
Returns whether the plain-text body should be persisted for captured emails.
Functions
Returns a single capture option, falling back to its default when the host
hasn't configured :capture at all, or has configured it but omitted this
particular key.
@spec complaint_rate_min_volume() :: non_neg_integer()
Returns the minimum number of sent emails in the trailing window required before the complaint-rate breaker can trip.
Defaults to 100.
@spec complaint_rate_pause?() :: boolean()
Returns whether SquatchMail.Guard's complaint-rate circuit breaker is
active.
Defaults to true.
@spec complaint_rate_threshold() :: float()
Returns the complaint-rate fraction (0.0..1.0) at or above which
SquatchMail.Guard blocks sending.
Defaults to 0.001 (0.1%).
@spec complaint_rate_window_days() :: pos_integer()
Returns the trailing window, in days, the complaint rate is computed over.
Defaults to 30.
@spec enabled?() :: boolean()
Returns whether SquatchMail is enabled.
Defaults to true.
Returns a single guard option, falling back to its default when the host
hasn't configured :guard at all, or has configured it but omitted this
particular key.
@spec max_concurrency() :: pos_integer()
Returns the maximum number of captures SquatchMail.Capture.Recorder
will persist to the database concurrently.
Defaults to 50.
@spec max_queue() :: non_neg_integer()
Returns the maximum number of pending captures
SquatchMail.Capture.Recorder will queue before dropping new ones.
Defaults to 10_000.
@spec otp_app() :: atom() | nil
Returns the configured OTP application, if any.
@spec prefix() :: String.t()
Returns the Postgres schema SquatchMail's tables live in.
Defaults to "squatch_mail".
@spec prune_interval_ms() :: pos_integer()
Returns how often, in milliseconds, SquatchMail.Guard.Pruner runs
SquatchMail.Tracker.prune/0.
Defaults to 24 hours.
Returns a single pruner option, falling back to its default when the host
hasn't configured :pruner at all, or has configured it but omitted this
particular key.
@spec pruner_enabled?() :: boolean()
Returns whether SquatchMail.Pruner runs at all.
Defaults to true.
@spec pruner_interval_ms() :: pos_integer()
Returns how often, in milliseconds, SquatchMail.Pruner runs
SquatchMail.Tracker.prune/0.
Defaults to 6 hours.
@spec repo() :: Ecto.Repo.t()
Returns the configured Ecto.Repo.
Raises if :repo has not been configured.
@spec sample_rate() :: float()
Returns the configured sample rate for the telemetry capture engine.
Defaults to 1.0.
@spec store_html?() :: boolean()
Returns whether the HTML body should be persisted for captured emails.
Defaults to true.
@spec store_text?() :: boolean()
Returns whether the plain-text body should be persisted for captured emails.
Defaults to true.