pub struct Channel<T> { /* private fields */ }Expand description
Defines one durable FIFO queue of typed messages.
Add the Channel to crate::PersistenceSchema. Clients and handlers may publish messages;
Steps create Condition values that wait for queue-size bounds and read the messages consumed
by the satisfied condition.
§Examples
use dex_sdk::{Channel, Wait};
let approvals = Channel::<String>::new("approvals");
let wait = Wait::until(approvals.for_one());Implementations§
Source§impl<T> Channel<T>
impl<T> Channel<T>
Sourcepub fn publish(&self, context: &mut Context, value: T) -> HandlerResult<()>where
T: Value,
pub fn publish(&self, context: &mut Context, value: T) -> HandlerResult<()>where
T: Value,
Stages one message from the current Step or RPC invocation.
§Errors
Returns a crate::HandlerError when value cannot be encoded.
Sourcepub fn size(&self, context: &Context) -> HandlerResult<usize>
pub fn size(&self, context: &Context) -> HandlerResult<usize>
Returns the invocation snapshot’s queued-message count.
Sourcepub fn condition_results(&self, context: &Context) -> HandlerResult<Vec<T>>where
T: Value,
pub fn condition_results(&self, context: &Context) -> HandlerResult<Vec<T>>where
T: Value,
Decodes messages consumed by this Channel’s satisfied condition.
§Errors
Returns a crate::HandlerError when a message cannot be decoded.
Sourcepub fn for_one(&self) -> Condition
pub fn for_one(&self) -> Condition
Creates a condition that consumes exactly one queued message.
Sourcepub fn for_n(&self, count: usize) -> Condition
pub fn for_n(&self, count: usize) -> Condition
Creates a condition that consumes exactly count queued messages.
Sourcepub fn at_least(&self, count: usize) -> Condition
pub fn at_least(&self, count: usize) -> Condition
Creates a condition satisfied when at least count messages are queued.
Sourcepub fn at_most(&self, count: usize) -> Condition
pub fn at_most(&self, count: usize) -> Condition
Creates a condition satisfied when no more than count messages are queued.
Sourcepub fn range(
&self,
at_least: Option<usize>,
at_most: Option<usize>,
) -> Condition
pub fn range( &self, at_least: Option<usize>, at_most: Option<usize>, ) -> Condition
Creates a condition with optional inclusive lower and upper queue-size bounds.
Sourcepub fn when_empty(&self) -> ChannelGuard
pub fn when_empty(&self) -> ChannelGuard
Creates a guard used by conditional Flow completion to require an empty queue.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Channel<T>
impl<T> RefUnwindSafe for Channel<T>
impl<T> Send for Channel<T>
impl<T> Sync for Channel<T>
impl<T> Unpin for Channel<T>
impl<T> UnsafeUnpin for Channel<T>
impl<T> UnwindSafe for Channel<T>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request