Karta. Reports. Sending. Kind behaviour
(Karta v1.0.0)
What a kind of report knows: which domains it has something to report
about for a day, the reports to send about one, and where to send them.
Karta.Reports.Sending.Runner does the rest (limits, sending, records,
retries) and is the same for every kind.
A report is a map: :id (its identifier, also the base of its
Message-ID), :records (how many records it holds), :subject,
:text (the message's text), :filename, :content_type, :data (the
attachment, compressed) and :headers (further header fields). A
report that was split has several, numbered by their position.
Summary
Callbacks
The addresses to send the reports about domain to, or why there are
none ({:skip, reason}), or {:error, :dns} when the answer could not
be found out now. deadline is a monotonic time in milliseconds.
The domains (at most limit, the busiest first) with something to report for day.
The kind's name as stored in report_runs.kind.
The reports about domain for day, or :empty when there is nothing.
Types
@type context() :: %{ from: Karta.Mail.Address.t(), host: String.t(), now: DateTime.t() }
What the runner tells a kind about the reporter.
Callbacks
@callback destinations(String.t(), integer()) :: {:ok, [String.t()]} | {:skip, String.t()} | {:error, :dns}
The addresses to send the reports about domain to, or why there are
none ({:skip, reason}), or {:error, :dns} when the answer could not
be found out now. deadline is a monotonic time in milliseconds.
@callback domains(Date.t(), pos_integer()) :: [String.t()]
The domains (at most limit, the busiest first) with something to report for day.
@callback name() :: String.t()
The kind's name as stored in report_runs.kind.
The reports about domain for day, or :empty when there is nothing.