You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@eventmesh.apache.org by "mxsm (via GitHub)" <gi...@apache.org> on 2023/03/23 03:10:48 UTC
[GitHub] [incubator-eventmesh] mxsm commented on issue #3485: [WIP][Enhancement] Optimize Grpc protocol for Java
mxsm commented on issue #3485:
URL: https://github.com/apache/incubator-eventmesh/issues/3485#issuecomment-1480542198
SDK publish message to runtime flow:
![image](https://user-images.githubusercontent.com/15797831/227090302-710afdae-daf5-4218-8d4b-70463c649e22.png)
SimpleMessage will discard and replace with CloudEvent of EventMesh customed.
proto as follows:
eventmesh-cloudevents.proto
```
syntax = "proto3";
package eventmesh.common.protocol.grpc.v1;
import "google/protobuf/any.proto";
import "google/protobuf/timestamp.proto";
option java_package = "org.apache.eventmesh.common.protocol.grpc.cloudevents";
option java_multiple_files = true;
option java_outer_classname = "EventMeshCloudevents";
message CloudEvent {
// -- CloudEvent Context Attributes
// Required Attributes
string id = 1;
string source = 2; // URI-reference
string spec_version = 3;
string type = 4;
// Optional & Extension Attributes
map<string, CloudEventAttributeValue> attributes = 5;
// -- CloudEvent Data (Bytes, Text, or Proto)
oneof data {
bytes binary_data = 6;
string text_data = 7;
google.protobuf.Any proto_data = 8;
}
/**
* The CloudEvent specification defines
* seven attribute value types...
*/
message CloudEventAttributeValue {
oneof attr {
bool ce_boolean = 1;
int32 ce_integer = 2;
string ce_string = 3;
bytes ce_bytes = 4;
string ce_uri = 5;
string ce_uri_ref = 6;
google.protobuf.Timestamp ce_timestamp = 7;
}
}
}
/**
* CloudEvent Protobuf Batch Format
*
*/
message CloudEventBatch {
repeated CloudEvent events = 1;
}
```
eventmesh-service.proto
```
syntax = "proto3";
package eventmesh.common.protocol.grpc.v1;
import "google/protobuf/empty.proto";
import "eventmesh-cloudevents.proto";
option java_package = "org.apache.eventmesh.common.protocol.grpc.cloudevents";
option java_multiple_files = true;
option java_outer_classname = "EventMeshGrpcService";
service PublisherService {
//publish event
rpc publish(CloudEvent) returns (CloudEvent);
//publish event no reply
rpc publishNoReply(CloudEvent) returns (google.protobuf.Empty);
// publish batch event
rpc batchPublish(CloudEventBatch) returns (CloudEvent);
//publish batch event no reply
rpc batchPublishNoReply(CloudEventBatch) returns (google.protobuf.Empty);
}
service ConsumerService {
// The subscribed event will be delivered by invoking the webhook url in the Subscription
rpc subscribe(CloudEvent) returns (CloudEvent);
// The subscribed event will be delivered through stream of Message
rpc subscribeStream(stream CloudEvent) returns (stream CloudEvent);
rpc unsubscribe(CloudEvent) returns (CloudEvent);
}
service HeartbeatService {
rpc heartbeat(CloudEvent) returns (CloudEvent);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org