Skip to content

Commit a1000ed

Browse files
committed
fix: cleanup proto inception
1 parent 2c0aa5a commit a1000ed

File tree

5 files changed

+53
-50
lines changed

5 files changed

+53
-50
lines changed

dapr/src/appcallback.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
use crate::dapr;
2-
use crate::dapr::proto::runtime::v1::app_callback_server::AppCallback;
3-
use crate::dapr::proto::{common, runtime};
41
use std::collections::HashMap;
2+
53
use tonic::{Code, Request, Response, Status};
64

5+
use crate::proto::{common, runtime, runtime::v1::app_callback_server::AppCallback};
6+
77
/// InvokeRequest is the message to invoke a method with the data.
8-
pub type InvokeRequest = dapr::proto::common::v1::InvokeRequest;
8+
pub type InvokeRequest = common::v1::InvokeRequest;
99

1010
/// InvokeResponse is the response message inclduing data and its content type
1111
/// from app callback.
12-
pub type InvokeResponse = dapr::proto::common::v1::InvokeResponse;
12+
pub type InvokeResponse = common::v1::InvokeResponse;
1313

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

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

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

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

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

2929
/// BindingEventRequest represents input bindings event.
30-
pub type BindingEventRequest = dapr::proto::runtime::v1::BindingEventRequest;
30+
pub type BindingEventRequest = runtime::v1::BindingEventRequest;
3131

3232
/// BindingEventResponse includes operations to save state or
3333
/// send data to output bindings optionally.
34-
pub type BindingEventResponse = dapr::proto::runtime::v1::BindingEventResponse;
34+
pub type BindingEventResponse = runtime::v1::BindingEventResponse;
3535

