PhoenixKit.Modules.Emails.BrevoPollingManager (phoenix_kit_emails v0.1.14)

Copy Markdown View Source

Manager module for Brevo event polling via Oban jobs.

Mirrors SQSPollingManager — see that module's @moduledoc for the general architecture (Oban jobs instead of a GenServer, so settings changes take effect without a restart). enable_polling/0 and disable_polling/0 back the admin UI toggle; poll_now/0 forces an immediate cycle regardless of the sender-aware gate (useful to verify a freshly-configured Brevo profile before waiting for the next scheduled tick — the job itself still no-ops safely if the gate isn't satisfied).

Summary

Functions

Disables Brevo event polling by updating the configuration and cancelling scheduled jobs.

Enables Brevo event polling by setting the configuration and starting the first job.

Triggers an immediate polling job, regardless of the normal schedule or the brevo_events_enabled toggle — a forced: true job (see BrevoPollingJob.perform/1) still fetches once even while polling is disabled, rather than silently no-op'ing while claiming success. Still respects Emails.enabled?/0 (system disabled) and the sender-aware profile gate: a forced poll with zero active Brevo profiles correctly fetches nothing, same as a scheduled cycle would.

Sets the polling interval in milliseconds (minimum 30 000ms).

Returns the current status of Brevo event polling.

Functions

disable_polling()

Disables Brevo event polling by updating the configuration and cancelling scheduled jobs.

enable_polling()

Enables Brevo event polling by setting the configuration and starting the first job.

poll_now()

Triggers an immediate polling job, regardless of the normal schedule or the brevo_events_enabled toggle — a forced: true job (see BrevoPollingJob.perform/1) still fetches once even while polling is disabled, rather than silently no-op'ing while claiming success. Still respects Emails.enabled?/0 (system disabled) and the sender-aware profile gate: a forced poll with zero active Brevo profiles correctly fetches nothing, same as a scheduled cycle would.

set_polling_interval(interval_ms)

Sets the polling interval in milliseconds (minimum 30 000ms).

status()

Returns the current status of Brevo event polling.

active_brevo_profiles is the sender-aware gate's own count (see BrevoPollingJob's moduledoc): the number of enabled send profiles pointed at a "brevo_api" integration. When it's 0, the polling chain is alive (as long as enabled is true) but every cycle no-ops.

total_brevo_accounts/polling_brevo_accounts are the distinct integration view the per-account opt-out list needs — several profiles can share one integration, so this can differ from active_brevo_profiles. polling_brevo_accounts excludes whatever's in Emails.get_brevo_polling_excluded_integrations/0; when it's 0 while total_brevo_accounts is not, every active account has been explicitly excluded.