diff --git a/gen/events.pb.go b/gen/events.pb.go new file mode 100644 index 0000000..ad1256d --- /dev/null +++ b/gen/events.pb.go @@ -0,0 +1,280 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc v6.33.2 +// source: events.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 EventType int32 + +const ( + EventType_SLUG_CHANGE EventType = 0 +) + +// Enum value maps for EventType. +var ( + EventType_name = map[int32]string{ + 0: "SLUG_CHANGE", + } + EventType_value = map[string]int32{ + "SLUG_CHANGE": 0, + } +) + +func (x EventType) Enum() *EventType { + p := new(EventType) + *p = x + return p +} + +func (x EventType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (EventType) Descriptor() protoreflect.EnumDescriptor { + return file_events_proto_enumTypes[0].Descriptor() +} + +func (EventType) Type() protoreflect.EnumType { + return &file_events_proto_enumTypes[0] +} + +func (x EventType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use EventType.Descriptor instead. +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: + // + // *Event_DataEvent + Data isEvent_Data `protobuf_oneof:"data"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Event) Reset() { + *x = Event{} + mi := &file_events_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Event) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Event) ProtoMessage() {} + +func (x *Event) ProtoReflect() protoreflect.Message { + mi := &file_events_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 Event.ProtoReflect.Descriptor instead. +func (*Event) Descriptor() ([]byte, []int) { + return file_events_proto_rawDescGZIP(), []int{0} +} + +func (x *Event) GetType() EventType { + if x != nil { + return x.Type + } + return EventType_SLUG_CHANGE +} + +func (x *Event) GetTimestampUnixMs() int64 { + if x != nil { + return x.TimestampUnixMs + } + return 0 +} + +func (x *Event) GetData() isEvent_Data { + if x != nil { + return x.Data + } + return nil +} + +func (x *Event) GetDataEvent() *SlugChangeEvent { + if x != nil { + if x, ok := x.Data.(*Event_DataEvent); ok { + return x.DataEvent + } + } + return nil +} + +type isEvent_Data interface { + isEvent_Data() +} + +type Event_DataEvent struct { + DataEvent *SlugChangeEvent `protobuf:"bytes,10,opt,name=data_event,json=dataEvent,proto3,oneof"` +} + +func (*Event_DataEvent) isEvent_Data() {} + +type SlugChangeEvent 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"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SlugChangeEvent) Reset() { + *x = SlugChangeEvent{} + mi := &file_events_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SlugChangeEvent) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SlugChangeEvent) ProtoMessage() {} + +func (x *SlugChangeEvent) 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 SlugChangeEvent.ProtoReflect.Descriptor instead. +func (*SlugChangeEvent) Descriptor() ([]byte, []int) { + return file_events_proto_rawDescGZIP(), []int{1} +} + +func (x *SlugChangeEvent) GetOld() string { + if x != nil { + return x.Old + } + return "" +} + +func (x *SlugChangeEvent) GetNew() string { + if x != nil { + return x.New + } + 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" + + "\n" + + "data_event\x18\n" + + " \x01(\v2\x17.events.SlugChangeEventH\x00R\tdataEventB\x06\n" + + "\x04data\"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" + +var ( + file_events_proto_rawDescOnce sync.Once + file_events_proto_rawDescData []byte +) + +func file_events_proto_rawDescGZIP() []byte { + file_events_proto_rawDescOnce.Do(func() { + file_events_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_events_proto_rawDesc), len(file_events_proto_rawDesc))) + }) + return file_events_proto_rawDescData +} + +var file_events_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_events_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +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 +} +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 +} + +func init() { file_events_proto_init() } +func file_events_proto_init() { + if File_events_proto != nil { + return + } + file_events_proto_msgTypes[0].OneofWrappers = []any{ + (*Event_DataEvent)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_events_proto_rawDesc), len(file_events_proto_rawDesc)), + NumEnums: 1, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_events_proto_goTypes, + DependencyIndexes: file_events_proto_depIdxs, + EnumInfos: file_events_proto_enumTypes, + MessageInfos: file_events_proto_msgTypes, + }.Build() + File_events_proto = out.File + file_events_proto_goTypes = nil + file_events_proto_depIdxs = nil +} diff --git a/gen/events_grpc.pb.go b/gen/events_grpc.pb.go new file mode 100644 index 0000000..c8bdab4 --- /dev/null +++ b/gen/events_grpc.pb.go @@ -0,0 +1,125 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.6.0 +// - protoc v6.33.2 +// source: events.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 ( + EventService_Subscribe_FullMethodName = "/events.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) +} + +type eventServiceClient struct { + cc grpc.ClientConnInterface +} + +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) { + 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 + } + 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] + +// 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 + mustEmbedUnimplementedEventServiceServer() +} + +// UnimplementedEventServiceServer 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 UnimplementedEventServiceServer struct{} + +func (UnimplementedEventServiceServer) Subscribe(*emptypb.Empty, grpc.ServerStreamingServer[Event]) error { + return status.Error(codes.Unimplemented, "method Subscribe not implemented") +} +func (UnimplementedEventServiceServer) mustEmbedUnimplementedEventServiceServer() {} +func (UnimplementedEventServiceServer) testEmbeddedByValue() {} + +// UnsafeEventServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to EventServiceServer will +// result in compilation errors. +type UnsafeEventServiceServer interface { + mustEmbedUnimplementedEventServiceServer() +} + +func RegisterEventServiceServer(s grpc.ServiceRegistrar, srv EventServiceServer) { + // If the following call panics, it indicates UnimplementedEventServiceServer 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(&EventService_ServiceDesc, srv) +} + +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}) +} + +// 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] + +// 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", + HandlerType: (*EventServiceServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "Subscribe", + Handler: _EventService_Subscribe_Handler, + ServerStreams: true, + }, + }, + Metadata: "events.proto", +} diff --git a/gen/slug.pb.go b/gen/slug.pb.go new file mode 100644 index 0000000..989633c --- /dev/null +++ b/gen/slug.pb.go @@ -0,0 +1,193 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc v6.33.2 +// source: slug.proto + +package gen + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + 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 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"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ChangeSlugRequest) Reset() { + *x = ChangeSlugRequest{} + mi := &file_slug_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ChangeSlugRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ChangeSlugRequest) ProtoMessage() {} + +func (x *ChangeSlugRequest) ProtoReflect() protoreflect.Message { + mi := &file_slug_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 ChangeSlugRequest.ProtoReflect.Descriptor instead. +func (*ChangeSlugRequest) Descriptor() ([]byte, []int) { + return file_slug_proto_rawDescGZIP(), []int{0} +} + +func (x *ChangeSlugRequest) GetOld() string { + if x != nil { + return x.Old + } + return "" +} + +func (x *ChangeSlugRequest) GetNew() string { + if x != nil { + return x.New + } + return "" +} + +type ChangeSlugResponse 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 *ChangeSlugResponse) Reset() { + *x = ChangeSlugResponse{} + mi := &file_slug_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ChangeSlugResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ChangeSlugResponse) ProtoMessage() {} + +func (x *ChangeSlugResponse) ProtoReflect() protoreflect.Message { + mi := &file_slug_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 ChangeSlugResponse.ProtoReflect.Descriptor instead. +func (*ChangeSlugResponse) Descriptor() ([]byte, []int) { + return file_slug_proto_rawDescGZIP(), []int{1} +} + +func (x *ChangeSlugResponse) GetSuccess() bool { + if x != nil { + return x.Success + } + return false +} + +func (x *ChangeSlugResponse) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +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" + + "\x12ChangeSlugResponse\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\x12\x18\n" + + "\amessage\x18\x02 \x01(\tR\amessage2G\n" + + "\x04Slug\x12?\n" + + "\n" + + "ChangeSlug\x12\x17.slug.ChangeSlugRequest\x1a\x18.slug.ChangeSlugResponseB\aZ\x05./genb\x06proto3" + +var ( + file_slug_proto_rawDescOnce sync.Once + file_slug_proto_rawDescData []byte +) + +func file_slug_proto_rawDescGZIP() []byte { + file_slug_proto_rawDescOnce.Do(func() { + file_slug_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_slug_proto_rawDesc), len(file_slug_proto_rawDesc))) + }) + return file_slug_proto_rawDescData +} + +var file_slug_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_slug_proto_goTypes = []any{ + (*ChangeSlugRequest)(nil), // 0: slug.ChangeSlugRequest + (*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 + 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 + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_slug_proto_init() } +func file_slug_proto_init() { + if File_slug_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_slug_proto_rawDesc), len(file_slug_proto_rawDesc)), + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_slug_proto_goTypes, + DependencyIndexes: file_slug_proto_depIdxs, + MessageInfos: file_slug_proto_msgTypes, + }.Build() + File_slug_proto = out.File + file_slug_proto_goTypes = nil + file_slug_proto_depIdxs = nil +} diff --git a/gen/slug_grpc.pb.go b/gen/slug_grpc.pb.go new file mode 100644 index 0000000..493a113 --- /dev/null +++ b/gen/slug_grpc.pb.go @@ -0,0 +1,121 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.6.0 +// - protoc v6.33.2 +// source: slug.proto + +package gen + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// 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 ( + Slug_ChangeSlug_FullMethodName = "/slug.Slug/ChangeSlug" +) + +// SlugClient is the client API for Slug 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 slugClient struct { + cc grpc.ClientConnInterface +} + +func NewSlugClient(cc grpc.ClientConnInterface) SlugClient { + return &slugClient{cc} +} + +func (c *slugClient) ChangeSlug(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...) + if err != nil { + return nil, err + } + return out, nil +} + +// SlugServer is the server API for Slug service. +// All implementations must embed UnimplementedSlugServer +// for forward compatibility. +type SlugServer interface { + ChangeSlug(context.Context, *ChangeSlugRequest) (*ChangeSlugResponse, error) + mustEmbedUnimplementedSlugServer() +} + +// UnimplementedSlugServer 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{} + +func (UnimplementedSlugServer) ChangeSlug(context.Context, *ChangeSlugRequest) (*ChangeSlugResponse, error) { + return nil, status.Error(codes.Unimplemented, "method ChangeSlug not implemented") +} +func (UnimplementedSlugServer) mustEmbedUnimplementedSlugServer() {} +func (UnimplementedSlugServer) 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 +// result in compilation errors. +type UnsafeSlugServer interface { + mustEmbedUnimplementedSlugServer() +} + +func RegisterSlugServer(s grpc.ServiceRegistrar, srv SlugServer) { + // If the following call panics, it indicates UnimplementedSlugServer 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) +} + +func _Slug_ChangeSlug_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) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Slug_ChangeSlug_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SlugServer).ChangeSlug(ctx, req.(*ChangeSlugRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Slug_ServiceDesc is the grpc.ServiceDesc for Slug 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), + Methods: []grpc.MethodDesc{ + { + MethodName: "ChangeSlug", + Handler: _Slug_ChangeSlug_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "slug.proto", +} diff --git a/proto/events.proto b/proto/events.proto new file mode 100644 index 0000000..7a1097c --- /dev/null +++ b/proto/events.proto @@ -0,0 +1,30 @@ +syntax = "proto3"; + +package events; + +option go_package = "./gen"; + +import "google/protobuf/empty.proto"; + +service EventService { + rpc Subscribe(google.protobuf.Empty) returns (stream Event); +} + +enum EventType { + SLUG_CHANGE = 0; +} + +message Event { + EventType type = 1; + int64 timestamp_unix_ms = 2; + + oneof data { + SlugChangeEvent data_event = 10; + } +} + +message SlugChangeEvent { + string old = 1; + string new = 2; +} + diff --git a/proto/slug.proto b/proto/slug.proto new file mode 100644 index 0000000..32cb320 --- /dev/null +++ b/proto/slug.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; + +package slug; + +option go_package = "./gen"; + +service Slug { + rpc ChangeSlug(ChangeSlugRequest) returns (ChangeSlugResponse); +} + +message ChangeSlugRequest { + string old = 1; + string new = 2; +} + +message ChangeSlugResponse { + bool success = 1; + string message = 2; +}