Struct Client

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

Represents a client to a single node. Client maintains a full duplex communication to KurrentDB.

Many threads can use a KurrentDB client at the same time or a single thread can make many asynchronous requests.

Implementations§

Source§

impl Client

Source

pub fn new(settings: ClientSettings) -> Result<Self>

Creates a gRPC client to a KurrentDB database.

Source

pub fn with_runtime_handle( handle: Handle, settings: ClientSettings, ) -> Result<Self>

Creates a gRPC client to a KurrentDB database using an existing tokio runtime.

Source

pub fn settings(&self) -> &ClientSettings

Source

pub async fn server_info(&self) -> Result<ServerInfo>

Returns the server information the client is connected to. If None, means you are dealing with a server older than 21.6 version.

Source

pub async fn append_to_stream<Events>( &self, stream_name: impl StreamName, options: &AppendToStreamOptions, events: Events, ) -> Result<WriteResult>
where Events: ToEvents,

Sends events to a given stream.

Source

pub async fn set_stream_metadata( &self, name: impl MetadataStreamName, options: &AppendToStreamOptions, metadata: &StreamMetadata, ) -> Result<WriteResult>

Source

pub async fn batch_append( &self, options: &BatchAppendOptions, ) -> Result<BatchAppendClient>

Source

pub async fn read_stream( &self, stream_name: impl StreamName, options: &ReadStreamOptions, ) -> Result<ReadStream>

Reads events from a given stream. The reading can be done forward and backward.

Source

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.

Source

pub async fn get_stream_metadata( &self, name: impl MetadataStreamName, options: &ReadStreamOptions, ) -> Result<StreamMetadataResult>

Reads a stream metadata.

Source

pub async fn delete_stream( &self, stream_name: impl StreamName, 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.

Source

pub async fn tombstone_stream( &self, stream_name: impl StreamName, 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.

Source

pub async fn subscribe_to_stream( &self, stream_name: impl StreamName, 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.

Source

pub async fn subscribe_to_all( &self, options: &SubscribeToAllOptions, ) -> Subscription

Like subscribe_to_stream but specific to system $all stream.

Source

pub async fn create_persistent_subscription( &self, stream_name: impl StreamName, 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.

Source

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.

Source

pub async fn update_persistent_subscription( &self, stream_name: impl StreamName, group_name: impl AsRef<str>, options: &PersistentSubscriptionOptions, ) -> Result<()>

Updates a persistent subscription group on a stream.

Source

pub async fn update_persistent_subscription_to_all( &self, group_name: impl AsRef<str>, options: &PersistentSubscriptionToAllOptions, ) -> Result<()>

Updates a persistent subscription group to $all.

Source

pub async fn delete_persistent_subscription( &self, stream_name: impl StreamName, group_name: impl AsRef<str>, options: &DeletePersistentSubscriptionOptions, ) -> Result<()>

Deletes a persistent subscription group on a stream.

Source

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.

Source

pub async fn subscribe_to_persistent_subscription( &self, stream_name: impl StreamName, group_name: impl AsRef<str>, options: &SubscribeToPersistentSubscriptionOptions, ) -> Result<PersistentSubscription>

Connects to a persistent subscription group on a stream.

Source

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.

Source

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.

Source

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.

Source

pub async fn list_all_persistent_subscriptions( &self, options: &ListPersistentSubscriptionsOptions, ) -> Result<Vec<PersistentSubscriptionInfo<RevisionOrPosition>>>

Lists all persistent subscriptions to date.

Source

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.

Source

pub async fn list_persistent_subscriptions_to_all( &self, options: &ListPersistentSubscriptionsOptions, ) -> Result<Vec<PersistentSubscriptionInfo<Position>>>

List all persistent subscriptions of the $all stream.

Source

pub async fn get_persistent_subscription_info( &self, stream_name: impl AsRef<str>, group_name: impl AsRef<str>, options: &GetPersistentSubscriptionInfoOptions, ) -> Result<PersistentSubscriptionInfo<u64>>

Source

pub async fn get_persistent_subscription_info_to_all( &self, group_name: impl AsRef<str>, options: &GetPersistentSubscriptionInfoOptions, ) -> Result<PersistentSubscriptionInfo<Position>>

Source

pub async fn restart_persistent_subscription_subsystem( &self, options: &RestartPersistentSubscriptionSubsystem, ) -> Result<()>

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl From<Client> for Client

Source§

fn from(src: Client) -> Self

Converts to this type from the input type.
Source§

impl From<Client> for ProjectionClient

Source§

fn from(src: Client) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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

impl<T> ErasedDestructor for T
where T: 'static,