mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-11 19:04:35 +00:00
update events
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"publish": [{
|
"publish": [{
|
||||||
"title": "Publish a message",
|
"title": "Publish an event",
|
||||||
"description": "Publish a message to a topic",
|
"description": "Publish an event to a topic",
|
||||||
"run_check": true,
|
"run_check": true,
|
||||||
"request": {
|
"request": {
|
||||||
"topic": "user",
|
"topic": "user",
|
||||||
@@ -10,9 +10,9 @@
|
|||||||
},
|
},
|
||||||
"response": {}
|
"response": {}
|
||||||
}],
|
}],
|
||||||
"subscribe": [{
|
"consume": [{
|
||||||
"title": "Subscribe to a topic",
|
"title": "Consume from a topic",
|
||||||
"description": "Subscribe to messages on a given topic",
|
"description": "Consume events from a given topic",
|
||||||
"run_check": false,
|
"run_check": false,
|
||||||
"request": {
|
"request": {
|
||||||
"topic": "user"
|
"topic": "user"
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func (s *Event) Publish(ctx context.Context, req *pb.PublishRequest, rsp *pb.Pub
|
|||||||
return events.Publish(topic, req.Message.AsMap())
|
return events.Publish(topic, req.Message.AsMap())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Event) Subscribe(ctx context.Context, req *pb.SubscribeRequest, stream pb.Event_SubscribeStream) error {
|
func (s *Event) Consume(ctx context.Context, req *pb.ConsumeRequest, stream pb.Event_ConsumeStream) error {
|
||||||
if len(req.Topic) == 0 {
|
if len(req.Topic) == 0 {
|
||||||
return errors.BadRequest("event.publish", "topic is blank")
|
return errors.BadRequest("event.publish", "topic is blank")
|
||||||
}
|
}
|
||||||
@@ -77,7 +77,7 @@ func (s *Event) Subscribe(ctx context.Context, req *pb.SubscribeRequest, stream
|
|||||||
d := &structpb.Struct{}
|
d := &structpb.Struct{}
|
||||||
d.UnmarshalJSON(msg.Payload)
|
d.UnmarshalJSON(msg.Payload)
|
||||||
|
|
||||||
if err := stream.Send(&pb.SubscribeResponse{
|
if err := stream.Send(&pb.ConsumeResponse{
|
||||||
Topic: req.Topic,
|
Topic: req.Topic,
|
||||||
Id: msg.ID,
|
Id: msg.ID,
|
||||||
Timestamp: msg.Timestamp.Format(time.RFC3339Nano),
|
Timestamp: msg.Timestamp.Format(time.RFC3339Nano),
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ func (x *Ev) GetMessage() *structpb.Struct {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Publish a message to the event stream.
|
// Publish a event to the event stream.
|
||||||
type PublishRequest struct {
|
type PublishRequest struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
@@ -183,8 +183,8 @@ func (*PublishResponse) Descriptor() ([]byte, []int) {
|
|||||||
return file_proto_event_proto_rawDescGZIP(), []int{2}
|
return file_proto_event_proto_rawDescGZIP(), []int{2}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Subscribe to messages for a given topic.
|
// Consume events from a given topic.
|
||||||
type SubscribeRequest struct {
|
type ConsumeRequest struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
@@ -197,8 +197,8 @@ type SubscribeRequest struct {
|
|||||||
Offset string `protobuf:"bytes,3,opt,name=offset,proto3" json:"offset,omitempty"`
|
Offset string `protobuf:"bytes,3,opt,name=offset,proto3" json:"offset,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *SubscribeRequest) Reset() {
|
func (x *ConsumeRequest) Reset() {
|
||||||
*x = SubscribeRequest{}
|
*x = ConsumeRequest{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_proto_event_proto_msgTypes[3]
|
mi := &file_proto_event_proto_msgTypes[3]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
@@ -206,13 +206,13 @@ func (x *SubscribeRequest) Reset() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *SubscribeRequest) String() string {
|
func (x *ConsumeRequest) String() string {
|
||||||
return protoimpl.X.MessageStringOf(x)
|
return protoimpl.X.MessageStringOf(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*SubscribeRequest) ProtoMessage() {}
|
func (*ConsumeRequest) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *SubscribeRequest) ProtoReflect() protoreflect.Message {
|
func (x *ConsumeRequest) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_proto_event_proto_msgTypes[3]
|
mi := &file_proto_event_proto_msgTypes[3]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
@@ -224,26 +224,26 @@ func (x *SubscribeRequest) ProtoReflect() protoreflect.Message {
|
|||||||
return mi.MessageOf(x)
|
return mi.MessageOf(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: Use SubscribeRequest.ProtoReflect.Descriptor instead.
|
// Deprecated: Use ConsumeRequest.ProtoReflect.Descriptor instead.
|
||||||
func (*SubscribeRequest) Descriptor() ([]byte, []int) {
|
func (*ConsumeRequest) Descriptor() ([]byte, []int) {
|
||||||
return file_proto_event_proto_rawDescGZIP(), []int{3}
|
return file_proto_event_proto_rawDescGZIP(), []int{3}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *SubscribeRequest) GetTopic() string {
|
func (x *ConsumeRequest) GetTopic() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Topic
|
return x.Topic
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *SubscribeRequest) GetGroup() string {
|
func (x *ConsumeRequest) GetGroup() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Group
|
return x.Group
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *SubscribeRequest) GetOffset() string {
|
func (x *ConsumeRequest) GetOffset() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Offset
|
return x.Offset
|
||||||
}
|
}
|
||||||
@@ -251,7 +251,7 @@ func (x *SubscribeRequest) GetOffset() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// A blocking event will be returned in response.
|
// A blocking event will be returned in response.
|
||||||
type SubscribeResponse struct {
|
type ConsumeResponse struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
@@ -266,8 +266,8 @@ type SubscribeResponse struct {
|
|||||||
Message *structpb.Struct `protobuf:"bytes,4,opt,name=message,proto3" json:"message,omitempty"`
|
Message *structpb.Struct `protobuf:"bytes,4,opt,name=message,proto3" json:"message,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *SubscribeResponse) Reset() {
|
func (x *ConsumeResponse) Reset() {
|
||||||
*x = SubscribeResponse{}
|
*x = ConsumeResponse{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_proto_event_proto_msgTypes[4]
|
mi := &file_proto_event_proto_msgTypes[4]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
@@ -275,13 +275,13 @@ func (x *SubscribeResponse) Reset() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *SubscribeResponse) String() string {
|
func (x *ConsumeResponse) String() string {
|
||||||
return protoimpl.X.MessageStringOf(x)
|
return protoimpl.X.MessageStringOf(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*SubscribeResponse) ProtoMessage() {}
|
func (*ConsumeResponse) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *SubscribeResponse) ProtoReflect() protoreflect.Message {
|
func (x *ConsumeResponse) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_proto_event_proto_msgTypes[4]
|
mi := &file_proto_event_proto_msgTypes[4]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
@@ -293,33 +293,33 @@ func (x *SubscribeResponse) ProtoReflect() protoreflect.Message {
|
|||||||
return mi.MessageOf(x)
|
return mi.MessageOf(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: Use SubscribeResponse.ProtoReflect.Descriptor instead.
|
// Deprecated: Use ConsumeResponse.ProtoReflect.Descriptor instead.
|
||||||
func (*SubscribeResponse) Descriptor() ([]byte, []int) {
|
func (*ConsumeResponse) Descriptor() ([]byte, []int) {
|
||||||
return file_proto_event_proto_rawDescGZIP(), []int{4}
|
return file_proto_event_proto_rawDescGZIP(), []int{4}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *SubscribeResponse) GetTopic() string {
|
func (x *ConsumeResponse) GetTopic() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Topic
|
return x.Topic
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *SubscribeResponse) GetId() string {
|
func (x *ConsumeResponse) GetId() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Id
|
return x.Id
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *SubscribeResponse) GetTimestamp() string {
|
func (x *ConsumeResponse) GetTimestamp() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Timestamp
|
return x.Timestamp
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *SubscribeResponse) GetMessage() *structpb.Struct {
|
func (x *ConsumeResponse) GetMessage() *structpb.Struct {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Message
|
return x.Message
|
||||||
}
|
}
|
||||||
@@ -460,43 +460,43 @@ var file_proto_event_proto_rawDesc = []byte{
|
|||||||
0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
|
0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
|
||||||
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63,
|
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63,
|
||||||
0x74, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x11, 0x0a, 0x0f, 0x50, 0x75,
|
0x74, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x11, 0x0a, 0x0f, 0x50, 0x75,
|
||||||
0x62, 0x6c, 0x69, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x56, 0x0a,
|
0x62, 0x6c, 0x69, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x54, 0x0a,
|
||||||
0x10, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
|
0x0e, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
|
||||||
0x74, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
0x14, 0x0a, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05,
|
||||||
0x52, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x12, 0x14, 0x0a, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70,
|
0x74, 0x6f, 0x70, 0x69, 0x63, 0x12, 0x14, 0x0a, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x02,
|
||||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x16, 0x0a,
|
0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x6f,
|
||||||
0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f,
|
0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x66, 0x66,
|
||||||
0x66, 0x66, 0x73, 0x65, 0x74, 0x22, 0x8a, 0x01, 0x0a, 0x11, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72,
|
0x73, 0x65, 0x74, 0x22, 0x88, 0x01, 0x0a, 0x0f, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x52,
|
||||||
0x69, 0x62, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74,
|
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63,
|
||||||
0x6f, 0x70, 0x69, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x70, 0x69,
|
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x12, 0x0e, 0x0a,
|
||||||
0x63, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69,
|
0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1c, 0x0a,
|
||||||
0x64, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03,
|
0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09,
|
||||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12,
|
0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x31, 0x0a, 0x07, 0x6d,
|
||||||
0x31, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b,
|
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67,
|
||||||
0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
|
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53,
|
||||||
0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61,
|
0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x51,
|
||||||
0x67, 0x65, 0x22, 0x51, 0x0a, 0x0b, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
|
0x0a, 0x0b, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a,
|
||||||
0x74, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f,
|
||||||
0x52, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74,
|
0x70, 0x69, 0x63, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01,
|
||||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x16, 0x0a,
|
0x28, 0x05, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66,
|
||||||
0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6f,
|
0x73, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65,
|
||||||
0x66, 0x66, 0x73, 0x65, 0x74, 0x22, 0x31, 0x0a, 0x0c, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x73,
|
0x74, 0x22, 0x31, 0x0a, 0x0c, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
|
||||||
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x21, 0x0a, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x18,
|
0x65, 0x12, 0x21, 0x0a, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28,
|
||||||
0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x45, 0x76,
|
0x0b, 0x32, 0x09, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x45, 0x76, 0x52, 0x06, 0x65, 0x76,
|
||||||
0x52, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x32, 0xba, 0x01, 0x0a, 0x05, 0x45, 0x76, 0x65,
|
0x65, 0x6e, 0x74, 0x73, 0x32, 0xb4, 0x01, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x3a,
|
||||||
0x6e, 0x74, 0x12, 0x3a, 0x0a, 0x07, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x12, 0x15, 0x2e,
|
0x0a, 0x07, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x12, 0x15, 0x2e, 0x65, 0x76, 0x65, 0x6e,
|
||||||
0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x52, 0x65, 0x71,
|
0x74, 0x2e, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
||||||
0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x50, 0x75, 0x62,
|
0x1a, 0x16, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68,
|
||||||
0x6c, 0x69, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x42,
|
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3c, 0x0a, 0x07, 0x43, 0x6f,
|
||||||
0x0a, 0x09, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, 0x17, 0x2e, 0x65, 0x76,
|
0x6e, 0x73, 0x75, 0x6d, 0x65, 0x12, 0x15, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x43, 0x6f,
|
||||||
0x65, 0x6e, 0x74, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x71,
|
0x6e, 0x73, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x65,
|
||||||
0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x53, 0x75, 0x62,
|
0x76, 0x65, 0x6e, 0x74, 0x2e, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70,
|
||||||
0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00,
|
0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x31, 0x0a, 0x04, 0x52, 0x65, 0x61, 0x64,
|
||||||
0x30, 0x01, 0x12, 0x31, 0x0a, 0x04, 0x52, 0x65, 0x61, 0x64, 0x12, 0x12, 0x2e, 0x65, 0x76, 0x65,
|
0x12, 0x12, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71,
|
||||||
0x6e, 0x74, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13,
|
0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x52, 0x65, 0x61,
|
||||||
0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f,
|
0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x0f, 0x5a, 0x0d, 0x2e,
|
||||||
0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x0f, 0x5a, 0x0d, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x06, 0x70, 0x72,
|
||||||
0x3b, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -513,25 +513,25 @@ func file_proto_event_proto_rawDescGZIP() []byte {
|
|||||||
|
|
||||||
var file_proto_event_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
|
var file_proto_event_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
|
||||||
var file_proto_event_proto_goTypes = []interface{}{
|
var file_proto_event_proto_goTypes = []interface{}{
|
||||||
(*Ev)(nil), // 0: event.Ev
|
(*Ev)(nil), // 0: event.Ev
|
||||||
(*PublishRequest)(nil), // 1: event.PublishRequest
|
(*PublishRequest)(nil), // 1: event.PublishRequest
|
||||||
(*PublishResponse)(nil), // 2: event.PublishResponse
|
(*PublishResponse)(nil), // 2: event.PublishResponse
|
||||||
(*SubscribeRequest)(nil), // 3: event.SubscribeRequest
|
(*ConsumeRequest)(nil), // 3: event.ConsumeRequest
|
||||||
(*SubscribeResponse)(nil), // 4: event.SubscribeResponse
|
(*ConsumeResponse)(nil), // 4: event.ConsumeResponse
|
||||||
(*ReadRequest)(nil), // 5: event.ReadRequest
|
(*ReadRequest)(nil), // 5: event.ReadRequest
|
||||||
(*ReadResponse)(nil), // 6: event.ReadResponse
|
(*ReadResponse)(nil), // 6: event.ReadResponse
|
||||||
(*structpb.Struct)(nil), // 7: google.protobuf.Struct
|
(*structpb.Struct)(nil), // 7: google.protobuf.Struct
|
||||||
}
|
}
|
||||||
var file_proto_event_proto_depIdxs = []int32{
|
var file_proto_event_proto_depIdxs = []int32{
|
||||||
7, // 0: event.Ev.message:type_name -> google.protobuf.Struct
|
7, // 0: event.Ev.message:type_name -> google.protobuf.Struct
|
||||||
7, // 1: event.PublishRequest.message:type_name -> google.protobuf.Struct
|
7, // 1: event.PublishRequest.message:type_name -> google.protobuf.Struct
|
||||||
7, // 2: event.SubscribeResponse.message:type_name -> google.protobuf.Struct
|
7, // 2: event.ConsumeResponse.message:type_name -> google.protobuf.Struct
|
||||||
0, // 3: event.ReadResponse.events:type_name -> event.Ev
|
0, // 3: event.ReadResponse.events:type_name -> event.Ev
|
||||||
1, // 4: event.Event.Publish:input_type -> event.PublishRequest
|
1, // 4: event.Event.Publish:input_type -> event.PublishRequest
|
||||||
3, // 5: event.Event.Subscribe:input_type -> event.SubscribeRequest
|
3, // 5: event.Event.Consume:input_type -> event.ConsumeRequest
|
||||||
5, // 6: event.Event.Read:input_type -> event.ReadRequest
|
5, // 6: event.Event.Read:input_type -> event.ReadRequest
|
||||||
2, // 7: event.Event.Publish:output_type -> event.PublishResponse
|
2, // 7: event.Event.Publish:output_type -> event.PublishResponse
|
||||||
4, // 8: event.Event.Subscribe:output_type -> event.SubscribeResponse
|
4, // 8: event.Event.Consume:output_type -> event.ConsumeResponse
|
||||||
6, // 9: event.Event.Read:output_type -> event.ReadResponse
|
6, // 9: event.Event.Read:output_type -> event.ReadResponse
|
||||||
7, // [7:10] is the sub-list for method output_type
|
7, // [7:10] is the sub-list for method output_type
|
||||||
4, // [4:7] is the sub-list for method input_type
|
4, // [4:7] is the sub-list for method input_type
|
||||||
@@ -583,7 +583,7 @@ func file_proto_event_proto_init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_proto_event_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
file_proto_event_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*SubscribeRequest); i {
|
switch v := v.(*ConsumeRequest); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
case 1:
|
case 1:
|
||||||
@@ -595,7 +595,7 @@ func file_proto_event_proto_init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_proto_event_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
file_proto_event_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*SubscribeResponse); i {
|
switch v := v.(*ConsumeResponse); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
case 1:
|
case 1:
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ func NewEventEndpoints() []*api.Endpoint {
|
|||||||
|
|
||||||
type EventService interface {
|
type EventService interface {
|
||||||
Publish(ctx context.Context, in *PublishRequest, opts ...client.CallOption) (*PublishResponse, error)
|
Publish(ctx context.Context, in *PublishRequest, opts ...client.CallOption) (*PublishResponse, error)
|
||||||
Subscribe(ctx context.Context, in *SubscribeRequest, opts ...client.CallOption) (Event_SubscribeService, error)
|
Consume(ctx context.Context, in *ConsumeRequest, opts ...client.CallOption) (Event_ConsumeService, error)
|
||||||
Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error)
|
Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,8 +70,8 @@ func (c *eventService) Publish(ctx context.Context, in *PublishRequest, opts ...
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *eventService) Subscribe(ctx context.Context, in *SubscribeRequest, opts ...client.CallOption) (Event_SubscribeService, error) {
|
func (c *eventService) Consume(ctx context.Context, in *ConsumeRequest, opts ...client.CallOption) (Event_ConsumeService, error) {
|
||||||
req := c.c.NewRequest(c.name, "Event.Subscribe", &SubscribeRequest{})
|
req := c.c.NewRequest(c.name, "Event.Consume", &ConsumeRequest{})
|
||||||
stream, err := c.c.Stream(ctx, req, opts...)
|
stream, err := c.c.Stream(ctx, req, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -79,39 +79,39 @@ func (c *eventService) Subscribe(ctx context.Context, in *SubscribeRequest, opts
|
|||||||
if err := stream.Send(in); err != nil {
|
if err := stream.Send(in); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &eventServiceSubscribe{stream}, nil
|
return &eventServiceConsume{stream}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type Event_SubscribeService interface {
|
type Event_ConsumeService interface {
|
||||||
Context() context.Context
|
Context() context.Context
|
||||||
SendMsg(interface{}) error
|
SendMsg(interface{}) error
|
||||||
RecvMsg(interface{}) error
|
RecvMsg(interface{}) error
|
||||||
Close() error
|
Close() error
|
||||||
Recv() (*SubscribeResponse, error)
|
Recv() (*ConsumeResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type eventServiceSubscribe struct {
|
type eventServiceConsume struct {
|
||||||
stream client.Stream
|
stream client.Stream
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *eventServiceSubscribe) Close() error {
|
func (x *eventServiceConsume) Close() error {
|
||||||
return x.stream.Close()
|
return x.stream.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *eventServiceSubscribe) Context() context.Context {
|
func (x *eventServiceConsume) Context() context.Context {
|
||||||
return x.stream.Context()
|
return x.stream.Context()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *eventServiceSubscribe) SendMsg(m interface{}) error {
|
func (x *eventServiceConsume) SendMsg(m interface{}) error {
|
||||||
return x.stream.Send(m)
|
return x.stream.Send(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *eventServiceSubscribe) RecvMsg(m interface{}) error {
|
func (x *eventServiceConsume) RecvMsg(m interface{}) error {
|
||||||
return x.stream.Recv(m)
|
return x.stream.Recv(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *eventServiceSubscribe) Recv() (*SubscribeResponse, error) {
|
func (x *eventServiceConsume) Recv() (*ConsumeResponse, error) {
|
||||||
m := new(SubscribeResponse)
|
m := new(ConsumeResponse)
|
||||||
err := x.stream.Recv(m)
|
err := x.stream.Recv(m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -133,14 +133,14 @@ func (c *eventService) Read(ctx context.Context, in *ReadRequest, opts ...client
|
|||||||
|
|
||||||
type EventHandler interface {
|
type EventHandler interface {
|
||||||
Publish(context.Context, *PublishRequest, *PublishResponse) error
|
Publish(context.Context, *PublishRequest, *PublishResponse) error
|
||||||
Subscribe(context.Context, *SubscribeRequest, Event_SubscribeStream) error
|
Consume(context.Context, *ConsumeRequest, Event_ConsumeStream) error
|
||||||
Read(context.Context, *ReadRequest, *ReadResponse) error
|
Read(context.Context, *ReadRequest, *ReadResponse) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterEventHandler(s server.Server, hdlr EventHandler, opts ...server.HandlerOption) error {
|
func RegisterEventHandler(s server.Server, hdlr EventHandler, opts ...server.HandlerOption) error {
|
||||||
type event interface {
|
type event interface {
|
||||||
Publish(ctx context.Context, in *PublishRequest, out *PublishResponse) error
|
Publish(ctx context.Context, in *PublishRequest, out *PublishResponse) error
|
||||||
Subscribe(ctx context.Context, stream server.Stream) error
|
Consume(ctx context.Context, stream server.Stream) error
|
||||||
Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error
|
Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error
|
||||||
}
|
}
|
||||||
type Event struct {
|
type Event struct {
|
||||||
@@ -158,43 +158,43 @@ func (h *eventHandler) Publish(ctx context.Context, in *PublishRequest, out *Pub
|
|||||||
return h.EventHandler.Publish(ctx, in, out)
|
return h.EventHandler.Publish(ctx, in, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *eventHandler) Subscribe(ctx context.Context, stream server.Stream) error {
|
func (h *eventHandler) Consume(ctx context.Context, stream server.Stream) error {
|
||||||
m := new(SubscribeRequest)
|
m := new(ConsumeRequest)
|
||||||
if err := stream.Recv(m); err != nil {
|
if err := stream.Recv(m); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return h.EventHandler.Subscribe(ctx, m, &eventSubscribeStream{stream})
|
return h.EventHandler.Consume(ctx, m, &eventConsumeStream{stream})
|
||||||
}
|
}
|
||||||
|
|
||||||
type Event_SubscribeStream interface {
|
type Event_ConsumeStream interface {
|
||||||
Context() context.Context
|
Context() context.Context
|
||||||
SendMsg(interface{}) error
|
SendMsg(interface{}) error
|
||||||
RecvMsg(interface{}) error
|
RecvMsg(interface{}) error
|
||||||
Close() error
|
Close() error
|
||||||
Send(*SubscribeResponse) error
|
Send(*ConsumeResponse) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type eventSubscribeStream struct {
|
type eventConsumeStream struct {
|
||||||
stream server.Stream
|
stream server.Stream
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *eventSubscribeStream) Close() error {
|
func (x *eventConsumeStream) Close() error {
|
||||||
return x.stream.Close()
|
return x.stream.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *eventSubscribeStream) Context() context.Context {
|
func (x *eventConsumeStream) Context() context.Context {
|
||||||
return x.stream.Context()
|
return x.stream.Context()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *eventSubscribeStream) SendMsg(m interface{}) error {
|
func (x *eventConsumeStream) SendMsg(m interface{}) error {
|
||||||
return x.stream.Send(m)
|
return x.stream.Send(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *eventSubscribeStream) RecvMsg(m interface{}) error {
|
func (x *eventConsumeStream) RecvMsg(m interface{}) error {
|
||||||
return x.stream.Recv(m)
|
return x.stream.Recv(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *eventSubscribeStream) Send(m *SubscribeResponse) error {
|
func (x *eventConsumeStream) Send(m *ConsumeResponse) error {
|
||||||
return x.stream.Send(m)
|
return x.stream.Send(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import "google/protobuf/struct.proto";
|
|||||||
|
|
||||||
service Event {
|
service Event {
|
||||||
rpc Publish(PublishRequest) returns (PublishResponse) {}
|
rpc Publish(PublishRequest) returns (PublishResponse) {}
|
||||||
rpc Subscribe(SubscribeRequest) returns (stream SubscribeResponse) {}
|
rpc Consume(ConsumeRequest) returns (stream ConsumeResponse) {}
|
||||||
rpc Read(ReadRequest) returns (ReadResponse) {}
|
rpc Read(ReadRequest) returns (ReadResponse) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ message Ev {
|
|||||||
google.protobuf.Struct message = 3;
|
google.protobuf.Struct message = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Publish a message to the event stream.
|
// Publish a event to the event stream.
|
||||||
message PublishRequest {
|
message PublishRequest {
|
||||||
// The topic to publish to
|
// The topic to publish to
|
||||||
string topic = 1;
|
string topic = 1;
|
||||||
@@ -30,8 +30,8 @@ message PublishRequest {
|
|||||||
|
|
||||||
message PublishResponse {}
|
message PublishResponse {}
|
||||||
|
|
||||||
// Subscribe to messages for a given topic.
|
// Consume events from a given topic.
|
||||||
message SubscribeRequest {
|
message ConsumeRequest {
|
||||||
// The topic to subscribe to
|
// The topic to subscribe to
|
||||||
string topic = 1;
|
string topic = 1;
|
||||||
// Optional group for the subscription
|
// Optional group for the subscription
|
||||||
@@ -41,7 +41,7 @@ message SubscribeRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// A blocking event will be returned in response.
|
// A blocking event will be returned in response.
|
||||||
message SubscribeResponse {
|
message ConsumeResponse {
|
||||||
// The topic subscribed to
|
// The topic subscribed to
|
||||||
string topic = 1;
|
string topic = 1;
|
||||||
// Unique message id
|
// Unique message id
|
||||||
|
|||||||
Reference in New Issue
Block a user