diff --git a/CHANGELOG.md b/CHANGELOG.md index 7eee6a0..eed81e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Dynamic introspection API. +### Changed + +- Send Empty parameter instead of Node in the detach rpc. + ## [0.6.2] - 2024-04-23 ### Changed diff --git a/proto/astarteplatform/msghub/message_hub_service.proto b/proto/astarteplatform/msghub/message_hub_service.proto index 202e9f3..75a9541 100644 --- a/proto/astarteplatform/msghub/message_hub_service.proto +++ b/proto/astarteplatform/msghub/message_hub_service.proto @@ -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. */ diff --git a/proto/astarteplatform/msghub/node.proto b/proto/astarteplatform/msghub/node.proto index ed2b6a4..bcd706b 100644 --- a/proto/astarteplatform/msghub/node.proto +++ b/proto/astarteplatform/msghub/node.proto @@ -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. repeated string interfaces_json = 2; // Array of string representing all .json interface files of the node. diff --git a/python/astarteplatform/msghub/message_hub_service_pb2.py b/python/astarteplatform/msghub/message_hub_service_pb2.py index 31f1eeb..59da6a9 100644 --- a/python/astarteplatform/msghub/message_hub_service_pb2.py +++ b/python/astarteplatform/msghub/message_hub_service_pb2.py @@ -19,7 +19,7 @@ from astarteplatform.msghub import interface_pb2 as astarteplatform_dot_msghub_dot_interface__pb2 -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n0astarteplatform/msghub/message_hub_service.proto\x12\x16\x61starteplatform.msghub\x1a\x1bgoogle/protobuf/empty.proto\x1a,astarteplatform/msghub/astarte_message.proto\x1a)astarteplatform/msghub/astarte_type.proto\x1a!astarteplatform/msghub/node.proto\x1a&astarteplatform/msghub/interface.proto2\x95\x03\n\nMessageHub\x12R\n\x06\x41ttach\x12\x1c.astarteplatform.msghub.Node\x1a&.astarteplatform.msghub.AstarteMessage\"\x00\x30\x01\x12H\n\x04Send\x12&.astarteplatform.msghub.AstarteMessage\x1a\x16.google.protobuf.Empty\"\x00\x12@\n\x06\x44\x65tach\x12\x1c.astarteplatform.msghub.Node\x1a\x16.google.protobuf.Empty\"\x00\x12Q\n\rAddInterfaces\x12&.astarteplatform.msghub.InterfacesJson\x1a\x16.google.protobuf.Empty\"\x00\x12T\n\x10RemoveInterfaces\x12&.astarteplatform.msghub.InterfacesName\x1a\x16.google.protobuf.Empty\"\x00\x62\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n0astarteplatform/msghub/message_hub_service.proto\x12\x16\x61starteplatform.msghub\x1a\x1bgoogle/protobuf/empty.proto\x1a,astarteplatform/msghub/astarte_message.proto\x1a)astarteplatform/msghub/astarte_type.proto\x1a!astarteplatform/msghub/node.proto\x1a&astarteplatform/msghub/interface.proto2\x8f\x03\n\nMessageHub\x12R\n\x06\x41ttach\x12\x1c.astarteplatform.msghub.Node\x1a&.astarteplatform.msghub.AstarteMessage\"\x00\x30\x01\x12H\n\x04Send\x12&.astarteplatform.msghub.AstarteMessage\x1a\x16.google.protobuf.Empty\"\x00\x12:\n\x06\x44\x65tach\x12\x16.google.protobuf.Empty\x1a\x16.google.protobuf.Empty\"\x00\x12Q\n\rAddInterfaces\x12&.astarteplatform.msghub.InterfacesJson\x1a\x16.google.protobuf.Empty\"\x00\x12T\n\x10RemoveInterfaces\x12&.astarteplatform.msghub.InterfacesName\x1a\x16.google.protobuf.Empty\"\x00\x62\x06proto3') _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) @@ -27,5 +27,5 @@ if not _descriptor._USE_C_DESCRIPTORS: DESCRIPTOR._loaded_options = None _globals['_MESSAGEHUB']._serialized_start=270 - _globals['_MESSAGEHUB']._serialized_end=675 + _globals['_MESSAGEHUB']._serialized_end=669 # @@protoc_insertion_point(module_scope) diff --git a/python/astarteplatform/msghub/message_hub_service_pb2_grpc.py b/python/astarteplatform/msghub/message_hub_service_pb2_grpc.py index 096ea7a..d76ecea 100644 --- a/python/astarteplatform/msghub/message_hub_service_pb2_grpc.py +++ b/python/astarteplatform/msghub/message_hub_service_pb2_grpc.py @@ -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( @@ -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( @@ -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) diff --git a/rust/astarte-message-hub-proto/README.md b/rust/astarte-message-hub-proto/README.md index c1bc6bc..fdf45ad 100644 --- a/rust/astarte-message-hub-proto/README.md +++ b/rust/astarte-message-hub-proto/README.md @@ -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; @@ -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); diff --git a/rust/astarte-message-hub-proto/src/astarteplatform.msghub.rs b/rust/astarte-message-hub-proto/src/astarteplatform.msghub.rs index 0e5e40c..facea89 100644 --- a/rust/astarte-message-hub-proto/src/astarteplatform.msghub.rs +++ b/rust/astarte-message-hub-proto/src/astarteplatform.msghub.rs @@ -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 { @@ -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, + request: impl tonic::IntoRequest<::pbjson_types::Empty>, ) -> std::result::Result, tonic::Status> { self.inner .ready() @@ -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, + request: tonic::Request<::pbjson_types::Empty>, ) -> std::result::Result, 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( @@ -624,7 +624,9 @@ pub mod message_hub_server { "/astarteplatform.msghub.MessageHub/Detach" => { #[allow(non_camel_case_types)] struct DetachSvc(pub Arc); - impl tonic::server::UnaryService + impl< + T: MessageHub, + > tonic::server::UnaryService<::pbjson_types::Empty> for DetachSvc { type Response = ::pbjson_types::Empty; type Future = BoxFuture< @@ -633,7 +635,7 @@ pub mod message_hub_server { >; fn call( &mut self, - request: tonic::Request, + request: tonic::Request<::pbjson_types::Empty>, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move {