34 lines
1.2 KiB
Elixir
34 lines
1.2 KiB
Elixir
defmodule Symbiont.Telepathy.Supervisor do
|
|
@moduledoc """
|
|
Supervision subtree for Telepathy (email communication layer).
|
|
|
|
Children (start order matters — rest_for_one strategy):
|
|
- MessageStore — JSONL-backed message persistence (must start first)
|
|
- JMAP — Fastmail JMAP client with periodic inbox polling
|
|
- SMTP — gen_smtp listener on port 25 (inbound email receiver)
|
|
|
|
The `rest_for_one` strategy ensures that if MessageStore crashes, JMAP and
|
|
SMTP are also restarted (they depend on MessageStore being available).
|
|
"""
|
|
use Supervisor
|
|
|
|
def start_link(opts) do
|
|
Supervisor.start_link(__MODULE__, opts, name: __MODULE__)
|
|
end
|
|
|
|
@impl true
|
|
def init(opts) do
|
|
messages_path = Keyword.get(opts, :messages_path, "/data/telepathy/messages.jsonl")
|
|
poll_interval_ms = Keyword.get(opts, :poll_interval_ms, 60_000)
|
|
smtp_port = Keyword.get(opts, :smtp_port, 25)
|
|
|
|
children = [
|
|
{Symbiont.Telepathy.MessageStore, path: messages_path},
|
|
{Symbiont.Telepathy.JMAP, poll_interval_ms: poll_interval_ms},
|
|
{Symbiont.Telepathy.SMTP, smtp_port: smtp_port}
|
|
]
|
|
|
|
Supervisor.init(children, strategy: :rest_for_one)
|
|
end
|
|
end
|