pub struct Client { /* private fields */ }Expand description
Implementations§
Source§impl Client
impl Client
Sourcepub async fn connect(addr: impl Into<Address>) -> Result<Client>
pub async fn connect(addr: impl Into<Address>) -> Result<Client>
Connects with default settings. See Client::builder for knobs.
Sourcepub fn builder(addr: impl Into<Address>) -> ClientBuilder
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 Executor for Client
impl Executor for Client
Source§fn default_routing_key(&self) -> Option<&str>
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>>
fn write_watch(&self) -> Option<Receiver<u64>>
Returns a receiver notified after each successful in-process
write,
for low-latency subscription wakeup. Read moreSource§fn write_watch_for(&self, interest: &WriteInterest) -> Option<Receiver<u64>>
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 moreSource§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,
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 moreSource§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,
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,
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,
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,
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 moreSource§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,
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,
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,
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,
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,
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,
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,
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 moreSource§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,
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,
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,
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,
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 moreSource§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,
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 moreSource§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,
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,
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,
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 moreAuto 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 Ewhere
E: Executor,
impl<E> AggregateExt<E> for Ewhere
E: Executor,
Source§fn has_event<A>(&self, id: impl Into<String>) -> HasEvent<'_, E, A>where
A: AggregateEvent,
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,
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> 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> 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<New, Old> UpcastFrom<Old> for Newwhere
New: From<Old>,
impl<New, Old> UpcastFrom<Old> for Newwhere
New: From<Old>,
Source§fn upcast_from(old: Old) -> New
fn upcast_from(old: Old) -> New
Converts the older event into this one.