Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

A remote Executor: forwards every call to a served executor over TCP. Cheap to clone; all clones share the connection pool.

Implementations§

Source§

impl Client

Source

pub async fn connect(addr: impl Into<Address>) -> Result<Client>

Connects with default settings. See Client::builder for knobs.

Source

pub fn builder(addr: impl Into<Address>) -> ClientBuilder

Starts building a client for addr (token, TLS, request timeout, connection count, reconnect backoff). A host name in addr is looked up on every connection attempt, not once here.

Trait Implementations§

Source§

impl Clone for Client

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
Source§

impl Executor for Client

Source§

fn default_routing_key(&self) -> Option<&str>

Default routing key applied to new aggregates and inherited by subscriptions. Read more
Source§

fn write_watch(&self) -> Option<Receiver<u64>>

Returns a receiver notified after each successful in-process write, for low-latency subscription wakeup. Read more
Source§

fn write_watch_for(&self, interest: &WriteInterest) -> Option<Receiver<u64>>

Like write_watch, for a watcher that reads with a filter: the receiver is notified only by the writes that hold an event interest matches. Read more
Source§

fn stable_timestamp<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<u64>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

An exclusive upper bound, in microseconds since the Unix epoch, on the event timestamps a subscription may safely process — or None for no bound (the default). Read more
Source§

fn write<'life0, 'async_trait>( &'life0 self, events: Vec<Event>, ) -> Pin<Box<dyn Future<Output = Result<(), WriteError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Persists events atomically. Read more
Source§

fn replicate<'life0, 'async_trait>( &'life0 self, events: Vec<Event>, ) -> Pin<Box<dyn Future<Output = Result<(), WriteError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Persists pre-stamped events verbatim, without re-stamping timestamps. Read more
Source§

fn read<'life0, 'async_trait>( &'life0 self, aggregators: Option<Arc<[EventFilter]>>, routing_key: Option<RoutingKey>, tenant: TenantFilter, args: Args, to_micros: Option<u64>, ) -> Pin<Box<dyn Future<Output = Result<ReadResult<Event>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Queries events with filtering and pagination. Read more
Source§

fn latest_timestamp<'life0, 'async_trait>( &'life0 self, aggregators: Option<Arc<[EventFilter]>>, routing_key: Option<RoutingKey>, tenant: TenantFilter, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the timestamp of the most recent event matching the filter, in whole seconds since the Unix epoch (unlike stable_timestamp, which is microseconds). Read more
Source§

fn get_subscriber_cursor<'life0, 'async_trait>( &'life0 self, key: String, ) -> Pin<Box<dyn Future<Output = Result<Option<Value>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Gets the current cursor position for a subscription.
Source§

fn is_subscriber_running<'life0, 'async_trait>( &'life0 self, key: String, worker_id: Ulid, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Checks if a subscription is running with the given worker ID.
Source§

fn subscriber_status<'life0, 'async_trait>( &'life0 self, key: String, worker_id: Ulid, ) -> Pin<Box<dyn Future<Output = Result<SubscriberStatus>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetches subscriber fencing state and cursor together. Read more
Source§

fn latest_version<'life0, 'async_trait>( &'life0 self, tenant: String, aggregate_type: String, aggregate_id: String, ) -> Pin<Box<dyn Future<Output = Result<u16>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the highest committed version of an aggregate stream, or 0 when the stream does not exist. Read more
Source§

fn stream_routing_key<'life0, 'async_trait>( &'life0 self, tenant: String, aggregate_type: String, aggregate_id: String, ) -> Pin<Box<dyn Future<Output = Result<Option<Option<String>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the routing key of an existing aggregate stream. Read more
Source§

fn upsert_subscriber<'life0, 'async_trait>( &'life0 self, key: String, worker_id: Ulid, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Creates or updates a subscription record.
Source§

fn acknowledge<'life0, 'async_trait>( &'life0 self, key: String, worker_id: Ulid, cursor: Value, lag: u64, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Updates the subscription cursor after processing an event, fenced by worker_id. Read more
Source§

fn get_snapshot<'life0, 'async_trait>( &'life0 self, tenant: String, aggregate_type: String, projection: String, aggregate_revision: String, id: String, ) -> Pin<Box<dyn Future<Output = Result<Option<(Vec<u8>, Value)>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieves the snapshot a projection stored for an aggregate. Read more
Source§

fn save_snapshot<'life0, 'async_trait>( &'life0 self, tenant: String, aggregate_type: String, projection: String, aggregate_revision: String, id: String, data: Vec<u8>, cursor: Value, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Stores a projection’s snapshot for an aggregate. Read more
Source§

fn delete_snapshot<'life0, 'async_trait>( &'life0 self, tenant: String, aggregate_type: String, projection: String, id: String, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Deletes a projection’s stored snapshot for an aggregate. Read more
Source§

fn delete_stream<'life0, 'async_trait>( &'life0 self, tenant: String, aggregate_type: String, aggregate_id: String, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Removes one stream — the events of (tenant, aggregate_type, aggregate_id) and every index entry that leads to them — so the stream can be written again from its first version. Read more
Source§

fn save_dead_letter<'life0, 'async_trait>( &'life0 self, letter: DeadLetter, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Records an event a subscription gave up on, replacing the row the same (subscription, event_id) already has: an event given up on again — a crash before its acknowledge, a failed redelivery recorded by the host — keeps one row. Read more
Source§

fn dead_letters<'life0, 'async_trait>( &'life0 self, key: String, limit: u16, ) -> Pin<Box<dyn Future<Output = Result<Vec<DeadLetter>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

The dead letters of subscription key (its storage key), limit at most, in the order of their event ids: ULIDs, so the oldest event first.
Source§

fn dead_letter_count<'life0, 'async_trait>( &'life0 self, key: String, ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

How many dead letters subscription key holds.
Source§

fn delete_dead_letter<'life0, 'async_trait>( &'life0 self, key: String, event_id: Ulid, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Removes the dead letter of (key, event_id): the event was redelivered, or an operator dismissed it. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Client

§

impl !UnwindSafe for Client

§

impl Forget for Client

§

impl Freeze for Client

§

impl Move for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl UnsafeUnpin for Client

Blanket Implementations§

Source§

impl<E> AggregateExt<E> for E
where E: Executor,

Source§

fn has_event<A>(&self, id: impl Into<String>) -> HasEvent<'_, E, A>
where A: AggregateEvent,

Returns true if the aggregate id has at least one event of type A — or of an older event that upcasts into it.
Source§

fn original_version<A>( &self, id: impl Into<String>, ) -> OriginalVersion<'_, E, A>
where A: AggregateEvent,

Returns the current version of the aggregate id’s stream (the version of its most recent event), or None when the stream is empty. Useful as input to WriteBuilder::original_version for optimistic concurrency; ask in the tenant the write will name, since the same id in two tenants is two streams.
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> 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> 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<New, Old> UpcastFrom<Old> for New
where New: From<Old>,

Source§

fn upcast_from(old: Old) -> New

Converts the older event into this one.
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