Skip to content

Commit

Permalink
Handle metadata for get_configuration and subscribe_configuration (#118)
Browse files Browse the repository at this point in the history
* Add metadata parameter for config get and subscribe

Signed-off-by: David Blackwood <david.blackwood@rockwellautomation.com>

* Bump version

Signed-off-by: David Blackwood <david.blackwood@rockwellautomation.com>

* Revert "Bump version"

This reverts commit 7747075.

Signed-off-by: David Blackwood <david.blackwood@rockwellautomation.com>

* Revert "Bump version"

This reverts commit 7747075.

Signed-off-by: David Blackwood <david.blackwood@rockwellautomation.com>

---------

Signed-off-by: David Blackwood <david.blackwood@rockwellautomation.com>
  • Loading branch information
blackwood-ra committed Feb 20, 2024
1 parent ceaccb1 commit a9df2d9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions examples/configuration/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

// save key-value pair in the state store
let response = client
.get_configuration(CONFIGSTORE_NAME, vec![(&key)])
.get_configuration(CONFIGSTORE_NAME, vec![(&key)], None)
.await?;
let val = response.items.get("hello").unwrap();
println!("Configuration value: {val:?}");

// Subscribe for configuration changes
let mut stream = client
.subscribe_configuration(CONFIGSTORE_NAME, vec![(&key)])
.subscribe_configuration(CONFIGSTORE_NAME, vec![(&key)], None)
.await?;

let mut subscription_id = String::new();
Expand Down
6 changes: 4 additions & 2 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ impl<T: DaprInterface> Client<T> {
&mut self,
store_name: S,
keys: Vec<K>,
metadata: Option<HashMap<String, String>>,
) -> Result<GetConfigurationResponse, Error>
where
S: Into<String>,
Expand All @@ -319,7 +320,7 @@ impl<T: DaprInterface> Client<T> {
let request = GetConfigurationRequest {
store_name: store_name.into(),
keys: keys.into_iter().map(|key| key.into()).collect(),
metadata: Default::default(),
metadata: metadata.unwrap_or_default(),
};
self.0.get_configuration(request).await
}
Expand All @@ -329,14 +330,15 @@ impl<T: DaprInterface> Client<T> {
&mut self,
store_name: S,
keys: Vec<S>,
metadata: Option<HashMap<String, String>>,
) -> Result<Streaming<SubscribeConfigurationResponse>, Error>
where
S: Into<String>,
{
let request = SubscribeConfigurationRequest {
store_name: store_name.into(),
keys: keys.into_iter().map(|key| key.into()).collect(),
metadata: Default::default(),
metadata: metadata.unwrap_or_default(),
};
self.0.subscribe_configuration(request).await
}
Expand Down

0 comments on commit a9df2d9

Please sign in to comment.