Struct dapr::client::Client

source ·
pub struct Client<T>(/* private fields */);

Implementations§

source§

impl<T: DaprInterface> Client<T>

source

pub async fn connect(addr: String) -> Result<Self, Error>

Connect to a Dapr enabled app.

§Arguments
  • addr - Address of gRPC server to connect to.
source

pub async fn invoke_service<I, M>( &mut self, app_id: I, method_name: M, data: Option<Any> ) -> Result<InvokeServiceResponse, Error>
where I: Into<String>, M: Into<String>,

Invoke a method in a Dapr enabled app.

§Arguments
  • app_id - Id of the application running.
  • method_name - Name of the method to invoke.
  • data - Required. Bytes value or data required to invoke service.
source

pub async fn invoke_binding<S>( &mut self, name: S, data: Vec<u8> ) -> Result<InvokeBindingResponse, Error>
where S: Into<String>,

Invoke an Dapr output binding.

§Arguments
  • name - The name of the output binding to invoke.
  • data - The data which will be sent to the output binding.
source

pub async fn publish_event<S>( &mut self, pubsub_name: S, topic: S, data_content_type: S, data: Vec<u8>, metadata: Option<HashMap<String, String>> ) -> Result<(), Error>
where S: Into<String>,

Publish a payload to multiple consumers who are listening on a topic.

Dapr guarantees at least once semantics for this endpoint.

§Arguments
  • pubsub_name - Name of the pubsub component
  • topic - Pubsub topic.
  • data - The data which will be published to topic.
source

pub async fn get_secret<S>( &mut self, store_name: S, key: S ) -> Result<GetSecretResponse, Error>
where S: Into<String>,

Get the secret for a specific key.

§Arguments
  • store_name - The name of secret store.
  • key - The name of secret key.
source

pub async fn get_state<S>( &mut self, store_name: S, key: S, metadata: Option<HashMap<String, String>> ) -> Result<GetStateResponse, Error>
where S: Into<String>,

Get the state for a specific key.

§Arguments
  • store_name - The name of state store.
  • key - The key of the desired state.
source

pub async fn save_state<I, K>( &mut self, store_name: K, states: I ) -> Result<(), Error>
where I: IntoIterator<Item = (K, Vec<u8>)>, K: Into<String>,

Save an array of state objects.

§Arguments
  • store_name - The name of state store.
  • states - The array of the state key values.
source

pub async fn delete_bulk_state<I, K>( &mut self, store_name: K, states: I ) -> Result<(), Error>
where I: IntoIterator<Item = (K, Vec<u8>)>, K: Into<String>,

Delete an array of state objects.

§Arguments
  • store_name - The name of state store.
  • states - The array of the state key values.
source

pub async fn delete_state<S>( &mut self, store_name: S, key: S, metadata: Option<HashMap<String, String>> ) -> Result<(), Error>
where S: Into<String>,

Delete the state for a specific key.

§Arguments
  • store_name - The name of state store.
  • key - The key of the desired state.
source

pub async fn set_metadata<S>(&mut self, key: S, value: S) -> Result<(), Error>
where S: Into<String>,

Set sidecar Metadata

§Arguments
  • key - The metadata key
  • value - The metadata value
source

pub async fn get_metadata(&mut self) -> Result<GetMetadataResponse, Error>

Set sidecar Metadata

source

pub async fn invoke_actor<I, M, TInput, TOutput>( &mut self, actor_type: I, actor_id: I, method_name: M, input: TInput, metadata: Option<HashMap<String, String>> ) -> Result<TOutput, Error>
where I: Into<String>, M: Into<String>, TInput: Serialize, TOutput: for<'a> Deserialize<'a>,

Invoke a method in a Dapr actor.

§Arguments
  • actor_type - Type of the actor.
  • actor_id - Id of the actor.
  • method_name - Name of the method to invoke.
  • input - Required. Data required to invoke service, should be json serializable.
source

pub async fn get_configuration<S, K>( &mut self, store_name: S, keys: Vec<K>, metadata: Option<HashMap<String, String>> ) -> Result<GetConfigurationResponse, Error>
where S: Into<String>, K: Into<String>,

Get the configuration for a specific key ///

§Arguments
  • store_name - The name of config store.
  • keys - The key of the desired configuration.
source

pub async fn subscribe_configuration<S>( &mut self, store_name: S, keys: Vec<S>, metadata: Option<HashMap<String, String>> ) -> Result<Streaming<SubscribeConfigurationResponse>, Error>
where S: Into<String>,

Subscribe to configuration changes

source

pub async fn unsubscribe_configuration<S>( &mut self, store_name: S, id: S ) -> Result<UnsubscribeConfigurationResponse, Error>
where S: Into<String>,

Unsubscribe from configuration changes

Trait Implementations§

source§

impl<T: Clone> Clone for Client<T>

source§

fn clone(&self) -> Client<T>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Client<T>
where T: RefUnwindSafe,

§

impl<T> Send for Client<T>
where T: Send,

§

impl<T> Sync for Client<T>
where T: Sync,

§

impl<T> Unpin for Client<T>
where T: Unpin,

§

impl<T> UnwindSafe for Client<T>
where T: UnwindSafe,

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> 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> 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<T> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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