Skip to content

Commit 658dcc4

Browse files
committed
refactor: lint issues and correctness improvements
Signed-off-by: Mike Nguyen <[email protected]>
1 parent 8b97f4a commit 658dcc4

File tree

15 files changed

+39
-42
lines changed

15 files changed

+39
-42
lines changed

.github/workflows/dapr-bot/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ rust-version = "1.70.0"
1111

1212
[dependencies]
1313
exitcode = "1.1.2"
14-
octocrab = "0.34.1"
14+
octocrab = "0.42.1"
1515
serde_json = "1.0.114"
1616
tokio = { version = "1.36.0", features = ["full"] }

dapr/src/appcallback.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,36 @@
1-
use crate::dapr;
21
use crate::dapr::proto::runtime::v1::app_callback_server::AppCallback;
32
use crate::dapr::proto::{common, runtime};
43
use std::collections::HashMap;
54
use tonic::{Code, Request, Response, Status};
65

76
/// InvokeRequest is the message to invoke a method with the data.
8-
pub type InvokeRequest = dapr::proto::common::v1::InvokeRequest;
7+
pub type InvokeRequest = common::v1::InvokeRequest;
98

109
/// InvokeResponse is the response message inclduing data and its content type
1110
/// from app callback.
12-
pub type InvokeResponse = dapr::proto::common::v1::InvokeResponse;
11+
pub type InvokeResponse = common::v1::InvokeResponse;
1312

1413
/// ListTopicSubscriptionsResponse is the message including the list of the subscribing topics.
15-
pub type ListTopicSubscriptionsResponse = dapr::proto::runtime::v1::ListTopicSubscriptionsResponse;
14+
pub type ListTopicSubscriptionsResponse = runtime::v1::ListTopicSubscriptionsResponse;
1615

1716
/// TopicSubscription represents a topic and it's metadata (session id etc.)
18-
pub type TopicSubscription = dapr::proto::runtime::v1::TopicSubscription;
17+
pub type TopicSubscription = runtime::v1::TopicSubscription;
1918

2019
/// TopicEventRequest message is compatiable with CloudEvent spec v1.0.
21-
pub type TopicEventRequest = dapr::proto::runtime::v1::TopicEventRequest;
20+
pub type TopicEventRequest = runtime::v1::TopicEventRequest;
2221

2322
/// TopicEventResponse is response from app on published message
24-
pub type TopicEventResponse = dapr::proto::runtime::v1::TopicEventResponse;
23+
pub type TopicEventResponse = runtime::v1::TopicEventResponse;
2524

2625
/// ListInputBindingsResponse is the message including the list of input bindings.
27-
pub type ListInputBindingsResponse = dapr::proto::runtime::v1::ListInputBindingsResponse;
26+
pub type ListInputBindingsResponse = runtime::v1::ListInputBindingsResponse;
2827

2928
/// BindingEventRequest represents input bindings event.
30-
pub type BindingEventRequest = dapr::proto::runtime::v1::BindingEventRequest;
29+
pub type BindingEventRequest = runtime::v1::BindingEventRequest;
3130

3231
/// BindingEventResponse includes operations to save state or
3332
/// send data to output bindings optionally.
34-
pub type BindingEventResponse = dapr::proto::runtime::v1::BindingEventResponse;
33+
pub type BindingEventResponse = runtime::v1::BindingEventResponse;
3534

