Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(detach): pass Empty rather than Node to detach rpc #54

Merged
merged 2 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion proto/astarteplatform/msghub/message_hub_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ service MessageHub {
/* This function should be used to send an `AstarteMessage` to Astarte. */
rpc Send(AstarteMessage) returns (google.protobuf.Empty){}
/* This function should be used to detach a node from an instance of the Astarte message hub. */
rpc Detach(Node) returns (google.protobuf.Empty){}
rpc Detach(google.protobuf.Empty) returns (google.protobuf.Empty){}
/* This function should be used to add one or more interfaces to an instance of the Astarte message hub. */
rpc AddInterfaces(InterfacesJson) returns (google.protobuf.Empty){}
/* This function should be used to remove one or more interfaces from an instance of the Astarte message hub. */
Expand Down
2 changes: 1 addition & 1 deletion proto/astarteplatform/msghub/node.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import "astarteplatform/msghub/interface.proto";

package astarteplatform.msghub;

/* This message defines a node to be attached/detached to the Astarte message hub. */
/* This message defines a node to be attached to the Astarte message hub. */
message Node {
string uuid = 1; // The node identifier.
harlem88 marked this conversation as resolved.
Show resolved Hide resolved
repeated string interfaces_json = 2; // Array of string representing all .json interface files of the node.
Expand Down
4 changes: 2 additions & 2 deletions python/astarteplatform/msghub/message_hub_service_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions python/astarteplatform/msghub/message_hub_service_pb2_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self, channel):
)
self.Detach = channel.unary_unary(
'/astarteplatform.msghub.MessageHub/Detach',
request_serializer=astarteplatform_dot_msghub_dot_node__pb2.Node.SerializeToString,
request_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString,
response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString,
)
self.AddInterfaces = channel.unary_unary(
Expand Down Expand Up @@ -98,7 +98,7 @@ def add_MessageHubServicer_to_server(servicer, server):
),
'Detach': grpc.unary_unary_rpc_method_handler(
servicer.Detach,
request_deserializer=astarteplatform_dot_msghub_dot_node__pb2.Node.FromString,
request_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString,
response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString,
),
'AddInterfaces': grpc.unary_unary_rpc_method_handler(
Expand Down Expand Up @@ -167,7 +167,7 @@ def Detach(request,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/astarteplatform.msghub.MessageHub/Detach',
astarteplatform_dot_msghub_dot_node__pb2.Node.SerializeToString,
google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString,
google_dot_protobuf_dot_empty__pb2.Empty.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
Expand Down
3 changes: 2 additions & 1 deletion rust/astarte-message-hub-proto/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use astarte_message_hub_proto::astarte_message::Payload;
use astarte_message_hub_proto::message_hub_client::MessageHubClient;
use astarte_message_hub_proto::AstarteMessage;
use astarte_message_hub_proto::Node;
use astarte_message_hub_proto::pbjson_types::Empty;
use log::info;
use uuid::Uuid;

Expand Down Expand Up @@ -117,7 +118,7 @@ async fn run_example_client() {
}

info!("Done sending messages, closing the connection.");
client.detach(node).await.expect("Detach failed");
client.detach(Empty {}).await.expect("Detach failed");
});

let res = tokio::join!(reply_handle, send_handle);
Expand Down
12 changes: 7 additions & 5 deletions rust/astarte-message-hub-proto/src/astarteplatform.msghub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ pub struct InterfacesName {
#[prost(string, repeated, tag = "1")]
pub names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
/// This message defines a node to be attached/detached to the Astarte message hub.
/// This message defines a node to be attached to the Astarte message hub.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Node {
Expand Down Expand Up @@ -335,7 +335,7 @@ pub mod message_hub_client {
/// This function should be used to detach a node from an instance of the Astarte message hub.
pub async fn detach(
&mut self,
request: impl tonic::IntoRequest<super::Node>,
request: impl tonic::IntoRequest<::pbjson_types::Empty>,
) -> std::result::Result<tonic::Response<::pbjson_types::Empty>, tonic::Status> {
self.inner
.ready()
Expand Down Expand Up @@ -437,7 +437,7 @@ pub mod message_hub_server {
/// This function should be used to detach a node from an instance of the Astarte message hub.
async fn detach(
&self,
request: tonic::Request<super::Node>,
request: tonic::Request<::pbjson_types::Empty>,
) -> std::result::Result<tonic::Response<::pbjson_types::Empty>, tonic::Status>;
/// This function should be used to add one or more interfaces to an instance of the Astarte message hub.
async fn add_interfaces(
Expand Down Expand Up @@ -624,7 +624,9 @@ pub mod message_hub_server {
"/astarteplatform.msghub.MessageHub/Detach" => {
#[allow(non_camel_case_types)]
struct DetachSvc<T: MessageHub>(pub Arc<T>);
impl<T: MessageHub> tonic::server::UnaryService<super::Node>
impl<
T: MessageHub,
> tonic::server::UnaryService<::pbjson_types::Empty>
for DetachSvc<T> {
type Response = ::pbjson_types::Empty;
type Future = BoxFuture<
Expand All @@ -633,7 +635,7 @@ pub mod message_hub_server {
>;
fn call(
&mut self,
request: tonic::Request<super::Node>,
request: tonic::Request<::pbjson_types::Empty>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
Expand Down
Loading