3636
impl ListTopicSubscriptionsResponse {
3737
/// Create `ListTopicSubscriptionsResponse` with a topic.

dapr/src/client.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use tonic::codegen::tokio_stream;
1010
use tonic::{transport::Channel as TonicChannel, Request};
1111
use tonic::{Status, Streaming};
1212

13-
use crate::dapr::proto::{common::v1 as common_v1, runtime::v1 as dapr_v1};
13+
use crate::proto::{common::v1 as common_v1, runtime::v1 as dapr_v1};
1414
use crate::error::Error;
1515

1616
#[derive(Clone)]
@@ -603,6 +603,13 @@ impl DaprInterface for dapr_v1::dapr_client::DaprClient<TonicChannel> {
603603
Ok(dapr_v1::dapr_client::DaprClient::connect(addr).await?)
604604
}
605605

606+
async fn publish_event(&mut self, request: PublishEventRequest) -> Result<(), Error> {
607+
self.publish_event(Request::new(request))
608+
.await?
609+
.into_inner();
610+
Ok(())
611+
}
612+
606613
async fn invoke_service(
607614
&mut self,
608615
request: InvokeServiceRequest,
@@ -623,13 +630,6 @@ impl DaprInterface for dapr_v1::dapr_client::DaprClient<TonicChannel> {
623630
.into_inner())
624631
}
625632

626-
async fn publish_event(&mut self, request: PublishEventRequest) -> Result<(), Error> {
627-
self.publish_event(Request::new(request))
628-
.await?
629-
.into_inner();
630-
Ok(())
631-
}
632-
633633
async fn get_secret(&mut self, request: GetSecretRequest) -> Result<GetSecretResponse, Error> {
634634
Ok(self.get_secret(Request::new(request)).await?.into_inner())
635635
}
@@ -648,6 +648,11 @@ impl DaprInterface for dapr_v1::dapr_client::DaprClient<TonicChannel> {
648648
Ok(self.get_state(Request::new(request)).await?.into_inner())
649649
}
650650

651+
async fn save_state(&mut self, request: SaveStateRequest) -> Result<(), Error> {
652+
self.save_state(Request::new(request)).await?.into_inner();
653+
Ok(())
654+
}
655+
651656
async fn query_state_alpha1(
652657
&mut self,
653658
request: QueryStateRequest,
@@ -658,11 +663,6 @@ impl DaprInterface for dapr_v1::dapr_client::DaprClient<TonicChannel> {
658663
.into_inner())
659664
}
660665

661-
async fn save_state(&mut self, request: SaveStateRequest) -> Result<(), Error> {
662-
self.save_state(Request::new(request)).await?.into_inner();
663-
Ok(())
664-
}
665-
666666
async fn delete_state(&mut self, request: DeleteStateRequest) -> Result<(), Error> {
667667
self.delete_state(Request::new(request)).await?.into_inner();
668668
Ok(())
@@ -875,39 +875,39 @@ pub type UnsubscribeConfigurationResponse = dapr_v1::UnsubscribeConfigurationRes
875875
pub type TonicClient = dapr_v1::dapr_client::DaprClient<TonicChannel>;
876876

877877
/// Encryption gRPC request
878-
pub type EncryptRequest = crate::dapr::proto::runtime::v1::EncryptRequest;
878+
pub type EncryptRequest = crate::proto::runtime::v1::EncryptRequest;
879879

880880
/// Decrypt gRPC request
881-
pub type DecryptRequest = crate::dapr::proto::runtime::v1::DecryptRequest;
881+
pub type DecryptRequest = crate::proto::runtime::v1::DecryptRequest;
882882

883883
/// Encryption request options
884-
pub type EncryptRequestOptions = crate::dapr::proto::runtime::v1::EncryptRequestOptions;
884+
pub type EncryptRequestOptions = crate::proto::runtime::v1::EncryptRequestOptions;
885885

886886
/// Decryption request options
887-
pub type DecryptRequestOptions = crate::dapr::proto::runtime::v1::DecryptRequestOptions;
887+
pub type DecryptRequestOptions = crate::proto::runtime::v1::DecryptRequestOptions;
888888

889889
/// The basic job structure
890-
pub type Job = crate::dapr::proto::runtime::v1::Job;
890+
pub type Job = crate::proto::runtime::v1::Job;
891891

892892
/// A request to schedule a job
893-
pub type ScheduleJobRequest = crate::dapr::proto::runtime::v1::ScheduleJobRequest;
893+
pub type ScheduleJobRequest = crate::proto::runtime::v1::ScheduleJobRequest;
894894

895895
/// A response from a schedule job request
896-
pub type ScheduleJobResponse = crate::dapr::proto::runtime::v1::ScheduleJobResponse;
896+
pub type ScheduleJobResponse = crate::proto::runtime::v1::ScheduleJobResponse;
897897

898898
/// A request to get a job
899-
pub type GetJobRequest = crate::dapr::proto::runtime::v1::GetJobRequest;
899+
pub type GetJobRequest = crate::proto::runtime::v1::GetJobRequest;
900900

901901
/// A response from a get job request
902-
pub type GetJobResponse = crate::dapr::proto::runtime::v1::GetJobResponse;
902+
pub type GetJobResponse = crate::proto::runtime::v1::GetJobResponse;
903903

904904
/// A request to delete a job
905-
pub type DeleteJobRequest = crate::dapr::proto::runtime::v1::DeleteJobRequest;
905+
pub type DeleteJobRequest = crate::proto::runtime::v1::DeleteJobRequest;
906906

907907
/// A response from a delete job request
908-
pub type DeleteJobResponse = crate::dapr::proto::runtime::v1::DeleteJobResponse;
908+
pub type DeleteJobResponse = crate::proto::runtime::v1::DeleteJobResponse;
909909

910-
type StreamPayload = crate::dapr::proto::common::v1::StreamPayload;
910+
type StreamPayload = crate::proto::common::v1::StreamPayload;
911911
impl<K> From<(K, Vec<u8>)> for common_v1::StateItem
912912
where
913913
K: Into<String>,

dapr/src/lib.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,20 @@ pub mod appcallback;
1313
/// Module containing the 'Client' implementation.
1414
pub mod client;
1515
/// Module importing the Dapr runtime implementation.
16-
pub mod dapr {
17-
pub mod proto {
18-
pub mod common {
19-
pub mod v1 {
20-
include!("dapr/dapr.proto.common.v1.rs");
21-
}
16+
pub mod proto {
17+
/// Module containing the common implementations.
18+
19+
pub mod common {
20+
/// Module containing the v1 implementations.
21+
pub mod v1 {
22+
include!("dapr/dapr.proto.common.v1.rs");
2223
}
23-
pub mod runtime {
24-
pub mod v1 {
25-
include!("dapr/dapr.proto.runtime.v1.rs");
26-
}
24+
}
25+
/// Module containing the runtime implementations.
26+
pub mod runtime {
27+
/// Module containing the v1 implementations.
28+
pub mod v1 {
29+
include!("dapr/dapr.proto.runtime.v1.rs");
2730
}
2831
}
2932
}

dapr/src/server/actor/context_client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::client::TonicClient;
2-
use crate::dapr::proto::runtime::v1 as dapr_v1;
2+
use crate::proto::runtime::v1 as dapr_v1;
33
use crate::error::Error as DaprError;
44
use prost_types::Any;
55
use std::collections::HashMap;

dapr/src/server/appcallbackalpha.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use std::collections::HashMap;
22

33
use tonic::{Code, Request, Response, Status};
44

5-
use crate::dapr::proto::runtime;
6-
use crate::dapr::proto::runtime::v1::app_callback_alpha_server::AppCallbackAlpha;
5+
use crate::proto::runtime;
6+
use crate::proto::runtime::v1::app_callback_alpha_server::AppCallbackAlpha;
77

88
pub struct AppCallbackServiceAlpha {
99
pub job_handlers: HashMap<String, Box<dyn JobHandlerMethod + Send + Sync + 'static>>,

0 commit comments

Comments
 (0)