Skip to main content

SuotarBatchPhase

Trait SuotarBatchPhase 

Source
pub(crate) trait SuotarBatchPhase {
    type Row;
    type Item: Serialize;
    type Result;

    const ALL_TRANSIENT_ERROR: &'static str;

    // Required methods
    async fn prepare(
        &mut self,
        ctx: &PhaseContext<'_>,
        conn: &mut PgConnection,
        scope: &PhaseScope,
    ) -> Result<Prepared<Self::Row, Self::Item>>;
    fn registration(row: &Self::Row) -> &CreditRegistration;
    fn request_item_id(row: &Self::Row) -> String;
    async fn send(
        &self,
        ctx: &PhaseContext<'_>,
        rows: &[Self::Row],
        items: Vec<Self::Item>,
    ) -> Result<SuotarBatchResponse<Self::Result>, UtilError>;
    async fn apply(
        &self,
        conn: &mut PgConnection,
        row: &Self::Row,
        item: Option<&SuotarResponseItem<Self::Result>>,
        event: OutcomeEvent<'_>,
    ) -> Result<bool>;
    async fn apply_request_rejection(
        &self,
        conn: &mut PgConnection,
        row: &Self::Row,
        request: &Value,
        error: &UtilError,
    ) -> Result<bool>;

    // Provided method
    fn sent_student_number(_row: &Self::Row) -> Option<&str> { ... }
}
Expand description

A phase whose iteration is “claim rows, decide in one transaction what may be asked, send one batch, write one answer per row”. import, resolve-enrolments, and each of verify’s two flows; run_suotar_batch_phase is the loop they share, and the only place the transaction shape, the moved-on skipping and the counters are written down.

Required Associated Constants§

Source

const ALL_TRANSIENT_ERROR: &'static str

The iteration’s error when every item came back transiently unavailable.

Required Associated Types§

Source

type Row

A row to send for, with whatever its preflight read alongside it.

Source

type Item: Serialize

The request item, which is also what the audit log records as sent.

Source

type Result

The endpoint’s per-item result body.

Required Methods§

Source

async fn prepare( &mut self, ctx: &PhaseContext<'_>, conn: &mut PgConnection, scope: &PhaseScope, ) -> Result<Prepared<Self::Row, Self::Item>>

Claims rows and decides what may be asked about them. Whatever has to be true before the request leaves is written here, in the caller’s transaction.

Source

fn registration(row: &Self::Row) -> &CreditRegistration

Source

fn request_item_id(row: &Self::Row) -> String

What the row was addressed as, and so how its answer is found again.

Source

async fn send( &self, ctx: &PhaseContext<'_>, rows: &[Self::Row], items: Vec<Self::Item>, ) -> Result<SuotarBatchResponse<Self::Result>, UtilError>

Source

async fn apply( &self, conn: &mut PgConnection, row: &Self::Row, item: Option<&SuotarResponseItem<Self::Result>>, event: OutcomeEvent<'_>, ) -> Result<bool>

Applies one answer, or the absence of one, to its row. Returns whether the row ended up in a failure state; errors with PreconditionFailed if another writer moved the row meanwhile.

Source

async fn apply_request_rejection( &self, conn: &mut PgConnection, row: &Self::Row, request: &Value, error: &UtilError, ) -> Result<bool>

What one row gets when the study registry rejected the whole request.

Provided Methods§

Source

fn sent_student_number(_row: &Self::Row) -> Option<&str>

The student number this row’s request carried, where it carried one: a number the registry rejects may only cost the link it was sent under.

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§