-
Notifications
You must be signed in to change notification settings - Fork 642
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
[Enhancement] Optimize Grpc protocol for Java #3485
Comments
1. BackgroundThe current data exchange of EventMesh's GRPC protocol uses EventMesh's custom SimpleMessage protocol. To better support the CloudEvents specification, the SimpleMessage protocol is being modified to use CloudEvents-provided Protobuf format protocol. 2. ArchitectureSimpleMessage is mainly used for data exchange between the GRPC SDK and the runtime. A new EventMesh CloudEvent protocol (fully compatible with the CloudEvents specification) will be defined to replace SimpleMessage.
By replacing the SimpleMessage protocol with the redefined EventMesh CloudEvent protocol, it will better implement the CloudEvents specification.
3. How to transform3.1 Transformation of data protocoldefinition of data protocol: syntax = "proto3";
package org.apache.eventmesh.cloudevents.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;
} The defined data protocol is completely identical to the CloudEvents 1.0.2 specification. 3.2 Service protocol transformationsyntax = "proto3";
package org.apache.eventmesh.cloudevents.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 with reply
rpc publishReply(CloudEvent) returns (CloudEvent);
//publish event one way
rpc publishOneWay(CloudEvent) returns (google.protobuf.Empty);
// publish batch event
rpc batchPublish(CloudEventBatch) returns (CloudEvent);
//publish batch event one way
rpc batchPublishOneWay(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);
} 3.3 SDK upgrade and transformation
3.4 Runtime GRPC upgrade and transformation
4. Compatibility issues
|
* add cloudevent proto file * generate cloudevents java class * develop cloudevents for sdk * upgrade cloudevents version to 2.4.2 * develop cloudevents for runtime module * add test case * fix test case * fix test case * optimize logic * remove custom simplemessage class
* add cloudevent proto file * generate cloudevents java class * develop cloudevents for sdk * upgrade cloudevents version to 2.4.2 * develop cloudevents for runtime module * add test case * fix test case * fix test case * optimize logic * remove custom simplemessage class
Search before asking
Enhancement Request
Optimize Grpc protocol
Describe the solution you'd like
Optimize Grpc protocol, replace SimpleMessage with CloudEvent
Are you willing to submit PR?
The text was updated successfully, but these errors were encountered: