Skip to main content

ListenerContext

Struct ListenerContext 

Source
pub struct ListenerContext {
    pub replaying: bool,
    pub store: Option<Store>,
    pub request: RequestContext,
    /* private fields */
}
Expand description

What a listener handler gets besides the event’s payload and meta (the ctx of Listener::on).

Fields§

§replaying: bool

The event was committed before this connection began: a read model rebuilding from the start, and equally the backlog a reactor catches up on after a restart or a lost connection. A reactor must not skip side effects because of it (those events are new to it); submit with fixed command IDs instead, so they are safe to repeat. Use it to skip work that only matters live, e.g. a notification about something long past in a listener that starts at 0.

§store: Option<Store>

The listener’s store, if it has one (Listener::store).

§request: RequestContext

The request context of the command that caused the event.

Implementations§

Source§

impl ListenerContext

Source

pub fn follow(&self) -> RequestContext

A request context for commands caused by this event: same sender and correlation, this event’s command as the cause, without an expected version or privileges. Pass it with crate::Submit::context; ListenerContext::submit does.

Source

pub async fn submit(&self, submit: Submit) -> Result<Vec<StoredEvent>, Error>

Submits a command this event causes, on the listener’s connection, and returns its events. It needs a fixed ID (Submit::id, e.g. confirm-<order>), so a redelivered event runs it once; without one it is Error::Config. Unless the submit sets them, the context is ListenerContext::follow and the tenant the event’s.

A rejection is Error::Rejected: returned from the handler (?), it parks the event at once in a reactor (see Listener::park_after). Match it to accept one: match ctx.submit(s).await { Err(Error::Rejected(r)) if r.code == "unique_taken" => {} r => { r?; } }. Other errors as for Kernable::submit.

Source

pub async fn query<T: DeserializeOwned>(&self, query: Query) -> Result<T, Error>

Asks a query on the listener’s connection, like Kernable::query; unless the query sets it, for the event’s tenant. It is the listener’s own read: it keeps the connection’s context, not the event’s sender.

Source

pub async fn process_act( &self, name: &str, context: RequestContext, ) -> Result<bool, Error>

Sets as whom a business process acts, on the listener’s connection, like Kernable::process_act: e.g. a reactor that gives each registered process an identity.

Trait Implementations§

Source§

impl Clone for ListenerContext

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl !Freeze for ListenerContext

§

impl !RefUnwindSafe for ListenerContext

§

impl !UnwindSafe for ListenerContext

§

impl Forget for ListenerContext

§

impl Move for ListenerContext

§

impl Send for ListenerContext
where Arc<Mutex<Option<Connection>>>: Send, Arc<Atomic<u64>>: Send, Arc<Mutex<()>>: Send, RawVecInner: Send, NodeRef<Owned, String, String, LeafOrInternal>: Send, BoxRaw<(String, String)>: Send, Arc<Channels>: Send, Arc<Partitions>: Send, Arc<SigningKey>: Send, Bytes: Send, Arc<str>: Send, Arc<RwLock<HashMap<String, Domain>>>: Send,

§

impl Sync for ListenerContext
where Arc<Mutex<Option<Connection>>>: Sync, Arc<Atomic<u64>>: Sync, Arc<Mutex<()>>: Sync, RawVecInner: Sync, NodeRef<Owned, String, String, LeafOrInternal>: Sync, BoxRaw<(String, String)>: Sync, Arc<Channels>: Sync, Arc<Partitions>: Sync, Arc<SigningKey>: Sync, Bytes: Sync, Arc<str>: Sync, Arc<RwLock<HashMap<String, Domain>>>: Sync,

§

impl Unpin for ListenerContext
where Arc<Mutex<Option<Connection>>>: Unpin, Arc<Atomic<u64>>: Unpin, Arc<Mutex<()>>: Unpin, *const u8 is !null: Unpin, *const LeafNode<String, String> is !null: Unpin, Box<(String, String)>: Unpin, Arc<Channels>: Unpin, Arc<Partitions>: Unpin, Arc<SigningKey>: Unpin, *const u8: Unpin, Align8<*mut ()>: Unpin, &'static Vtable: Unpin, Arc<str>: Unpin, Arc<RwLock<HashMap<String, Domain>>>: Unpin,

§

impl UnsafeUnpin for ListenerContext
where *const ArcInner<Mutex<Option<Connection>>> is !null: UnsafeUnpin, PhantomData<ArcInner<Mutex<Option<Connection>>>>: UnsafeUnpin, *const ArcInner<Atomic<u64>> is !null: UnsafeUnpin, PhantomData<ArcInner<Atomic<u64>>>: UnsafeUnpin, *const ArcInner<Mutex<()>> is !null: UnsafeUnpin, PhantomData<ArcInner<Mutex<()>>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const LeafNode<String, String> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(String, String)>>: UnsafeUnpin, *const ArcInner<Channels> is !null: UnsafeUnpin, PhantomData<ArcInner<Channels>>: UnsafeUnpin, *const ArcInner<Partitions> is !null: UnsafeUnpin, PhantomData<ArcInner<Partitions>>: UnsafeUnpin, *const ArcInner<SigningKey> is !null: UnsafeUnpin, PhantomData<ArcInner<SigningKey>>: UnsafeUnpin, *const u8: UnsafeUnpin, Align8<*mut ()>: UnsafeUnpin, &'static Vtable: UnsafeUnpin, PhantomData<Ascii>: UnsafeUnpin, *const ArcInner<str> is !null: UnsafeUnpin, PhantomData<ArcInner<str>>: UnsafeUnpin, *const ArcInner<RwLock<HashMap<String, Domain>>> is !null: UnsafeUnpin, PhantomData<ArcInner<RwLock<HashMap<String, Domain>>>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more