From 291f87635b83a3b6bc23637c0307dbf6ca5c6fe4 Mon Sep 17 00:00:00 2001 From: bagas Date: Fri, 2 Jan 2026 18:29:58 +0700 Subject: [PATCH] feat: add slug proto --- README.md | 4 + gen/events.pb.go | 351 ++++++++++++++++++++++++++++++-------- gen/events_grpc.pb.go | 32 ++-- gen/identifier.pb.go | 188 -------------------- gen/identifier_grpc.pb.go | 160 ----------------- gen/slug.pb.go | 31 ++-- gen/slug_grpc.pb.go | 74 ++++---- proto/events.proto | 35 +++- proto/identifier.proto | 21 --- proto/slug.proto | 9 +- 10 files changed, 386 insertions(+), 519 deletions(-) create mode 100644 README.md delete mode 100644 gen/identifier.pb.go delete mode 100644 gen/identifier_grpc.pb.go delete mode 100644 proto/identifier.proto diff --git a/README.md b/README.md new file mode 100644 index 0000000..13190e4 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +## Compile +```bash +protoc --proto_path=proto proto/*.proto --go_out=. --go-grpc_out=. +``` \ No newline at end of file diff --git a/gen/events.pb.go b/gen/events.pb.go index ad1256d..90a479e 100644 --- a/gen/events.pb.go +++ b/gen/events.pb.go @@ -9,7 +9,6 @@ package gen import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" sync "sync" unsafe "unsafe" @@ -25,16 +24,22 @@ const ( type EventType int32 const ( - EventType_SLUG_CHANGE EventType = 0 + EventType_AUTHENTICATION EventType = 0 + EventType_SLUG_CHANGE EventType = 1 + EventType_SLUG_CHANGE_RESPONSE EventType = 2 ) // Enum value maps for EventType. var ( EventType_name = map[int32]string{ - 0: "SLUG_CHANGE", + 0: "AUTHENTICATION", + 1: "SLUG_CHANGE", + 2: "SLUG_CHANGE_RESPONSE", } EventType_value = map[string]int32{ - "SLUG_CHANGE": 0, + "AUTHENTICATION": 0, + "SLUG_CHANGE": 1, + "SLUG_CHANGE_RESPONSE": 2, } ) @@ -65,32 +70,31 @@ func (EventType) EnumDescriptor() ([]byte, []int) { return file_events_proto_rawDescGZIP(), []int{0} } -type Event struct { - state protoimpl.MessageState `protogen:"open.v1"` - Type EventType `protobuf:"varint,1,opt,name=type,proto3,enum=events.EventType" json:"type,omitempty"` - TimestampUnixMs int64 `protobuf:"varint,2,opt,name=timestamp_unix_ms,json=timestampUnixMs,proto3" json:"timestamp_unix_ms,omitempty"` - // Types that are valid to be assigned to Data: +type Controller struct { + state protoimpl.MessageState `protogen:"open.v1"` + Type EventType `protobuf:"varint,1,opt,name=type,proto3,enum=slug.EventType" json:"type,omitempty"` + // Types that are valid to be assigned to Payload: // - // *Event_DataEvent - Data isEvent_Data `protobuf_oneof:"data"` + // *Controller_SlugEvent + Payload isController_Payload `protobuf_oneof:"payload"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *Event) Reset() { - *x = Event{} +func (x *Controller) Reset() { + *x = Controller{} mi := &file_events_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *Event) String() string { +func (x *Controller) String() string { return protoimpl.X.MessageStringOf(x) } -func (*Event) ProtoMessage() {} +func (*Controller) ProtoMessage() {} -func (x *Event) ProtoReflect() protoreflect.Message { +func (x *Controller) ProtoReflect() protoreflect.Message { mi := &file_events_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -102,50 +106,185 @@ func (x *Event) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Event.ProtoReflect.Descriptor instead. -func (*Event) Descriptor() ([]byte, []int) { +// Deprecated: Use Controller.ProtoReflect.Descriptor instead. +func (*Controller) Descriptor() ([]byte, []int) { return file_events_proto_rawDescGZIP(), []int{0} } -func (x *Event) GetType() EventType { +func (x *Controller) GetType() EventType { if x != nil { return x.Type } - return EventType_SLUG_CHANGE + return EventType_AUTHENTICATION } -func (x *Event) GetTimestampUnixMs() int64 { +func (x *Controller) GetPayload() isController_Payload { if x != nil { - return x.TimestampUnixMs - } - return 0 -} - -func (x *Event) GetData() isEvent_Data { - if x != nil { - return x.Data + return x.Payload } return nil } -func (x *Event) GetDataEvent() *SlugChangeEvent { +func (x *Controller) GetSlugEvent() *SlugChangeEvent { if x != nil { - if x, ok := x.Data.(*Event_DataEvent); ok { - return x.DataEvent + if x, ok := x.Payload.(*Controller_SlugEvent); ok { + return x.SlugEvent } } return nil } -type isEvent_Data interface { - isEvent_Data() +type isController_Payload interface { + isController_Payload() } -type Event_DataEvent struct { - DataEvent *SlugChangeEvent `protobuf:"bytes,10,opt,name=data_event,json=dataEvent,proto3,oneof"` +type Controller_SlugEvent struct { + SlugEvent *SlugChangeEvent `protobuf:"bytes,11,opt,name=slug_event,json=slugEvent,proto3,oneof"` } -func (*Event_DataEvent) isEvent_Data() {} +func (*Controller_SlugEvent) isController_Payload() {} + +type Client struct { + state protoimpl.MessageState `protogen:"open.v1"` + Type EventType `protobuf:"varint,1,opt,name=type,proto3,enum=slug.EventType" json:"type,omitempty"` + // Types that are valid to be assigned to Payload: + // + // *Client_AuthEvent + // *Client_SlugEventResponse + Payload isClient_Payload `protobuf_oneof:"payload"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Client) Reset() { + *x = Client{} + mi := &file_events_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Client) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Client) ProtoMessage() {} + +func (x *Client) ProtoReflect() protoreflect.Message { + mi := &file_events_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Client.ProtoReflect.Descriptor instead. +func (*Client) Descriptor() ([]byte, []int) { + return file_events_proto_rawDescGZIP(), []int{1} +} + +func (x *Client) GetType() EventType { + if x != nil { + return x.Type + } + return EventType_AUTHENTICATION +} + +func (x *Client) GetPayload() isClient_Payload { + if x != nil { + return x.Payload + } + return nil +} + +func (x *Client) GetAuthEvent() *Authentication { + if x != nil { + if x, ok := x.Payload.(*Client_AuthEvent); ok { + return x.AuthEvent + } + } + return nil +} + +func (x *Client) GetSlugEventResponse() *SlugChangeEventResponse { + if x != nil { + if x, ok := x.Payload.(*Client_SlugEventResponse); ok { + return x.SlugEventResponse + } + } + return nil +} + +type isClient_Payload interface { + isClient_Payload() +} + +type Client_AuthEvent struct { + AuthEvent *Authentication `protobuf:"bytes,10,opt,name=auth_event,json=authEvent,proto3,oneof"` +} + +type Client_SlugEventResponse struct { + SlugEventResponse *SlugChangeEventResponse `protobuf:"bytes,11,opt,name=slug_event_response,json=slugEventResponse,proto3,oneof"` +} + +func (*Client_AuthEvent) isClient_Payload() {} + +func (*Client_SlugEventResponse) isClient_Payload() {} + +type Authentication struct { + state protoimpl.MessageState `protogen:"open.v1"` + AuthToken string `protobuf:"bytes,1,opt,name=auth_token,json=authToken,proto3" json:"auth_token,omitempty"` + Identity string `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Authentication) Reset() { + *x = Authentication{} + mi := &file_events_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Authentication) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Authentication) ProtoMessage() {} + +func (x *Authentication) ProtoReflect() protoreflect.Message { + mi := &file_events_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Authentication.ProtoReflect.Descriptor instead. +func (*Authentication) Descriptor() ([]byte, []int) { + return file_events_proto_rawDescGZIP(), []int{2} +} + +func (x *Authentication) GetAuthToken() string { + if x != nil { + return x.AuthToken + } + return "" +} + +func (x *Authentication) GetIdentity() string { + if x != nil { + return x.Identity + } + return "" +} type SlugChangeEvent struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -157,7 +296,7 @@ type SlugChangeEvent struct { func (x *SlugChangeEvent) Reset() { *x = SlugChangeEvent{} - mi := &file_events_proto_msgTypes[1] + mi := &file_events_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -169,7 +308,7 @@ func (x *SlugChangeEvent) String() string { func (*SlugChangeEvent) ProtoMessage() {} func (x *SlugChangeEvent) ProtoReflect() protoreflect.Message { - mi := &file_events_proto_msgTypes[1] + mi := &file_events_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -182,7 +321,7 @@ func (x *SlugChangeEvent) ProtoReflect() protoreflect.Message { // Deprecated: Use SlugChangeEvent.ProtoReflect.Descriptor instead. func (*SlugChangeEvent) Descriptor() ([]byte, []int) { - return file_events_proto_rawDescGZIP(), []int{1} + return file_events_proto_rawDescGZIP(), []int{3} } func (x *SlugChangeEvent) GetOld() string { @@ -199,25 +338,92 @@ func (x *SlugChangeEvent) GetNew() string { return "" } +type SlugChangeEventResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SlugChangeEventResponse) Reset() { + *x = SlugChangeEventResponse{} + mi := &file_events_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SlugChangeEventResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SlugChangeEventResponse) ProtoMessage() {} + +func (x *SlugChangeEventResponse) ProtoReflect() protoreflect.Message { + mi := &file_events_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SlugChangeEventResponse.ProtoReflect.Descriptor instead. +func (*SlugChangeEventResponse) Descriptor() ([]byte, []int) { + return file_events_proto_rawDescGZIP(), []int{4} +} + +func (x *SlugChangeEventResponse) GetSuccess() bool { + if x != nil { + return x.Success + } + return false +} + +func (x *SlugChangeEventResponse) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + var File_events_proto protoreflect.FileDescriptor const file_events_proto_rawDesc = "" + "\n" + - "\fevents.proto\x12\x06events\x1a\x1bgoogle/protobuf/empty.proto\"\x9c\x01\n" + - "\x05Event\x12%\n" + - "\x04type\x18\x01 \x01(\x0e2\x11.events.EventTypeR\x04type\x12*\n" + - "\x11timestamp_unix_ms\x18\x02 \x01(\x03R\x0ftimestampUnixMs\x128\n" + + "\fevents.proto\x12\x04slug\"t\n" + "\n" + - "data_event\x18\n" + - " \x01(\v2\x17.events.SlugChangeEventH\x00R\tdataEventB\x06\n" + - "\x04data\"5\n" + + "Controller\x12#\n" + + "\x04type\x18\x01 \x01(\x0e2\x0f.slug.EventTypeR\x04type\x126\n" + + "\n" + + "slug_event\x18\v \x01(\v2\x15.slug.SlugChangeEventH\x00R\tslugEventB\t\n" + + "\apayload\"\xc0\x01\n" + + "\x06Client\x12#\n" + + "\x04type\x18\x01 \x01(\x0e2\x0f.slug.EventTypeR\x04type\x125\n" + + "\n" + + "auth_event\x18\n" + + " \x01(\v2\x14.slug.AuthenticationH\x00R\tauthEvent\x12O\n" + + "\x13slug_event_response\x18\v \x01(\v2\x1d.slug.SlugChangeEventResponseH\x00R\x11slugEventResponseB\t\n" + + "\apayload\"K\n" + + "\x0eAuthentication\x12\x1d\n" + + "\n" + + "auth_token\x18\x01 \x01(\tR\tauthToken\x12\x1a\n" + + "\bidentity\x18\x02 \x01(\tR\bidentity\"5\n" + "\x0fSlugChangeEvent\x12\x10\n" + "\x03old\x18\x01 \x01(\tR\x03old\x12\x10\n" + - "\x03new\x18\x02 \x01(\tR\x03new*\x1c\n" + - "\tEventType\x12\x0f\n" + - "\vSLUG_CHANGE\x10\x002D\n" + - "\fEventService\x124\n" + - "\tSubscribe\x12\x16.google.protobuf.Empty\x1a\r.events.Event0\x01B\aZ\x05./genb\x06proto3" + "\x03new\x18\x02 \x01(\tR\x03new\"M\n" + + "\x17SlugChangeEventResponse\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\x12\x18\n" + + "\amessage\x18\x02 \x01(\tR\amessage*J\n" + + "\tEventType\x12\x12\n" + + "\x0eAUTHENTICATION\x10\x00\x12\x0f\n" + + "\vSLUG_CHANGE\x10\x01\x12\x18\n" + + "\x14SLUG_CHANGE_RESPONSE\x10\x022?\n" + + "\fEventService\x12/\n" + + "\tSubscribe\x12\f.slug.Client\x1a\x10.slug.Controller(\x010\x01B\aZ\x05./genb\x06proto3" var ( file_events_proto_rawDescOnce sync.Once @@ -232,23 +438,28 @@ func file_events_proto_rawDescGZIP() []byte { } var file_events_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_events_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_events_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_events_proto_goTypes = []any{ - (EventType)(0), // 0: events.EventType - (*Event)(nil), // 1: events.Event - (*SlugChangeEvent)(nil), // 2: events.SlugChangeEvent - (*emptypb.Empty)(nil), // 3: google.protobuf.Empty + (EventType)(0), // 0: slug.EventType + (*Controller)(nil), // 1: slug.Controller + (*Client)(nil), // 2: slug.Client + (*Authentication)(nil), // 3: slug.Authentication + (*SlugChangeEvent)(nil), // 4: slug.SlugChangeEvent + (*SlugChangeEventResponse)(nil), // 5: slug.SlugChangeEventResponse } var file_events_proto_depIdxs = []int32{ - 0, // 0: events.Event.type:type_name -> events.EventType - 2, // 1: events.Event.data_event:type_name -> events.SlugChangeEvent - 3, // 2: events.EventService.Subscribe:input_type -> google.protobuf.Empty - 1, // 3: events.EventService.Subscribe:output_type -> events.Event - 3, // [3:4] is the sub-list for method output_type - 2, // [2:3] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 0, // 0: slug.Controller.type:type_name -> slug.EventType + 4, // 1: slug.Controller.slug_event:type_name -> slug.SlugChangeEvent + 0, // 2: slug.Client.type:type_name -> slug.EventType + 3, // 3: slug.Client.auth_event:type_name -> slug.Authentication + 5, // 4: slug.Client.slug_event_response:type_name -> slug.SlugChangeEventResponse + 2, // 5: slug.EventService.Subscribe:input_type -> slug.Client + 1, // 6: slug.EventService.Subscribe:output_type -> slug.Controller + 6, // [6:7] is the sub-list for method output_type + 5, // [5:6] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name } func init() { file_events_proto_init() } @@ -257,7 +468,11 @@ func file_events_proto_init() { return } file_events_proto_msgTypes[0].OneofWrappers = []any{ - (*Event_DataEvent)(nil), + (*Controller_SlugEvent)(nil), + } + file_events_proto_msgTypes[1].OneofWrappers = []any{ + (*Client_AuthEvent)(nil), + (*Client_SlugEventResponse)(nil), } type x struct{} out := protoimpl.TypeBuilder{ @@ -265,7 +480,7 @@ func file_events_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_events_proto_rawDesc), len(file_events_proto_rawDesc)), NumEnums: 1, - NumMessages: 2, + NumMessages: 5, NumExtensions: 0, NumServices: 1, }, diff --git a/gen/events_grpc.pb.go b/gen/events_grpc.pb.go index c8bdab4..d10f456 100644 --- a/gen/events_grpc.pb.go +++ b/gen/events_grpc.pb.go @@ -11,7 +11,6 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - emptypb "google.golang.org/protobuf/types/known/emptypb" ) // This is a compile-time assertion to ensure that this generated file @@ -20,14 +19,14 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - EventService_Subscribe_FullMethodName = "/events.EventService/Subscribe" + EventService_Subscribe_FullMethodName = "/slug.EventService/Subscribe" ) // EventServiceClient is the client API for EventService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type EventServiceClient interface { - Subscribe(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (grpc.ServerStreamingClient[Event], error) + Subscribe(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[Client, Controller], error) } type eventServiceClient struct { @@ -38,30 +37,24 @@ func NewEventServiceClient(cc grpc.ClientConnInterface) EventServiceClient { return &eventServiceClient{cc} } -func (c *eventServiceClient) Subscribe(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (grpc.ServerStreamingClient[Event], error) { +func (c *eventServiceClient) Subscribe(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[Client, Controller], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) stream, err := c.cc.NewStream(ctx, &EventService_ServiceDesc.Streams[0], EventService_Subscribe_FullMethodName, cOpts...) if err != nil { return nil, err } - x := &grpc.GenericClientStream[emptypb.Empty, Event]{ClientStream: stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } + x := &grpc.GenericClientStream[Client, Controller]{ClientStream: stream} return x, nil } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. -type EventService_SubscribeClient = grpc.ServerStreamingClient[Event] +type EventService_SubscribeClient = grpc.BidiStreamingClient[Client, Controller] // EventServiceServer is the server API for EventService service. // All implementations must embed UnimplementedEventServiceServer // for forward compatibility. type EventServiceServer interface { - Subscribe(*emptypb.Empty, grpc.ServerStreamingServer[Event]) error + Subscribe(grpc.BidiStreamingServer[Client, Controller]) error mustEmbedUnimplementedEventServiceServer() } @@ -72,7 +65,7 @@ type EventServiceServer interface { // pointer dereference when methods are called. type UnimplementedEventServiceServer struct{} -func (UnimplementedEventServiceServer) Subscribe(*emptypb.Empty, grpc.ServerStreamingServer[Event]) error { +func (UnimplementedEventServiceServer) Subscribe(grpc.BidiStreamingServer[Client, Controller]) error { return status.Error(codes.Unimplemented, "method Subscribe not implemented") } func (UnimplementedEventServiceServer) mustEmbedUnimplementedEventServiceServer() {} @@ -97,21 +90,17 @@ func RegisterEventServiceServer(s grpc.ServiceRegistrar, srv EventServiceServer) } func _EventService_Subscribe_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(emptypb.Empty) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(EventServiceServer).Subscribe(m, &grpc.GenericServerStream[emptypb.Empty, Event]{ServerStream: stream}) + return srv.(EventServiceServer).Subscribe(&grpc.GenericServerStream[Client, Controller]{ServerStream: stream}) } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. -type EventService_SubscribeServer = grpc.ServerStreamingServer[Event] +type EventService_SubscribeServer = grpc.BidiStreamingServer[Client, Controller] // EventService_ServiceDesc is the grpc.ServiceDesc for EventService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var EventService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "events.EventService", + ServiceName: "slug.EventService", HandlerType: (*EventServiceServer)(nil), Methods: []grpc.MethodDesc{}, Streams: []grpc.StreamDesc{ @@ -119,6 +108,7 @@ var EventService_ServiceDesc = grpc.ServiceDesc{ StreamName: "Subscribe", Handler: _EventService_Subscribe_Handler, ServerStreams: true, + ClientStreams: true, }, }, Metadata: "events.proto", diff --git a/gen/identifier.pb.go b/gen/identifier.pb.go deleted file mode 100644 index eaf5677..0000000 --- a/gen/identifier.pb.go +++ /dev/null @@ -1,188 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.11 -// protoc v6.33.2 -// source: identifier.proto - -package gen - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - emptypb "google.golang.org/protobuf/types/known/emptypb" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type IdentifierRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *IdentifierRequest) Reset() { - *x = IdentifierRequest{} - mi := &file_identifier_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *IdentifierRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*IdentifierRequest) ProtoMessage() {} - -func (x *IdentifierRequest) ProtoReflect() protoreflect.Message { - mi := &file_identifier_proto_msgTypes[0] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use IdentifierRequest.ProtoReflect.Descriptor instead. -func (*IdentifierRequest) Descriptor() ([]byte, []int) { - return file_identifier_proto_rawDescGZIP(), []int{0} -} - -func (x *IdentifierRequest) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -type IdentifierResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Slug string `protobuf:"bytes,2,opt,name=slug,proto3" json:"slug,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *IdentifierResponse) Reset() { - *x = IdentifierResponse{} - mi := &file_identifier_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *IdentifierResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*IdentifierResponse) ProtoMessage() {} - -func (x *IdentifierResponse) ProtoReflect() protoreflect.Message { - mi := &file_identifier_proto_msgTypes[1] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use IdentifierResponse.ProtoReflect.Descriptor instead. -func (*IdentifierResponse) Descriptor() ([]byte, []int) { - return file_identifier_proto_rawDescGZIP(), []int{1} -} - -func (x *IdentifierResponse) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *IdentifierResponse) GetSlug() string { - if x != nil { - return x.Slug - } - return "" -} - -var File_identifier_proto protoreflect.FileDescriptor - -const file_identifier_proto_rawDesc = "" + - "\n" + - "\x10identifier.proto\x12\n" + - "identifier\x1a\x1bgoogle/protobuf/empty.proto\"#\n" + - "\x11IdentifierRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\tR\x02id\"8\n" + - "\x12IdentifierResponse\x12\x0e\n" + - "\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" + - "\x04slug\x18\x02 \x01(\tR\x04slug2\x92\x01\n" + - "\bIdentity\x12D\n" + - "\x03Get\x12\x1d.identifier.IdentifierRequest\x1a\x1e.identifier.IdentifierResponse\x12@\n" + - "\x06Create\x12\x16.google.protobuf.Empty\x1a\x1e.identifier.IdentifierResponseB\aZ\x05./genb\x06proto3" - -var ( - file_identifier_proto_rawDescOnce sync.Once - file_identifier_proto_rawDescData []byte -) - -func file_identifier_proto_rawDescGZIP() []byte { - file_identifier_proto_rawDescOnce.Do(func() { - file_identifier_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_identifier_proto_rawDesc), len(file_identifier_proto_rawDesc))) - }) - return file_identifier_proto_rawDescData -} - -var file_identifier_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_identifier_proto_goTypes = []any{ - (*IdentifierRequest)(nil), // 0: identifier.IdentifierRequest - (*IdentifierResponse)(nil), // 1: identifier.IdentifierResponse - (*emptypb.Empty)(nil), // 2: google.protobuf.Empty -} -var file_identifier_proto_depIdxs = []int32{ - 0, // 0: identifier.Identity.Get:input_type -> identifier.IdentifierRequest - 2, // 1: identifier.Identity.Create:input_type -> google.protobuf.Empty - 1, // 2: identifier.Identity.Get:output_type -> identifier.IdentifierResponse - 1, // 3: identifier.Identity.Create:output_type -> identifier.IdentifierResponse - 2, // [2:4] is the sub-list for method output_type - 0, // [0:2] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_identifier_proto_init() } -func file_identifier_proto_init() { - if File_identifier_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_identifier_proto_rawDesc), len(file_identifier_proto_rawDesc)), - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_identifier_proto_goTypes, - DependencyIndexes: file_identifier_proto_depIdxs, - MessageInfos: file_identifier_proto_msgTypes, - }.Build() - File_identifier_proto = out.File - file_identifier_proto_goTypes = nil - file_identifier_proto_depIdxs = nil -} diff --git a/gen/identifier_grpc.pb.go b/gen/identifier_grpc.pb.go deleted file mode 100644 index 6b0c2f7..0000000 --- a/gen/identifier_grpc.pb.go +++ /dev/null @@ -1,160 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.6.0 -// - protoc v6.33.2 -// source: identifier.proto - -package gen - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - emptypb "google.golang.org/protobuf/types/known/emptypb" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - Identity_Get_FullMethodName = "/identifier.Identity/Get" - Identity_Create_FullMethodName = "/identifier.Identity/Create" -) - -// IdentityClient is the client API for Identity service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type IdentityClient interface { - Get(ctx context.Context, in *IdentifierRequest, opts ...grpc.CallOption) (*IdentifierResponse, error) - Create(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*IdentifierResponse, error) -} - -type identityClient struct { - cc grpc.ClientConnInterface -} - -func NewIdentityClient(cc grpc.ClientConnInterface) IdentityClient { - return &identityClient{cc} -} - -func (c *identityClient) Get(ctx context.Context, in *IdentifierRequest, opts ...grpc.CallOption) (*IdentifierResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(IdentifierResponse) - err := c.cc.Invoke(ctx, Identity_Get_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *identityClient) Create(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*IdentifierResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(IdentifierResponse) - err := c.cc.Invoke(ctx, Identity_Create_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// IdentityServer is the server API for Identity service. -// All implementations must embed UnimplementedIdentityServer -// for forward compatibility. -type IdentityServer interface { - Get(context.Context, *IdentifierRequest) (*IdentifierResponse, error) - Create(context.Context, *emptypb.Empty) (*IdentifierResponse, error) - mustEmbedUnimplementedIdentityServer() -} - -// UnimplementedIdentityServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedIdentityServer struct{} - -func (UnimplementedIdentityServer) Get(context.Context, *IdentifierRequest) (*IdentifierResponse, error) { - return nil, status.Error(codes.Unimplemented, "method Get not implemented") -} -func (UnimplementedIdentityServer) Create(context.Context, *emptypb.Empty) (*IdentifierResponse, error) { - return nil, status.Error(codes.Unimplemented, "method Create not implemented") -} -func (UnimplementedIdentityServer) mustEmbedUnimplementedIdentityServer() {} -func (UnimplementedIdentityServer) testEmbeddedByValue() {} - -// UnsafeIdentityServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to IdentityServer will -// result in compilation errors. -type UnsafeIdentityServer interface { - mustEmbedUnimplementedIdentityServer() -} - -func RegisterIdentityServer(s grpc.ServiceRegistrar, srv IdentityServer) { - // If the following call panics, it indicates UnimplementedIdentityServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&Identity_ServiceDesc, srv) -} - -func _Identity_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(IdentifierRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(IdentityServer).Get(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Identity_Get_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(IdentityServer).Get(ctx, req.(*IdentifierRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Identity_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(emptypb.Empty) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(IdentityServer).Create(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Identity_Create_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(IdentityServer).Create(ctx, req.(*emptypb.Empty)) - } - return interceptor(ctx, in, info, handler) -} - -// Identity_ServiceDesc is the grpc.ServiceDesc for Identity service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Identity_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "identifier.Identity", - HandlerType: (*IdentityServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Get", - Handler: _Identity_Get_Handler, - }, - { - MethodName: "Create", - Handler: _Identity_Create_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "identifier.proto", -} diff --git a/gen/slug.pb.go b/gen/slug.pb.go index 989633c..26a23b2 100644 --- a/gen/slug.pb.go +++ b/gen/slug.pb.go @@ -23,8 +23,9 @@ const ( type ChangeSlugRequest struct { state protoimpl.MessageState `protogen:"open.v1"` - Old string `protobuf:"bytes,1,opt,name=old,proto3" json:"old,omitempty"` - New string `protobuf:"bytes,2,opt,name=new,proto3" json:"new,omitempty"` + Node string `protobuf:"bytes,1,opt,name=node,proto3" json:"node,omitempty"` + Old string `protobuf:"bytes,2,opt,name=old,proto3" json:"old,omitempty"` + New string `protobuf:"bytes,3,opt,name=new,proto3" json:"new,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -59,6 +60,13 @@ func (*ChangeSlugRequest) Descriptor() ([]byte, []int) { return file_slug_proto_rawDescGZIP(), []int{0} } +func (x *ChangeSlugRequest) GetNode() string { + if x != nil { + return x.Node + } + return "" +} + func (x *ChangeSlugRequest) GetOld() string { if x != nil { return x.Old @@ -130,16 +138,17 @@ var File_slug_proto protoreflect.FileDescriptor const file_slug_proto_rawDesc = "" + "\n" + "\n" + - "slug.proto\x12\x04slug\"7\n" + - "\x11ChangeSlugRequest\x12\x10\n" + - "\x03old\x18\x01 \x01(\tR\x03old\x12\x10\n" + - "\x03new\x18\x02 \x01(\tR\x03new\"H\n" + + "slug.proto\x12\x04slug\"K\n" + + "\x11ChangeSlugRequest\x12\x12\n" + + "\x04node\x18\x01 \x01(\tR\x04node\x12\x10\n" + + "\x03old\x18\x02 \x01(\tR\x03old\x12\x10\n" + + "\x03new\x18\x03 \x01(\tR\x03new\"H\n" + "\x12ChangeSlugResponse\x12\x18\n" + "\asuccess\x18\x01 \x01(\bR\asuccess\x12\x18\n" + - "\amessage\x18\x02 \x01(\tR\amessage2G\n" + - "\x04Slug\x12?\n" + + "\amessage\x18\x02 \x01(\tR\amessage2T\n" + "\n" + - "ChangeSlug\x12\x17.slug.ChangeSlugRequest\x1a\x18.slug.ChangeSlugResponseB\aZ\x05./genb\x06proto3" + "SlugChange\x12F\n" + + "\x11RequestChangeSlug\x12\x17.slug.ChangeSlugRequest\x1a\x18.slug.ChangeSlugResponseB\aZ\x05./genb\x06proto3" var ( file_slug_proto_rawDescOnce sync.Once @@ -159,8 +168,8 @@ var file_slug_proto_goTypes = []any{ (*ChangeSlugResponse)(nil), // 1: slug.ChangeSlugResponse } var file_slug_proto_depIdxs = []int32{ - 0, // 0: slug.Slug.ChangeSlug:input_type -> slug.ChangeSlugRequest - 1, // 1: slug.Slug.ChangeSlug:output_type -> slug.ChangeSlugResponse + 0, // 0: slug.SlugChange.RequestChangeSlug:input_type -> slug.ChangeSlugRequest + 1, // 1: slug.SlugChange.RequestChangeSlug:output_type -> slug.ChangeSlugResponse 1, // [1:2] is the sub-list for method output_type 0, // [0:1] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name diff --git a/gen/slug_grpc.pb.go b/gen/slug_grpc.pb.go index 493a113..43da27b 100644 --- a/gen/slug_grpc.pb.go +++ b/gen/slug_grpc.pb.go @@ -19,101 +19,101 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - Slug_ChangeSlug_FullMethodName = "/slug.Slug/ChangeSlug" + SlugChange_RequestChangeSlug_FullMethodName = "/slug.SlugChange/RequestChangeSlug" ) -// SlugClient is the client API for Slug service. +// SlugChangeClient is the client API for SlugChange service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type SlugClient interface { - ChangeSlug(ctx context.Context, in *ChangeSlugRequest, opts ...grpc.CallOption) (*ChangeSlugResponse, error) +type SlugChangeClient interface { + RequestChangeSlug(ctx context.Context, in *ChangeSlugRequest, opts ...grpc.CallOption) (*ChangeSlugResponse, error) } -type slugClient struct { +type slugChangeClient struct { cc grpc.ClientConnInterface } -func NewSlugClient(cc grpc.ClientConnInterface) SlugClient { - return &slugClient{cc} +func NewSlugChangeClient(cc grpc.ClientConnInterface) SlugChangeClient { + return &slugChangeClient{cc} } -func (c *slugClient) ChangeSlug(ctx context.Context, in *ChangeSlugRequest, opts ...grpc.CallOption) (*ChangeSlugResponse, error) { +func (c *slugChangeClient) RequestChangeSlug(ctx context.Context, in *ChangeSlugRequest, opts ...grpc.CallOption) (*ChangeSlugResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ChangeSlugResponse) - err := c.cc.Invoke(ctx, Slug_ChangeSlug_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, SlugChange_RequestChangeSlug_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -// SlugServer is the server API for Slug service. -// All implementations must embed UnimplementedSlugServer +// SlugChangeServer is the server API for SlugChange service. +// All implementations must embed UnimplementedSlugChangeServer // for forward compatibility. -type SlugServer interface { - ChangeSlug(context.Context, *ChangeSlugRequest) (*ChangeSlugResponse, error) - mustEmbedUnimplementedSlugServer() +type SlugChangeServer interface { + RequestChangeSlug(context.Context, *ChangeSlugRequest) (*ChangeSlugResponse, error) + mustEmbedUnimplementedSlugChangeServer() } -// UnimplementedSlugServer must be embedded to have +// UnimplementedSlugChangeServer must be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. -type UnimplementedSlugServer struct{} +type UnimplementedSlugChangeServer struct{} -func (UnimplementedSlugServer) ChangeSlug(context.Context, *ChangeSlugRequest) (*ChangeSlugResponse, error) { - return nil, status.Error(codes.Unimplemented, "method ChangeSlug not implemented") +func (UnimplementedSlugChangeServer) RequestChangeSlug(context.Context, *ChangeSlugRequest) (*ChangeSlugResponse, error) { + return nil, status.Error(codes.Unimplemented, "method RequestChangeSlug not implemented") } -func (UnimplementedSlugServer) mustEmbedUnimplementedSlugServer() {} -func (UnimplementedSlugServer) testEmbeddedByValue() {} +func (UnimplementedSlugChangeServer) mustEmbedUnimplementedSlugChangeServer() {} +func (UnimplementedSlugChangeServer) testEmbeddedByValue() {} -// UnsafeSlugServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to SlugServer will +// UnsafeSlugChangeServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to SlugChangeServer will // result in compilation errors. -type UnsafeSlugServer interface { - mustEmbedUnimplementedSlugServer() +type UnsafeSlugChangeServer interface { + mustEmbedUnimplementedSlugChangeServer() } -func RegisterSlugServer(s grpc.ServiceRegistrar, srv SlugServer) { - // If the following call panics, it indicates UnimplementedSlugServer was +func RegisterSlugChangeServer(s grpc.ServiceRegistrar, srv SlugChangeServer) { + // If the following call panics, it indicates UnimplementedSlugChangeServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } - s.RegisterService(&Slug_ServiceDesc, srv) + s.RegisterService(&SlugChange_ServiceDesc, srv) } -func _Slug_ChangeSlug_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _SlugChange_RequestChangeSlug_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ChangeSlugRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(SlugServer).ChangeSlug(ctx, in) + return srv.(SlugChangeServer).RequestChangeSlug(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Slug_ChangeSlug_FullMethodName, + FullMethod: SlugChange_RequestChangeSlug_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(SlugServer).ChangeSlug(ctx, req.(*ChangeSlugRequest)) + return srv.(SlugChangeServer).RequestChangeSlug(ctx, req.(*ChangeSlugRequest)) } return interceptor(ctx, in, info, handler) } -// Slug_ServiceDesc is the grpc.ServiceDesc for Slug service. +// SlugChange_ServiceDesc is the grpc.ServiceDesc for SlugChange service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) -var Slug_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "slug.Slug", - HandlerType: (*SlugServer)(nil), +var SlugChange_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "slug.SlugChange", + HandlerType: (*SlugChangeServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "ChangeSlug", - Handler: _Slug_ChangeSlug_Handler, + MethodName: "RequestChangeSlug", + Handler: _SlugChange_RequestChangeSlug_Handler, }, }, Streams: []grpc.StreamDesc{}, diff --git a/proto/events.proto b/proto/events.proto index 7a1097c..ad39ec1 100644 --- a/proto/events.proto +++ b/proto/events.proto @@ -1,30 +1,47 @@ syntax = "proto3"; -package events; +package slug; option go_package = "./gen"; -import "google/protobuf/empty.proto"; - service EventService { - rpc Subscribe(google.protobuf.Empty) returns (stream Event); + rpc Subscribe(stream Client) returns (stream Controller); } enum EventType { - SLUG_CHANGE = 0; + AUTHENTICATION = 0; + SLUG_CHANGE = 1; + SLUG_CHANGE_RESPONSE = 2; } -message Event { +message Controller { EventType type = 1; - int64 timestamp_unix_ms = 2; - oneof data { - SlugChangeEvent data_event = 10; + oneof payload { + SlugChangeEvent slug_event = 11; } } +message Client { + EventType type = 1; + + oneof payload { + Authentication auth_event = 10; + SlugChangeEventResponse slug_event_response = 11; + } +} + +message Authentication { + string auth_token = 1; + string identity = 2; +} + message SlugChangeEvent { string old = 1; string new = 2; } +message SlugChangeEventResponse { + bool success = 1; + string message = 2; +} diff --git a/proto/identifier.proto b/proto/identifier.proto deleted file mode 100644 index eeaae91..0000000 --- a/proto/identifier.proto +++ /dev/null @@ -1,21 +0,0 @@ -syntax = "proto3"; - -package identifier; - -option go_package = "./gen"; - -import "google/protobuf/empty.proto"; - -service Identity { - rpc Get(IdentifierRequest) returns (IdentifierResponse); - rpc Create(google.protobuf.Empty) returns (IdentifierResponse); -} - -message IdentifierRequest { - string id = 1; -} - -message IdentifierResponse { - string id = 1; - string slug = 2; -} \ No newline at end of file diff --git a/proto/slug.proto b/proto/slug.proto index 32cb320..c9f91fe 100644 --- a/proto/slug.proto +++ b/proto/slug.proto @@ -4,13 +4,14 @@ package slug; option go_package = "./gen"; -service Slug { - rpc ChangeSlug(ChangeSlugRequest) returns (ChangeSlugResponse); +service SlugChange { + rpc RequestChangeSlug(ChangeSlugRequest) returns (ChangeSlugResponse); } message ChangeSlugRequest { - string old = 1; - string new = 2; + string node = 1; + string old = 2; + string new = 3; } message ChangeSlugResponse {