Struct eventstore::Client
source · [−]pub struct Client { /* private fields */ }
Expand description
Represents a client to a single node. Client
maintains a full duplex
communication to EventStoreDB.
Many threads can use an EventStoreDB client at the same time or a single thread can make many asynchronous requests.
Implementations
sourceimpl Client
impl Client
sourcepub fn new(settings: ClientSettings) -> Result<Self>
pub fn new(settings: ClientSettings) -> Result<Self>
Creates a gRPC client to an EventStoreDB database.
sourcepub fn with_runtime_handle(
handle: Handle,
settings: ClientSettings
) -> Result<Self>
pub fn with_runtime_handle(
handle: Handle,
settings: ClientSettings
) -> Result<Self>
Creates a gRPC client to an EventStoreDB database using an existing tokio runtime.
sourcepub async fn append_to_stream<Events>(
&self,
stream_name: impl AsRef<str>,
options: &AppendToStreamOptions,
events: Events
) -> Result<WriteResult> where
Events: ToEvents,
pub async fn append_to_stream<Events>(
&self,
stream_name: impl AsRef<str>,
options: &AppendToStreamOptions,
events: Events
) -> Result<WriteResult> where
Events: ToEvents,
Sends events to a given stream.
pub async fn set_stream_metadata(
&self,
stream_name: impl AsRef<str>,
options: &AppendToStreamOptions,
metadata: StreamMetadata
) -> Result<WriteResult>
pub async fn batch_append(
&self,
options: &BatchAppendOptions
) -> Result<BatchAppendClient>
sourcepub async fn read_stream(
&self,
stream_name: impl AsRef<str>,
options: &ReadStreamOptions
) -> Result<ReadStream>
pub async fn read_stream(
&self,
stream_name: impl AsRef<str>,
options: &ReadStreamOptions
) -> Result<ReadStream>
Reads events from a given stream. The reading can be done forward and backward.
sourcepub async fn read_all(&self, options: &ReadAllOptions) -> Result<ReadStream>
pub async fn read_all(&self, options: &ReadAllOptions) -> Result<ReadStream>
Reads events for the system stream $all
. The reading can be done
forward and backward.
sourcepub async fn get_stream_metadata(
&self,
stream_name: impl AsRef<str>,
options: &ReadStreamOptions
) -> Result<StreamMetadataResult>
pub async fn get_stream_metadata(
&self,
stream_name: impl AsRef<str>,
options: &ReadStreamOptions
) -> Result<StreamMetadataResult>
Reads a stream metadata.
sourcepub async fn delete_stream(
&self,
stream_name: impl AsRef<str>,
options: &DeleteStreamOptions
) -> Result<Option<Position>>
pub async fn delete_stream(
&self,
stream_name: impl AsRef<str>,
options: &DeleteStreamOptions
) -> Result<Option<Position>>
Soft deletes a given stream. Makes use of Truncate before. When a stream is deleted, its Truncate before is set to the streams current last event number. When a soft deleted stream is read, the read will return a StreamNotFound. After deleting the stream, you are able to write to it again, continuing from where it left off.
sourcepub async fn tombstone_stream(
&self,
stream_name: impl AsRef<str>,
options: &TombstoneStreamOptions
) -> Result<Option<Position>>
pub async fn tombstone_stream(
&self,
stream_name: impl AsRef<str>,
options: &TombstoneStreamOptions
) -> Result<Option<Position>>
Hard deletes a given stream. A hard delete writes a tombstone event to the stream, permanently deleting it. The stream cannot be recreated or written to again. Tombstone events are written with the event type ‘$streamDeleted’. When a hard deleted stream is read, the read will return a StreamDeleted.
sourcepub async fn subscribe_to_stream(
&self,
stream_name: impl AsRef<str>,
options: &SubscribeToStreamOptions
) -> Subscription
pub async fn subscribe_to_stream(
&self,
stream_name: impl AsRef<str>,
options: &SubscribeToStreamOptions
) -> Subscription
Subscribes to a given stream. This kind of subscription specifies a
starting point (by default, the beginning of a stream). For a regular
stream, that starting point will be an event number. For the system
stream $all
, it will be a position in the transaction file
(see subscribe_to_all
). This subscription will fetch every event
until the end of the stream, then will dispatch subsequently written
events.
For example, if a starting point of 50 is specified when a stream has 100 events in it, the subscriber can expect to see events 51 through 100, and then any events subsequently written events until such time as the subscription is dropped or closed.
sourcepub async fn subscribe_to_all(
&self,
options: &SubscribeToAllOptions
) -> Subscription
pub async fn subscribe_to_all(
&self,
options: &SubscribeToAllOptions
) -> Subscription
Like subscribe_to_stream
but specific to system $all
stream.
sourcepub async fn create_persistent_subscription(
&self,
stream_name: impl AsRef<str>,
group_name: impl AsRef<str>,
options: &PersistentSubscriptionOptions
) -> Result<()>
pub async fn create_persistent_subscription(
&self,
stream_name: impl AsRef<str>,
group_name: impl AsRef<str>,
options: &PersistentSubscriptionOptions
) -> Result<()>
Creates a persistent subscription group on a stream.
Persistent subscriptions are special kind of subscription where the server remembers the state of the subscription. This allows for many different modes of operations compared to a regular or catchup subscription where the client holds the subscription state.
sourcepub async fn create_persistent_subscription_to_all(
&self,
group_name: impl AsRef<str>,
options: &PersistentSubscriptionToAllOptions
) -> Result<()>
pub async fn create_persistent_subscription_to_all(
&self,
group_name: impl AsRef<str>,
options: &PersistentSubscriptionToAllOptions
) -> Result<()>
Creates a persistent subscription group on a the $all stream.
sourcepub async fn update_persistent_subscription(
&self,
stream_name: impl AsRef<str>,
group_name: impl AsRef<str>,
options: &PersistentSubscriptionOptions
) -> Result<()>
pub async fn update_persistent_subscription(
&self,
stream_name: impl AsRef<str>,
group_name: impl AsRef<str>,
options: &PersistentSubscriptionOptions
) -> Result<()>
Updates a persistent subscription group on a stream.
sourcepub async fn update_persistent_subscription_to_all(
&self,
group_name: impl AsRef<str>,
options: &PersistentSubscriptionToAllOptions
) -> Result<()>
pub async fn update_persistent_subscription_to_all(
&self,
group_name: impl AsRef<str>,
options: &PersistentSubscriptionToAllOptions
) -> Result<()>
Updates a persistent subscription group to $all.
sourcepub async fn delete_persistent_subscription(
&self,
stream_name: impl AsRef<str>,
group_name: impl AsRef<str>,
options: &DeletePersistentSubscriptionOptions
) -> Result<()>
pub async fn delete_persistent_subscription(
&self,
stream_name: impl AsRef<str>,
group_name: impl AsRef<str>,
options: &DeletePersistentSubscriptionOptions
) -> Result<()>
Deletes a persistent subscription group on a stream.
sourcepub async fn delete_persistent_subscription_to_all(
&self,
group_name: impl AsRef<str>,
options: &DeletePersistentSubscriptionOptions
) -> Result<()>
pub async fn delete_persistent_subscription_to_all(
&self,
group_name: impl AsRef<str>,
options: &DeletePersistentSubscriptionOptions
) -> Result<()>
Deletes a persistent subscription group on the $all stream.
sourcepub async fn subscribe_to_persistent_subscription(
&self,
stream_name: impl AsRef<str>,
group_name: impl AsRef<str>,
options: &SubscribeToPersistentSubscriptionOptions
) -> Result<PersistentSubscription>
pub async fn subscribe_to_persistent_subscription(
&self,
stream_name: impl AsRef<str>,
group_name: impl AsRef<str>,
options: &SubscribeToPersistentSubscriptionOptions
) -> Result<PersistentSubscription>
Connects to a persistent subscription group on a stream.
sourcepub async fn subscribe_to_persistent_subscription_to_all(
&self,
group_name: impl AsRef<str>,
options: &SubscribeToPersistentSubscriptionOptions
) -> Result<PersistentSubscription>
pub async fn subscribe_to_persistent_subscription_to_all(
&self,
group_name: impl AsRef<str>,
options: &SubscribeToPersistentSubscriptionOptions
) -> Result<PersistentSubscription>
Connects to a persistent subscription group to $all stream.
sourcepub async fn replay_parked_messages(
&self,
stream_name: impl AsRef<str>,
group_name: impl AsRef<str>,
options: &ReplayParkedMessagesOptions
) -> Result<()>
pub async fn replay_parked_messages(
&self,
stream_name: impl AsRef<str>,
group_name: impl AsRef<str>,
options: &ReplayParkedMessagesOptions
) -> Result<()>
Replays a persistent subscriptions parked events.
sourcepub async fn replay_parked_messages_to_all(
&self,
group_name: impl AsRef<str>,
options: &ReplayParkedMessagesOptions
) -> Result<()>
pub async fn replay_parked_messages_to_all(
&self,
group_name: impl AsRef<str>,
options: &ReplayParkedMessagesOptions
) -> Result<()>
Replays a persistent subscriptions to $all parked events.
sourcepub async fn list_all_persistent_subscriptions(
&self,
options: &ListPersistentSubscriptionsOptions
) -> Result<Vec<PersistentSubscriptionInfo<RevisionOrPosition>>>
pub async fn list_all_persistent_subscriptions(
&self,
options: &ListPersistentSubscriptionsOptions
) -> Result<Vec<PersistentSubscriptionInfo<RevisionOrPosition>>>
Lists all persistent subscriptions to date.
sourcepub async fn list_persistent_subscriptions_for_stream(
&self,
stream_name: impl AsRef<str>,
options: &ListPersistentSubscriptionsOptions
) -> Result<Vec<PersistentSubscriptionInfo<u64>>>
pub async fn list_persistent_subscriptions_for_stream(
&self,
stream_name: impl AsRef<str>,
options: &ListPersistentSubscriptionsOptions
) -> Result<Vec<PersistentSubscriptionInfo<u64>>>
List all persistent subscriptions of a specific stream.
sourcepub async fn list_persistent_subscriptions_to_all(
&self,
options: &ListPersistentSubscriptionsOptions
) -> Result<Vec<PersistentSubscriptionInfo<Position>>>
pub async fn list_persistent_subscriptions_to_all(
&self,
options: &ListPersistentSubscriptionsOptions
) -> Result<Vec<PersistentSubscriptionInfo<Position>>>
List all persistent subscriptions of the $all stream.
pub async fn get_persistent_subscription_info(
&self,
stream_name: impl AsRef<str>,
group_name: impl AsRef<str>,
options: &GetPersistentSubscriptionInfoOptions
) -> Result<PersistentSubscriptionInfo<u64>>
pub async fn get_persistent_subscription_info_to_all(
&self,
group_name: impl AsRef<str>,
options: &GetPersistentSubscriptionInfoOptions
) -> Result<PersistentSubscriptionInfo<Position>>
pub async fn restart_persistent_subscription_subsystem(
&self,
options: &RestartPersistentSubscriptionSubsystem
) -> Result<()>
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
sourcefn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message T
in a tonic::Request
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more