3635
impl ListTopicSubscriptionsResponse {
3736
/// Create `ListTopicSubscriptionsResponse` with a topic.

dapr/src/client.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,13 @@ impl DaprInterface for dapr_v1::dapr_client::DaprClient<TonicChannel> {
656656
Ok(dapr_v1::dapr_client::DaprClient::connect(addr).await?)
657657
}
658658

659+
async fn publish_event(&mut self, request: PublishEventRequest) -> Result<(), Error> {
660+
self.publish_event(Request::new(request))
661+
.await?
662+
.into_inner();
663+
Ok(())
664+
}
665+
659666
async fn invoke_service(
660667
&mut self,
661668
request: InvokeServiceRequest,
@@ -676,13 +683,6 @@ impl DaprInterface for dapr_v1::dapr_client::DaprClient<TonicChannel> {
676683
.into_inner())
677684
}
678685

679-
async fn publish_event(&mut self, request: PublishEventRequest) -> Result<(), Error> {
680-
self.publish_event(Request::new(request))
681-
.await?
682-
.into_inner();
683-
Ok(())
684-
}
685-
686686
async fn get_secret(&mut self, request: GetSecretRequest) -> Result<GetSecretResponse, Error> {
687687
Ok(self.get_secret(Request::new(request)).await?.into_inner())
688688
}
@@ -701,6 +701,11 @@ impl DaprInterface for dapr_v1::dapr_client::DaprClient<TonicChannel> {
701701
Ok(self.get_state(Request::new(request)).await?.into_inner())
702702
}
703703

704+
async fn save_state(&mut self, request: SaveStateRequest) -> Result<(), Error> {
705+
self.save_state(Request::new(request)).await?.into_inner();
706+
Ok(())
707+
}
708+
704709
async fn query_state_alpha1(
705710
&mut self,
706711
request: QueryStateRequest,
@@ -711,11 +716,6 @@ impl DaprInterface for dapr_v1::dapr_client::DaprClient<TonicChannel> {
711716
.into_inner())
712717
}
713718

714-
async fn save_state(&mut self, request: SaveStateRequest) -> Result<(), Error> {
715-
self.save_state(Request::new(request)).await?.into_inner();
716-
Ok(())
717-
}
718-
719719
async fn delete_state(&mut self, request: DeleteStateRequest) -> Result<(), Error> {
720720
self.delete_state(Request::new(request)).await?.into_inner();
721721
Ok(())

examples/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ rust-version.workspace = true
1010

1111
[dependencies]
1212
async-trait = { workspace = true }
13-
base64 = "0.22"
1413
dapr = { path = "../dapr" }
1514
dapr-macros = { path = "../dapr-macros" }
1615
env_logger = "0.11"

examples/src/actors/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub struct MyRequest {
1414
async fn main() -> Result<(), Box<dyn std::error::Error>> {
1515
// TODO: Handle this issue in the sdk
1616
// Introduce delay so that dapr grpc port is assigned before app tries to connect
17-
std::thread::sleep(std::time::Duration::new(2, 0));
17+
tokio::time::sleep(std::time::Duration::new(2, 0)).await;
1818

1919
// Define the Dapr address
2020
let addr = "https://127.0.0.1".to_string();

examples/src/bindings/input.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl AppCallback for AppCallbackService {
6161
let name = &r.name;
6262
let data = &r.data;
6363

64-
let message = String::from_utf8_lossy(&data);
64+
let message = String::from_utf8_lossy(data);
6565
println!("Binding Name: {}", &name);
6666
println!("Message: {}", &message);
6767

examples/src/bindings/output.rs

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

33
#[tokio::main]
44
async fn main() -> Result<(), Box<dyn std::error::Error>> {
55
// TODO: Handle this issue in the sdk
66
// Introduce delay so that dapr grpc port is assigned before app tries to connect
7-
thread::sleep(Duration::from_secs(2));
7+
tokio::time::sleep(Duration::from_secs(2)).await;
88

99
// Get the Dapr port and create a connection
1010
let addr = "https://127.0.0.1".to_string();

examples/src/client/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
async fn main() -> Result<(), Box<dyn std::error::Error>> {
33
// TODO: Handle this issue in the sdk
44
// Introduce delay so that dapr grpc port is assigned before app tries to connect
5-
std::thread::sleep(std::time::Duration::new(2, 0));
5+
tokio::time::sleep(std::time::Duration::new(2, 0)).await;
66

77
// Set the Dapr address
88
let addr = "https://127.0.0.1".to_string();

examples/src/configuration/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ type DaprClient = dapr::Client<dapr::client::TonicClient>;
77
async fn main() -> Result<(), Box<dyn std::error::Error>> {
88
// TODO: Handle this issue in the sdk
99
// Introduce delay so that dapr grpc port is assigned before app tries to connect
10-
std::thread::sleep(std::time::Duration::new(2, 0));
10+
tokio::time::sleep(std::time::Duration::new(2, 0)).await;
1111

1212
// Set the Dapr address
1313
let addr = "https://127.0.0.1".to_string();
@@ -19,14 +19,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
1919

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

2727
// Subscribe for configuration changes
2828
let mut stream = client
29-
.subscribe_configuration(CONFIGSTORE_NAME, vec![(&key)], None)
29+
.subscribe_configuration(CONFIGSTORE_NAME, vec![&key], None)
3030
.await?;
3131

3232
let mut subscription_id = String::new();

examples/src/conversation/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
use dapr::client::{ConversationInputBuilder, ConversationRequestBuilder};
2-
use std::thread;
32
use std::time::Duration;
43

54
type DaprClient = dapr::Client<dapr::client::TonicClient>;
65

76
#[tokio::main]
87
async fn main() -> Result<(), Box<dyn std::error::Error>> {
98
// Sleep to allow for the server to become available
10-
thread::sleep(Duration::from_secs(5));
9+
tokio::time::sleep(Duration::from_secs(5)).await;
1110

1211
// Set the Dapr address
1312
let address = "https://127.0.0.1".to_string();

examples/src/invoke/grpc-proxying/client.rs

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

33
use hello_world::{greeter_client::GreeterClient, HelloRequest};
44

@@ -11,7 +11,7 @@ pub mod hello_world {
1111
#[tokio::main]
1212
async fn main() -> Result<(), Box<dyn std::error::Error>> {
1313
// Sleep to allow for the server to become available
14-
thread::sleep(Duration::from_secs(5));
14+
tokio::time::sleep(Duration::from_secs(5)).await;
1515

1616
// Get the Dapr port and create a connection
1717
let port: u16 = std::env::var("DAPR_GRPC_PORT").unwrap().parse().unwrap();

examples/src/invoke/grpc/client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::hello_world::HelloReply;
2-
use std::{thread, time::Duration};
2+
use std::time::Duration;
33

44
use prost::Message;
55

@@ -12,7 +12,7 @@ type DaprClient = dapr::Client<dapr::client::TonicClient>;
1212
#[tokio::main]
1313
async fn main() -> Result<(), Box<dyn std::error::Error>> {
1414
// Sleep to allow for the server to become available
15-
thread::sleep(Duration::from_secs(5));
15+
tokio::time::sleep(Duration::from_secs(5)).await;
1616

1717
// Set the Dapr address
1818
let address = "https://127.0.0.1".to_string();

examples/src/pubsub/publisher.rs

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

33
use tokio::time;
44

@@ -21,7 +21,7 @@ struct Refund {
2121
async fn main() -> Result<(), Box<dyn std::error::Error>> {
2222
// TODO: Handle this issue in the sdk
2323
// Introduce delay so that dapr grpc port is assigned before app tries to connect
24-
thread::sleep(Duration::from_secs(2));
24+
tokio::time::sleep(Duration::from_secs(2)).await;
2525

2626
// Set address for Dapr connection
2727
let addr = "https://127.0.0.1".to_string();

examples/src/query_state/query1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use serde_json::json;
33
#[tokio::main]
44
async fn main() -> Result<(), Box<dyn std::error::Error>> {
55
// Introduce delay so that dapr grpc port is assigned before app tries to connect
6-
std::thread::sleep(std::time::Duration::new(5, 0));
6+
tokio::time::sleep(std::time::Duration::new(5, 0)).await;
77

88
// Set the Dapr address and create a connection
99
let addr = "https://127.0.0.1".to_string();

examples/src/query_state/query2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use serde_json::json;
33
#[tokio::main]
44
async fn main() -> Result<(), Box<dyn std::error::Error>> {
55
// Introduce delay so that dapr grpc port is assigned before app tries to connect
6-
std::thread::sleep(std::time::Duration::new(5, 0));
6+
tokio::time::sleep(std::time::Duration::new(5, 0)).await;
77

88
// Set the Dapr address and create a connection
99
let addr = "https://127.0.0.1".to_string();

0 commit comments

Comments
 (0)