Skip to content

Commit ee3cacf

Browse files
authored
Update to 1.0.0-rc.3 protos (#37)
* Update to 1.0.0-rc.3 protos * Add new calls to client
1 parent 49fc694 commit ee3cacf

3 files changed

Lines changed: 129 additions & 5 deletions

File tree

dapr/proto/common/v1/common.proto

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ message StateItem {
8989

9090
// The entity tag which represents the specific version of data.
9191
// The exact ETag format is defined by the corresponding data store.
92-
string etag = 3;
92+
Etag etag = 3;
9393

9494
// The metadata which will be passed to state store component.
9595
map<string,string> metadata = 4;
@@ -98,6 +98,12 @@ message StateItem {
9898
StateOptions options = 5;
9999
}
100100

101+
// Etag represents a state item version
102+
message Etag {
103+
// value sets the etag value
104+
string value = 1;
105+
}
106+
101107
// StateOptions configures concurrency and consistency for state operations
102108
message StateOptions {
103109
// Enum describing the supported concurrency for state.

dapr/proto/runtime/v1/dapr.proto

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ service Dapr {
3232

3333
// Deletes the state for a specific key.
3434
rpc DeleteState(DeleteStateRequest) returns (google.protobuf.Empty) {}
35-
35+
36+
// Deletes a bulk of state items for a list of keys
37+
rpc DeleteBulkState(DeleteBulkStateRequest) returns (google.protobuf.Empty) {}
38+
3639
// Executes transactions for a specified store
3740
rpc ExecuteStateTransaction(ExecuteStateTransactionRequest) returns (google.protobuf.Empty) {}
3841

@@ -68,6 +71,12 @@ service Dapr {
6871

6972
// InvokeActor calls a method on an actor.
7073
rpc InvokeActor (InvokeActorRequest) returns (InvokeActorResponse) {}
74+
75+
// Gets metadata of the sidecar
76+
rpc GetMetadata (google.protobuf.Empty) returns (GetMetadataResponse) {}
77+
78+
// Sets value in extended metadata of the sidecar
79+
rpc SetMetadata (SetMetadataRequest) returns (google.protobuf.Empty) {}
7180
}
7281

7382
// InvokeServiceRequest represents the request message for Service invocation.
@@ -158,7 +167,7 @@ message DeleteStateRequest {
158167

159168
// The entity tag which represents the specific version of data.
160169
// The exact ETag format is defined by the corresponding data store.
161-
string etag = 3;
170+
common.v1.Etag etag = 3;
162171

163172
// State operation options which includes concurrency/
164173
// consistency/retry_policy.
@@ -168,6 +177,15 @@ message DeleteStateRequest {
168177
map<string,string> metadata = 5;
169178
}
170179

180+
// DeleteBulkStateRequest is the message to delete a list of key-value states from specific state store.
181+
message DeleteBulkStateRequest {
182+
// The name of state store.
183+
string store_name = 1;
184+
185+
// The array of the state key values.
186+
repeated common.v1.StateItem states = 2;
187+
}
188+
171189
// SaveStateRequest is the message to save multiple states into state store.
172190
message SaveStateRequest {
173191
// The name of state store.
@@ -256,11 +274,16 @@ message GetBulkSecretRequest {
256274
map<string,string> metadata = 2;
257275
}
258276

259-
// GetBulkSecretResponse is the response message to convey the requested secret.
277+
// SecretResponse is a map of decrypted string/string values
278+
message SecretResponse {
279+
map<string, string> secrets = 1;
280+
}
281+
282+
// GetBulkSecretResponse is the response message to convey the requested secrets.
260283
message GetBulkSecretResponse {
261284
// data hold the secret values. Some secret store, such as kubernetes secret
262285
// store, can save multiple secrets for single secret key.
263-
map<string, string> data = 1;
286+
map<string, SecretResponse> data = 1;
264287
}
265288

266289
// TransactionalStateOperation is the message to execute a specified operation with a key-value pair.
@@ -357,3 +380,27 @@ message InvokeActorRequest {
357380
message InvokeActorResponse {
358381
bytes data = 1;
359382
}
383+
384+
// GetMetadataResponse is a message that is returned on GetMetadata rpc call
385+
message GetMetadataResponse {
386+
string id = 1;
387+
repeated ActiveActorsCount active_actors_count = 2;
388+
repeated RegisteredComponents registered_components = 3;
389+
map<string,string> extended_metadata = 4;
390+
}
391+
392+
message ActiveActorsCount {
393+
string type = 1;
394+
int32 count = 2;
395+
}
396+
397+
message RegisteredComponents {
398+
string name = 1;
399+
string type = 2;
400+
string version = 3;
401+
}
402+
403+
message SetMetadataRequest {
404+
string key = 1;
405+
string value = 2;
406+
}

src/client.rs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,25 @@ impl<T: DaprInterface> Client<T> {
176176
.await
177177
}
178178

179+
/// Delete an array of state objects.
180+
///
181+
/// # Arguments
182+
///
183+
/// * `store_name` - The name of state store.
184+
/// * `states` - The array of the state key values.
185+
pub async fn delete_bulk_state<I, K>(&mut self, store_name: K, states: I) -> Result<(), Error>
186+
where
187+
I: IntoIterator<Item = (K, Vec<u8>)>,
188+
K: Into<String>,
189+
{
190+
self.0
191+
.delete_bulk_state(DeleteBulkStateRequest {
192+
store_name: store_name.into(),
193+
states: states.into_iter().map(|pair| pair.into()).collect(),
194+
})
195+
.await
196+
}
197+
179198
/// Delete the state for a specific key.
180199
///
181200
/// # Arguments
@@ -205,6 +224,31 @@ impl<T: DaprInterface> Client<T> {
205224
})
206225
.await
207226
}
227+
228+
/// Set sidecar Metadata
229+
///
230+
/// # Arguments
231+
///
232+
/// * `key` - The metadata key
233+
/// * `value` - The metadata value
234+
pub async fn set_metadata<S>(&mut self, key: S, value: S) -> Result<(), Error>
235+
where
236+
S: Into<String>,
237+
{
238+
self.0
239+
.set_metadata(SetMetadataRequest {
240+
key: key.into(),
241+
value: value.into(),
242+
..Default::default()
243+
})
244+
.await
245+
}
246+
247+
/// Set sidecar Metadata
248+
///
249+
pub async fn get_metadata(&mut self) -> Result<GetMetadataResponse, Error> {
250+
self.0.get_metadata().await
251+
}
208252
}
209253

210254
#[async_trait]
@@ -223,6 +267,9 @@ pub trait DaprInterface: Sized {
223267
async fn get_state(&mut self, request: GetStateRequest) -> Result<GetStateResponse, Error>;
224268
async fn save_state(&mut self, request: SaveStateRequest) -> Result<(), Error>;
225269
async fn delete_state(&mut self, request: DeleteStateRequest) -> Result<(), Error>;
270+
async fn delete_bulk_state(&mut self, request: DeleteBulkStateRequest) -> Result<(), Error>;
271+
async fn set_metadata(&mut self, request: SetMetadataRequest) -> Result<(), Error>;
272+
async fn get_metadata(&mut self) -> Result<GetMetadataResponse, Error>;
226273
}
227274

228275
#[async_trait]
@@ -273,6 +320,21 @@ impl DaprInterface for dapr_v1::dapr_client::DaprClient<TonicChannel> {
273320
async fn delete_state(&mut self, request: DeleteStateRequest) -> Result<(), Error> {
274321
Ok(self.delete_state(Request::new(request)).await?.into_inner())
275322
}
323+
324+
async fn delete_bulk_state(&mut self, request: DeleteBulkStateRequest) -> Result<(), Error> {
325+
Ok(self
326+
.delete_bulk_state(Request::new(request))
327+
.await?
328+
.into_inner())
329+
}
330+
331+
async fn set_metadata(&mut self, request: SetMetadataRequest) -> Result<(), Error> {
332+
Ok(self.set_metadata(Request::new(request)).await?.into_inner())
333+
}
334+
335+
async fn get_metadata(&mut self) -> Result<GetMetadataResponse, Error> {
336+
Ok(self.get_metadata(Request::new(())).await?.into_inner())
337+
}
276338
}
277339

278340
/// A request from invoking a service
@@ -302,12 +364,21 @@ pub type SaveStateRequest = dapr_v1::SaveStateRequest;
302364
/// A request for deleting state
303365
pub type DeleteStateRequest = dapr_v1::DeleteStateRequest;
304366

367+
/// A request for deleting bulk state
368+
pub type DeleteBulkStateRequest = dapr_v1::DeleteBulkStateRequest;
369+
305370
/// A request for getting secret
306371
pub type GetSecretRequest = dapr_v1::GetSecretRequest;
307372

308373
/// A response from getting secret
309374
pub type GetSecretResponse = dapr_v1::GetSecretResponse;
310375

376+
/// A response from getting metadata
377+
pub type GetMetadataResponse = dapr_v1::GetMetadataResponse;
378+
379+
/// A request for setting metadata
380+
pub type SetMetadataRequest = dapr_v1::SetMetadataRequest;
381+
311382
/// A tonic based gRPC client
312383
pub type TonicClient = dapr_v1::dapr_client::DaprClient<TonicChannel>;
313384

0 commit comments

Comments
 (0)