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§
Sourceconst ALL_UNAVAILABLE_ERROR: &'static str
const ALL_UNAVAILABLE_ERROR: &'static str
The iteration’s error when every item came back unavailable.
Sourceconst REFUSAL: RefusalPolicy<Self::Extra>
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§
Sourcetype Request: BatchRequest
type Request: BatchRequest
What each row asks, which also names the operation it is asked under.
Required Methods§
Sourceasync fn claim(
ctx: &BatchFlowContext<'_>,
conn: &mut PgConnection,
limit: usize,
) -> CreditRegistrationResult<Prepared<Self::Extra, Self::Request>>
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.
Sourceasync fn apply_answer(
conn: &mut PgConnection,
row: &Claimed<Self::Extra>,
answer: Option<&<Self::Request as BatchRequest>::Answer>,
audit: &ExchangeAudit,
) -> CreditRegistrationResult<Applied>
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§
Sourceasync fn keep_in_flight(
_conn: &mut PgConnection,
_rows: &[&Claimed<Self::Extra>],
) -> CreditRegistrationResult<()>
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.
Sourceasync fn release_unsent(
_conn: &mut PgConnection,
_rows: &[&Claimed<Self::Extra>],
) -> CreditRegistrationResult<()>
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.