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§
Sourceconst ALL_TRANSIENT_ERROR: &'static str
const ALL_TRANSIENT_ERROR: &'static str
The iteration’s error when every item came back transiently unavailable.
Required Associated Types§
Required Methods§
Sourceasync fn prepare(
&mut self,
ctx: &PhaseContext<'_>,
conn: &mut PgConnection,
scope: &PhaseScope,
) -> Result<Prepared<Self::Row, Self::Item>>
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.
fn registration(row: &Self::Row) -> &CreditRegistration
Sourcefn request_item_id(row: &Self::Row) -> String
fn request_item_id(row: &Self::Row) -> String
What the row was addressed as, and so how its answer is found again.
async fn send( &self, ctx: &PhaseContext<'_>, rows: &[Self::Row], items: Vec<Self::Item>, ) -> Result<SuotarBatchResponse<Self::Result>, UtilError>
Sourceasync fn apply(
&self,
conn: &mut PgConnection,
row: &Self::Row,
item: Option<&SuotarResponseItem<Self::Result>>,
event: OutcomeEvent<'_>,
) -> Result<bool>
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.
Sourceasync fn apply_request_rejection(
&self,
conn: &mut PgConnection,
row: &Self::Row,
request: &Value,
error: &UtilError,
) -> Result<bool>
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§
Sourcefn sent_student_number(_row: &Self::Row) -> Option<&str>
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.