Skip to content

Commit

Permalink
[ISSUE apache#4625]fix grpc request reply can not work
Browse files Browse the repository at this point in the history
  • Loading branch information
mxsm committed Dec 7, 2023
1 parent 8c59c7f commit e84412f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions eventmesh-sdks/eventmesh-sdk-rust/src/common/protocol_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ impl ProtocolKey {
pub const GRPC_RESPONSE_MESSAGE: &'static str = "response_message";
pub const GRPC_RESPONSE_TIME: &'static str = "time";

pub const SUB_MESSAGE_TYPE: &'static str = "submessagetype";

// CloudEvents spec
pub const ID: &'static str = "id";
pub const SOURCE: &'static str = "source";
Expand Down
8 changes: 8 additions & 0 deletions eventmesh-sdks/eventmesh-sdk-rust/src/grpc/grpc_consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ impl EventMeshGrpcConsumer {
None,
properties,
);
received.attributes.insert(
ProtocolKey::SUB_MESSAGE_TYPE.to_string(),
PbCloudEventAttributeValue {
attr: Some(PbAttr::CeString(
SubscriptionReply::SUB_TYPE.to_string(),
)),
},
);
received.data =
Some(PbData::TextData(serde_json::to_string(&reply).unwrap()));
let _ = keeper.sender.send(received).await;
Expand Down
6 changes: 3 additions & 3 deletions eventmesh-sdks/eventmesh-sdk-rust/src/model/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

#![cfg(feature = "eventmesh_message")]

#[allow(unused_imports)]
use cloudevents::Event;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fmt;
use std::time::{SystemTime, UNIX_EPOCH};

use cloudevents::Event;
use serde::{Deserialize, Serialize};

use crate::common::grpc_eventmesh_message_utils::EventMeshCloudEventUtils;
use crate::model::convert::FromPbCloudEvent;
use crate::proto_cloud_event::PbCloudEvent;
Expand Down
2 changes: 2 additions & 0 deletions eventmesh-sdks/eventmesh-sdk-rust/src/model/subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ pub struct SubscriptionReply {
}

impl SubscriptionReply {
pub const SUB_TYPE: &'static str = "subscription_reply";

pub fn new(
producer_group: String,
topic: String,
Expand Down
2 changes: 1 addition & 1 deletion eventmesh-sdks/eventmesh-sdk-rust/src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#![allow(unused_imports)]
pub use crate::net::grpc::grpc_client::GrpcClient;
pub use crate::net::grpc::grpc_client::SubscribeStreamKeeper;
mod grpc;

0 comments on commit e84412f

Please sign in to comment.