Skip to content

Commit 49fc694

Browse files
authored
Update to 1.0.0-RC.2 proto (#35)
* Update to latest proto from dapr/dapr * Update signature of publish_event<S> to match PublishEventRequest * Fix lint message * Run cargo fmt * Update example to also print content-type
1 parent e764932 commit 49fc694

File tree

5 files changed

+124
-8
lines changed

5 files changed

+124
-8
lines changed

dapr/proto/runtime/v1/appcallback.proto

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ service AppCallback {
3838
rpc OnBindingEvent(BindingEventRequest) returns (BindingEventResponse) {}
3939
}
4040

41-
// TopicEventRequest message is compatiable with CloudEvent spec v1.0
41+
// TopicEventRequest message is compatible with CloudEvent spec v1.0
4242
// https://github.com/cloudevents/spec/blob/v1.0/spec.md
4343
message TopicEventRequest {
4444
// id identifies the event. Producers MUST ensure that source + id
@@ -90,7 +90,7 @@ message TopicEventResponse {
9090

9191
// BindingEventRequest represents input bindings event.
9292
message BindingEventRequest {
93-
// Requried. The name of the input binding component.
93+
// Required. The name of the input binding component.
9494
string name = 1;
9595

9696
// Required. The payload that the input bindings sent
@@ -142,12 +142,12 @@ message TopicSubscription {
142142
// Required. The name of topic which will be subscribed
143143
string topic = 2;
144144

145-
// The optional properties used for this topic's subscribtion e.g. session id
145+
// The optional properties used for this topic's subscription e.g. session id
146146
map<string,string> metadata = 3;
147147
}
148148

149149
// ListInputBindingsResponse is the message including the list of input bindings.
150150
message ListInputBindingsResponse {
151151
// The list of input bindings.
152152
repeated string bindings = 1;
153-
}
153+
}

dapr/proto/runtime/v1/dapr.proto

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ syntax = "proto3";
77

88
package dapr.proto.runtime.v1;
99

10+
import "google/protobuf/any.proto";
1011
import "google/protobuf/empty.proto";
1112
import "dapr/proto/common/v1/common.proto";
1213

@@ -44,12 +45,27 @@ service Dapr {
4445
// Gets secrets from secret stores.
4546
rpc GetSecret(GetSecretRequest) returns (GetSecretResponse) {}
4647

48+
// Gets a bulk of secrets
49+
rpc GetBulkSecret(GetBulkSecretRequest) returns (GetBulkSecretResponse) {}
50+
4751
// Register an actor timer.
4852
rpc RegisterActorTimer(RegisterActorTimerRequest) returns (google.protobuf.Empty) {}
4953

5054
// Unregister an actor timer.
5155
rpc UnregisterActorTimer(UnregisterActorTimerRequest) returns (google.protobuf.Empty) {}
5256

57+
// Register an actor reminder.
58+
rpc RegisterActorReminder(RegisterActorReminderRequest) returns (google.protobuf.Empty) {}
59+
60+
// Unregister an actor reminder.
61+
rpc UnregisterActorReminder(UnregisterActorReminderRequest) returns (google.protobuf.Empty) {}
62+
63+
// Gets the state for a specific actor.
64+
rpc GetActorState(GetActorStateRequest) returns (GetActorStateResponse) {}
65+
66+
// Executes state transactions for a specified actor
67+
rpc ExecuteActorStateTransaction(ExecuteActorStateTransactionRequest) returns (google.protobuf.Empty) {}
68+
5369
// InvokeActor calls a method on an actor.
5470
rpc InvokeActor (InvokeActorRequest) returns (InvokeActorResponse) {}
5571
}
@@ -114,6 +130,9 @@ message BulkStateItem {
114130

115131
// The error that was returned from the state store in case of a failed get operation.
116132
string error = 4;
133+
134+
// The metadata which will be sent to app.
135+
map<string,string> metadata = 5;
117136
}
118137

119138
// GetStateResponse is the response conveying the state value and etag.
@@ -124,6 +143,9 @@ message GetStateResponse {
124143
// The entity tag which represents the specific version of data.
125144
// ETag format is defined by the corresponding data store.
126145
string etag = 2;
146+
147+
// The metadata which will be sent to app.
148+
map<string,string> metadata = 3;
127149
}
128150

129151
// DeleteStateRequest is the message to delete key-value states in the specific state store.
@@ -165,6 +187,15 @@ message PublishEventRequest {
165187

166188
// The data which will be published to topic.
167189
bytes data = 3;
190+
191+
// The content type for the data (optional).
192+
string data_content_type = 4;
193+
194+
// The metadata passing to pub components
195+
//
196+
// metadata property:
197+
// - key : the key of the message.
198+
map<string,string> metadata = 5;
168199
}
169200

170201
// InvokeBindingRequest is the message to send data to output bindings
@@ -216,6 +247,22 @@ message GetSecretResponse {
216247
map<string, string> data = 1;
217248
}
218249

250+
// GetBulkSecretRequest is the message to get the secrets from secret store.
251+
message GetBulkSecretRequest {
252+
// The name of secret store.
253+
string store_name = 1;
254+
255+
// The metadata which will be sent to secret store components.
256+
map<string,string> metadata = 2;
257+
}
258+
259+
// GetBulkSecretResponse is the response message to convey the requested secret.
260+
message GetBulkSecretResponse {
261+
// data hold the secret values. Some secret store, such as kubernetes secret
262+
// store, can save multiple secrets for single secret key.
263+
map<string, string> data = 1;
264+
}
265+
219266
// TransactionalStateOperation is the message to execute a specified operation with a key-value pair.
220267
message TransactionalStateOperation {
221268
// The type of operation to be executed
@@ -255,6 +302,49 @@ message UnregisterActorTimerRequest {
255302
string name = 3;
256303
}
257304

305+
// RegisterActorReminderRequest is the message to register a reminder for an actor of a given type and id.
306+
message RegisterActorReminderRequest {
307+
string actor_type = 1;
308+
string actor_id = 2;
309+
string name = 3;
310+
string due_time = 4;
311+
string period = 5;
312+
bytes data = 6;
313+
}
314+
315+
// UnregisterActorReminderRequest is the message to unregister an actor reminder.
316+
message UnregisterActorReminderRequest {
317+
string actor_type = 1;
318+
string actor_id = 2;
319+
string name = 3;
320+
}
321+
322+
// GetActorStateRequest is the message to get key-value states from specific actor.
323+
message GetActorStateRequest {
324+
string actor_type = 1;
325+
string actor_id = 2;
326+
string key = 3;
327+
}
328+
329+
// GetActorStateResponse is the response conveying the actor's state value.
330+
message GetActorStateResponse {
331+
bytes data = 1;
332+
}
333+
334+
// ExecuteActorStateTransactionRequest is the message to execute multiple operations on a specified actor.
335+
message ExecuteActorStateTransactionRequest {
336+
string actor_type = 1;
337+
string actor_id = 2;
338+
repeated TransactionalActorStateOperation operations = 3;
339+
}
340+
341+
// TransactionalAcorStateOperation is the message to execute a specified operation with a key-value pair.
342+
message TransactionalActorStateOperation {
343+
string operationType = 1;
344+
string key = 2;
345+
google.protobuf.Any value = 3;
346+
}
347+
258348
// InvokeActorRequest is the message to call an actor.
259349
message InvokeActorRequest {
260350
string actor_type = 1;

examples/pubsub/publisher.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{thread, time::Duration};
1+
use std::{collections::HashMap, thread, time::Duration};
22

33
#[tokio::main]
44
async fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -16,13 +16,29 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
1616
// name of the pubsub component
1717
let pubsub_name = "pubsub".to_string();
1818

19+
// content type of the pubsub data
20+
let data_content_type = "text/plain".to_string();
21+
1922
// topic to publish message to
2023
let topic = "A".to_string();
2124

2225
for count in 0..100 {
26+
// message metadata
27+
let mut metadata = HashMap::<String, String>::new();
28+
metadata.insert("count".to_string(), count.to_string());
29+
30+
// message
2331
let message = format!("{} => hello from rust!", &count).into_bytes();
2432

25-
client.publish_event(&pubsub_name, &topic, message).await?;
33+
client
34+
.publish_event(
35+
&pubsub_name,
36+
&topic,
37+
&data_content_type,
38+
message,
39+
Some(metadata),
40+
)
41+
.await?;
2642

2743
// sleep for 2 secs to simulate delay b/w two events
2844
tokio::time::delay_for(Duration::from_secs(2)).await;

examples/pubsub/subscriber.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ impl AppCallback for AppCallbackService {
4040
&self,
4141
request: Request<TopicEventRequest>,
4242
) -> Result<Response<TopicEventResponse>, Status> {
43-
let data = &request.into_inner().data;
43+
let r = request.into_inner();
44+
let data = &r.data;
45+
let data_content_type = &r.data_content_type;
4446

4547
let message = String::from_utf8_lossy(&data);
46-
4748
println!("Message: {}", &message);
49+
println!("Content-Type: {}", &data_content_type);
4850

4951
Ok(Response::new(TopicEventResponse::default()))
5052
}

src/client.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,24 @@ impl<T: DaprInterface> Client<T> {
8686
&mut self,
8787
pubsub_name: S,
8888
topic: S,
89+
data_content_type: S,
8990
data: Vec<u8>,
91+
metadata: Option<HashMap<String, String>>,
9092
) -> Result<(), Error>
9193
where
9294
S: Into<String>,
9395
{
96+
let mut mdata = HashMap::<String, String>::new();
97+
if let Some(m) = metadata {
98+
mdata = m;
99+
}
94100
self.0
95101
.publish_event(PublishEventRequest {
96102
pubsub_name: pubsub_name.into(),
97103
topic: topic.into(),
104+
data_content_type: data_content_type.into(),
98105
data,
106+
metadata: mdata,
99107
})
100108
.await
101109
}

0 commit comments

Comments
 (0)