Skip to main content

MailQueuePhase

Trait MailQueuePhase 

Source
pub(crate) trait MailQueuePhase {
    type Item;
    type Cache: Default;

    // Required methods
    async fn claim(
        conn: &mut PgConnection,
        scope: &PhaseScope,
    ) -> Result<Vec<Self::Item>>;
    fn template_type(item: &Self::Item) -> EmailTemplateType;
    fn language(item: &Self::Item) -> String;
    async fn queue(
        ctx: &PhaseContext<'_>,
        conn: &mut PgConnection,
        item: &Self::Item,
        template_id: Uuid,
        cache: &mut Self::Cache,
    ) -> Result<()>;
    fn missing_template_label(
        template_type: EmailTemplateType,
        language: &str,
    ) -> String;
    fn missing_templates_error_prefix() -> &'static str;
}
Expand description

A phase whose whole body is “claim rows, look up each one’s template, skip it if the template is missing, otherwise queue a mail”. link-emails and student-notifications are its only two shapes; run_mail_queue_phase is the loop they share.

Required Associated Types§

Source

type Item

Source

type Cache: Default

Per-run state queue may want across items, the way TemplateCache is kept across items already. () for a phase that needs none.

Required Methods§

Source

async fn claim( conn: &mut PgConnection, scope: &PhaseScope, ) -> Result<Vec<Self::Item>>

Source

fn template_type(item: &Self::Item) -> EmailTemplateType

Source

fn language(item: &Self::Item) -> String

Source

async fn queue( ctx: &PhaseContext<'_>, conn: &mut PgConnection, item: &Self::Item, template_id: Uuid, cache: &mut Self::Cache, ) -> Result<()>

Inserts the delivery and records it on the claimed item, given the template the caller already resolved.

Source

fn missing_template_label( template_type: EmailTemplateType, language: &str, ) -> String

One entry of the missing-templates report, e.g. the language alone or a type-and-language pair, depending on whether the phase has more than one template type.

Source

fn missing_templates_error_prefix() -> &'static str

The fixed lead-in of the missing-templates error message.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§