Skip to main content

RegistryBatchFlow

Trait RegistryBatchFlow 

Source
pub(super) trait RegistryBatchFlow {
    type Extra;
    type Request: BatchRequest;

    const ALL_UNAVAILABLE_ERROR: &'static str;
    const REFUSAL: RefusalPolicy<Self::Extra>;

    // Required methods
    async fn claim(
        ctx: &BatchFlowContext<'_>,
        conn: &mut PgConnection,
        limit: usize,
    ) -> CreditRegistrationResult<Prepared<Self::Extra, Self::Request>>;
    async fn apply_answer(
        conn: &mut PgConnection,
        row: &Claimed<Self::Extra>,
        answer: Option<&<Self::Request as BatchRequest>::Answer>,
        audit: &ExchangeAudit,
    ) -> CreditRegistrationResult<Applied>;

    // Provided methods
    async fn keep_in_flight(
        _conn: &mut PgConnection,
        _rows: &[&Claimed<Self::Extra>],
    ) -> CreditRegistrationResult<()> { ... }
    async fn release_unsent(
        _conn: &mut PgConnection,
        _rows: &[&Claimed<Self::Extra>],
    ) -> CreditRegistrationResult<()> { ... }
}
Expand description

A flow 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_registry_batch_flow is the loop they share. Implementations hold no state.

Required Associated Constants§

Source

const ALL_UNAVAILABLE_ERROR: &'static str

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

Source

const REFUSAL: RefusalPolicy<Self::Extra>

What the rows get when the study registry refused the whole request, which also decides whether a batch refused as malformed is split.

Required Associated Types§

Source

type Extra

What the claim read for each row alongside it, which its answer is applied with.

Source

type Request: BatchRequest

What each row asks, which also names the operation it is asked under.

Required Methods§

Source

async fn claim( ctx: &BatchFlowContext<'_>, conn: &mut PgConnection, limit: usize, ) -> CreditRegistrationResult<Prepared<Self::Extra, Self::Request>>

Claims at most limit 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

async fn apply_answer( conn: &mut PgConnection, row: &Claimed<Self::Extra>, answer: Option<&<Self::Request as BatchRequest>::Answer>, audit: &ExchangeAudit, ) -> CreditRegistrationResult<Applied>

Decides what one answer, or the absence of one, does to its row and writes it, with the exchange behind it. May read and write in transactions of its own on the way.

Provided Methods§

Source

async fn keep_in_flight( _conn: &mut PgConnection, _rows: &[&Claimed<Self::Extra>], ) -> CreditRegistrationResult<()>

Called before each send after a split, with every row the split still holds, so the ones waiting their turn are not taken for a worker that died mid-call.

Source

async fn release_unsent( _conn: &mut PgConnection, _rows: &[&Claimed<Self::Extra>], ) -> CreditRegistrationResult<()>

Called with every row a split still holds unsent when a shutdown or an error stops the iteration, each of which would otherwise be condemned as a lost submission.

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§

Source§

impl RegistryBatchFlow for Import

Source§

const ALL_UNAVAILABLE_ERROR: &'static str = "Every item of the batch timed out in Sisu or came back unavailable."

Source§

const REFUSAL: RefusalPolicy<()> = RefusalPolicy::RequestLevel

Source§

type Extra = ()

Source§

type Request = AttainmentSubmission

Source§

impl RegistryBatchFlow for ResolveEnrolments

Source§

const ALL_UNAVAILABLE_ERROR: &'static str = "Every item of the batch came back unavailable."

Source§

const REFUSAL: RefusalPolicy<LookupBasis> = RefusalPolicy::RequestLevel

Source§

type Extra = LookupBasis

Source§

type Request = EnrolmentLookup

Source§

impl RegistryBatchFlow for ResolvePersonIds

Source§

const ALL_UNAVAILABLE_ERROR: &'static str = "Every person lookup came back unavailable."

Source§

const REFUSAL: RefusalPolicy<LinkMissingPerson> = RefusalPolicy::RequestLevel

Source§

type Extra = LinkMissingPerson

Source§

type Request = PersonLookup

Source§

impl RegistryBatchFlow for VerifyPoll

Source§

impl RegistryBatchFlow for UncertainRecovery

Source§

const ALL_UNAVAILABLE_ERROR: &'static str = "Every recovery lookup came back unavailable."

Source§

const REFUSAL: RefusalPolicy<VerifyAttempt>

Source§

type Extra = VerifyAttempt

Source§

type Request = EnrolmentLookup