pub struct MultiResourceWriter<O, Opener: MultiResourceWriterOpener<O>, P> { /* private fields */ }Expand description
Writes a logical output partitioned across an ordered set of physical resources.
§Contract
- Input/output:
O, same as every delegate the opener produces. - State/checkpoint:
ResourceSetRevisionplus the current output resource’s ordinal and embedded delegate position, through the pairedMultiResourceWriterStream, following the same nested-envelope scheme asMultiResourceReader. - Ordering: resources are filled in
ResourceSet’s declared order; onewritebatch never spans two resources. - Restartability: supplied explicitly at construction, same as
multi_resource_reader. - Thread safety:
Send + Sync; one async-aware lock guards the active-or-poisoned state, the rollover decision, and the write together as one atomic critical section (this crate’s chunk runtime never actually callswriteconcurrently on one writer instance; the lock exists so this type’s own invariants hold regardless). The active resource and the poison flag deliberately share this single lock rather than living behind two separate ones: two locks would let a concurrentwriteread “not yet poisoned” before a poisoning transition commits and then roll over into a resource this writer is supposed to have permanently stopped using. - Transaction/delivery: never claims a stronger mode than the current delegate writer supports; a rollover happens between writer calls, never inside one enlisted call.
- Failure semantics: a failure while writing to resource N does not roll over to resource N+1 – the same delegate is retried at the same resource on the framework’s own retry contract, exactly like an undecorated writer.
- Close: rollover closes the outgoing resource’s delegate stream
(with
crate::StreamRuntimeOutcome::ResourceBoundary, neverCommitted– the enclosing step attempt has not reached a terminal outcome yet) before opening the next one, never leaving two resources’ delegates open at once; the pairedMultiResourceWriterStream::closecloses whichever resource is still active at the step attempt’s own terminal outcome, and never re-closes a resource already closed by a rollover. - Support tier: first-party.
Trait Implementations§
Source§impl<O, Opener, P> ItemWriter<O> for MultiResourceWriter<O, Opener, P>where
O: Sync + 'static,
Opener: MultiResourceWriterOpener<O> + 'static,
P: RolloverPolicy + 'static,
impl<O, Opener, P> ItemWriter<O> for MultiResourceWriter<O, Opener, P>where
O: Sync + 'static,
Opener: MultiResourceWriterOpener<O> + 'static,
P: RolloverPolicy + 'static,
Source§async fn write<'a>(
&'a self,
items: &'a [O],
context: WriteContext<'a>,
) -> Result<WriteOutcome, WriterError>
async fn write<'a>( &'a self, items: &'a [O], context: WriteContext<'a>, ) -> Result<WriteOutcome, WriterError>
Writes one borrowed, nonempty batch. Read more
Auto Trait Implementations§
impl<O, Opener, P> !RefUnwindSafe for MultiResourceWriter<O, Opener, P>
impl<O, Opener, P> !UnwindSafe for MultiResourceWriter<O, Opener, P>
impl<O, Opener, P> Freeze for MultiResourceWriter<O, Opener, P>
impl<O, Opener, P> Send for MultiResourceWriter<O, Opener, P>
impl<O, Opener, P> Sync for MultiResourceWriter<O, Opener, P>
impl<O, Opener, P> Unpin for MultiResourceWriter<O, Opener, P>
impl<O, Opener, P> UnsafeUnpin for MultiResourceWriter<O, Opener, P>where
Arc<WriterShared<O, Opener, P>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more