What language does this apply to?
If it's for proto2, proto3, or an edition? Any
If it's a generated code change, what programming language? NA
Describe the problem you are trying to solve.
Define event streaming schemas based on protobufs.
Describe the solution you'd like
Add something like an event keyword that would behave similarly to rpc. Something like:
service UserService {
rpc GetUser(GetUserRequest) returns (User);
rpc ListUsers(ListUsersRequest) returns (ListUsersResponse);
rpc CreateUser(CreateUserRequest) returns (User);
rpc UpdateUser(UpdateUserRequest) returns (User);
rpc DeleteUser(DeleteUserRequest) returns (google.protobuf.Empty);
event CreatedUser User;
event UpdatedUser User;
event DeletedUser DeletedUserEvent;
}
This would enable defining options for the events as will, something like a google.api.http but for events enabling the topic/stream to be defined.
Describe alternatives you've considered
- Utilizing a "Events" message
The example above would look something like this:
message UserEvents {
oneof events {
User created = 1;
User updated = 2;
DeletedUserEvent deleted = 3;
}
}
This works, but creates some annoyances when working with linters and is fully dependent on naming schemes.
- Use service and rpc
Use existing service and rpc ideas
service UserService {
rpc GetUser(GetUserRequest) returns (User);
rpc ListUsers(ListUsersRequest) returns (ListUsersResponse);
rpc CreateUser(CreateUserRequest) returns (User);
rpc UpdateUser(UpdateUserRequest) returns (User);
rpc DeleteUser(DeleteUserRequest) returns (google.protobuf.Empty);
rpc CreatedUserEvent(google.protobuf.Empty) returns (User);
rpc UpdatedUserEvent(google.protobuf.Empty) returns (User);
rpc DeletedUserEvent(google.protobuf.Empty) returns (DeletedUserEvent);
}
This has more issues than (1) since protoc tools will treat these events as methods (since they are) and you have the same linter and naming scheme issues from (1).
**Additional context**
Add any other context or screenshots about the feature request here.
What language does this apply to?
If it's for proto2, proto3, or an edition?
AnyIf it's a generated code change, what programming language?
NADescribe the problem you are trying to solve.
Define event streaming schemas based on protobufs.
Describe the solution you'd like
Add something like an
eventkeyword that would behave similarly torpc. Something like:This would enable defining options for the events as will, something like a
google.api.httpbut for events enabling the topic/stream to be defined.Describe alternatives you've considered
The example above would look something like this:
This works, but creates some annoyances when working with linters and is fully dependent on naming schemes.
Use existing service and rpc ideas