From 3df86292b56d4f40af7dfd586e477a98ab5c5efe Mon Sep 17 00:00:00 2001 From: benrobey Date: Sun, 17 Aug 2025 18:15:26 +1000 Subject: [PATCH 1/3] Adds `GetRace` --- api/proto/racing/racing.pb.go | 205 +++++++++++++++++--------- api/proto/racing/racing.pb.gw.go | 99 +++++++++++++ api/proto/racing/racing.proto | 10 ++ api/proto/racing/racing_grpc.pb.go | 38 +++++ racing/db/races.go | 29 ++++ racing/proto/racing.go | 2 +- racing/proto/racing/racing.pb.go | 202 ++++++++++++++++--------- racing/proto/racing/racing.proto | 9 ++ racing/proto/racing/racing_grpc.pb.go | 38 +++++ racing/service/racing.go | 30 ++++ 10 files changed, 528 insertions(+), 134 deletions(-) diff --git a/api/proto/racing/racing.pb.go b/api/proto/racing/racing.pb.go index feef067..0ee711e 100644 --- a/api/proto/racing/racing.pb.go +++ b/api/proto/racing/racing.pb.go @@ -218,6 +218,55 @@ func (x *ListRacesResponse) GetRaces() []*Race { return nil } +type GetRaceRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The resource name of the race to retrieve. + // Format: races/{race} + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // required +} + +func (x *GetRaceRequest) Reset() { + *x = GetRaceRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_racing_racing_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetRaceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetRaceRequest) ProtoMessage() {} + +func (x *GetRaceRequest) ProtoReflect() protoreflect.Message { + mi := &file_racing_racing_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetRaceRequest.ProtoReflect.Descriptor instead. +func (*GetRaceRequest) Descriptor() ([]byte, []int) { + return file_racing_racing_proto_rawDescGZIP(), []int{2} +} + +func (x *GetRaceRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + // Filter for listing races. type ListRacesRequestFilter struct { state protoimpl.MessageState @@ -236,7 +285,7 @@ type ListRacesRequestFilter struct { func (x *ListRacesRequestFilter) Reset() { *x = ListRacesRequestFilter{} if protoimpl.UnsafeEnabled { - mi := &file_racing_racing_proto_msgTypes[2] + mi := &file_racing_racing_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -249,7 +298,7 @@ func (x *ListRacesRequestFilter) String() string { func (*ListRacesRequestFilter) ProtoMessage() {} func (x *ListRacesRequestFilter) ProtoReflect() protoreflect.Message { - mi := &file_racing_racing_proto_msgTypes[2] + mi := &file_racing_racing_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -262,7 +311,7 @@ func (x *ListRacesRequestFilter) ProtoReflect() protoreflect.Message { // Deprecated: Use ListRacesRequestFilter.ProtoReflect.Descriptor instead. func (*ListRacesRequestFilter) Descriptor() ([]byte, []int) { - return file_racing_racing_proto_rawDescGZIP(), []int{2} + return file_racing_racing_proto_rawDescGZIP(), []int{3} } func (x *ListRacesRequestFilter) GetMeetingIds() []int64 { @@ -311,7 +360,7 @@ type Race struct { func (x *Race) Reset() { *x = Race{} if protoimpl.UnsafeEnabled { - mi := &file_racing_racing_proto_msgTypes[3] + mi := &file_racing_racing_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -324,7 +373,7 @@ func (x *Race) String() string { func (*Race) ProtoMessage() {} func (x *Race) ProtoReflect() protoreflect.Message { - mi := &file_racing_racing_proto_msgTypes[3] + mi := &file_racing_racing_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -337,7 +386,7 @@ func (x *Race) ProtoReflect() protoreflect.Message { // Deprecated: Use Race.ProtoReflect.Descriptor instead. func (*Race) Descriptor() ([]byte, []int) { - return file_racing_racing_proto_rawDescGZIP(), []int{3} + return file_racing_racing_proto_rawDescGZIP(), []int{4} } func (x *Race) GetId() int64 { @@ -406,54 +455,61 @@ var file_racing_racing_proto_rawDesc = []byte{ 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x22, 0x0a, 0x05, 0x72, 0x61, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, 0x63, 0x65, 0x52, 0x05, 0x72, 0x61, 0x63, 0x65, - 0x73, 0x22, 0xc8, 0x01, 0x0a, 0x16, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x1f, 0x0a, 0x0b, - 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, - 0x03, 0x52, 0x0a, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x49, 0x64, 0x73, 0x12, 0x26, 0x0a, - 0x0c, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x0b, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x4f, 0x6e, - 0x6c, 0x79, 0x88, 0x01, 0x01, 0x12, 0x41, 0x0a, 0x0e, 0x73, 0x6f, 0x72, 0x74, 0x5f, 0x64, 0x69, - 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, - 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x53, 0x6f, 0x72, 0x74, 0x44, 0x69, 0x72, 0x65, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x01, 0x52, 0x0d, 0x73, 0x6f, 0x72, 0x74, 0x44, 0x69, 0x72, 0x65, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, 0x01, 0x42, 0x0f, 0x0a, 0x0d, 0x5f, 0x76, 0x69, 0x73, - 0x69, 0x62, 0x6c, 0x65, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x42, 0x11, 0x0a, 0x0f, 0x5f, 0x73, 0x6f, - 0x72, 0x74, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xf7, 0x01, 0x0a, - 0x04, 0x52, 0x61, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, - 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x6d, 0x65, 0x65, 0x74, 0x69, - 0x6e, 0x67, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, - 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, - 0x12, 0x18, 0x0a, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x12, 0x4e, 0x0a, 0x15, 0x61, 0x64, - 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x65, 0x64, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, - 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x13, 0x61, 0x64, 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x65, - 0x64, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x2a, 0x0a, 0x06, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x72, 0x61, 0x63, - 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2a, 0x60, 0x0a, 0x0d, 0x53, 0x6f, 0x72, 0x74, 0x44, 0x69, - 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x1a, 0x53, 0x4f, 0x52, 0x54, 0x5f, - 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, - 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x4f, 0x52, 0x54, 0x5f, - 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x41, 0x53, 0x43, 0x10, 0x01, 0x12, - 0x17, 0x0a, 0x13, 0x53, 0x4f, 0x52, 0x54, 0x5f, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, - 0x4e, 0x5f, 0x44, 0x45, 0x53, 0x43, 0x10, 0x02, 0x2a, 0x57, 0x0a, 0x0a, 0x52, 0x61, 0x63, 0x65, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1b, 0x0a, 0x17, 0x52, 0x41, 0x43, 0x45, 0x5f, 0x53, - 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, - 0x44, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x52, 0x41, 0x43, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, - 0x55, 0x53, 0x5f, 0x4f, 0x50, 0x45, 0x4e, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x52, 0x41, 0x43, - 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x10, - 0x02, 0x32, 0x65, 0x0a, 0x06, 0x52, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x12, 0x5b, 0x0a, 0x09, 0x4c, - 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x12, 0x18, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, - 0x67, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x4c, 0x69, 0x73, 0x74, - 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, - 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x22, 0x0e, 0x2f, 0x76, 0x31, 0x2f, 0x6c, 0x69, 0x73, 0x74, 0x2d, - 0x72, 0x61, 0x63, 0x65, 0x73, 0x3a, 0x01, 0x2a, 0x42, 0x09, 0x5a, 0x07, 0x2f, 0x72, 0x61, 0x63, - 0x69, 0x6e, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x22, 0x24, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x52, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xc8, 0x01, 0x0a, 0x16, 0x4c, 0x69, 0x73, 0x74, + 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x69, 0x6c, 0x74, + 0x65, 0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x69, 0x64, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x03, 0x52, 0x0a, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, + 0x49, 0x64, 0x73, 0x12, 0x26, 0x0a, 0x0c, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x5f, 0x6f, + 0x6e, 0x6c, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x0b, 0x76, 0x69, 0x73, + 0x69, 0x62, 0x6c, 0x65, 0x4f, 0x6e, 0x6c, 0x79, 0x88, 0x01, 0x01, 0x12, 0x41, 0x0a, 0x0e, 0x73, + 0x6f, 0x72, 0x74, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x53, 0x6f, 0x72, + 0x74, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x01, 0x52, 0x0d, 0x73, 0x6f, + 0x72, 0x74, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, 0x01, 0x42, 0x0f, + 0x0a, 0x0d, 0x5f, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x42, + 0x11, 0x0a, 0x0f, 0x5f, 0x73, 0x6f, 0x72, 0x74, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x22, 0xf7, 0x01, 0x0a, 0x04, 0x52, 0x61, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, + 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x09, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, + 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, + 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, + 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, + 0x12, 0x4e, 0x0a, 0x15, 0x61, 0x64, 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x65, 0x64, 0x5f, 0x73, + 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x13, 0x61, 0x64, 0x76, + 0x65, 0x72, 0x74, 0x69, 0x73, 0x65, 0x64, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, + 0x12, 0x2a, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x12, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, 0x63, 0x65, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2a, 0x60, 0x0a, 0x0d, + 0x53, 0x6f, 0x72, 0x74, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, + 0x1a, 0x53, 0x4f, 0x52, 0x54, 0x5f, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, + 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x16, 0x0a, + 0x12, 0x53, 0x4f, 0x52, 0x54, 0x5f, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, + 0x41, 0x53, 0x43, 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, 0x53, 0x4f, 0x52, 0x54, 0x5f, 0x44, 0x49, + 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x44, 0x45, 0x53, 0x43, 0x10, 0x02, 0x2a, 0x57, + 0x0a, 0x0a, 0x52, 0x61, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1b, 0x0a, 0x17, + 0x52, 0x41, 0x43, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, + 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x52, 0x41, 0x43, + 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x4f, 0x50, 0x45, 0x4e, 0x10, 0x01, 0x12, + 0x16, 0x0a, 0x12, 0x52, 0x41, 0x43, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x43, + 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x10, 0x02, 0x32, 0xb2, 0x01, 0x0a, 0x06, 0x52, 0x61, 0x63, 0x69, + 0x6e, 0x67, 0x12, 0x5b, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x12, + 0x18, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, + 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x61, 0x63, 0x69, + 0x6e, 0x67, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x22, 0x0e, 0x2f, 0x76, + 0x31, 0x2f, 0x6c, 0x69, 0x73, 0x74, 0x2d, 0x72, 0x61, 0x63, 0x65, 0x73, 0x3a, 0x01, 0x2a, 0x12, + 0x4b, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x52, 0x61, 0x63, 0x65, 0x12, 0x16, 0x2e, 0x72, 0x61, 0x63, + 0x69, 0x6e, 0x67, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, 0x63, 0x65, + 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x12, 0x12, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, + 0x61, 0x6d, 0x65, 0x3d, 0x72, 0x61, 0x63, 0x65, 0x73, 0x2f, 0x2a, 0x7d, 0x42, 0x09, 0x5a, 0x07, + 0x2f, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -469,26 +525,29 @@ func file_racing_racing_proto_rawDescGZIP() []byte { } var file_racing_racing_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_racing_racing_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_racing_racing_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_racing_racing_proto_goTypes = []interface{}{ (SortDirection)(0), // 0: racing.SortDirection (RaceStatus)(0), // 1: racing.RaceStatus (*ListRacesRequest)(nil), // 2: racing.ListRacesRequest (*ListRacesResponse)(nil), // 3: racing.ListRacesResponse - (*ListRacesRequestFilter)(nil), // 4: racing.ListRacesRequestFilter - (*Race)(nil), // 5: racing.Race - (*timestamppb.Timestamp)(nil), // 6: google.protobuf.Timestamp + (*GetRaceRequest)(nil), // 4: racing.GetRaceRequest + (*ListRacesRequestFilter)(nil), // 5: racing.ListRacesRequestFilter + (*Race)(nil), // 6: racing.Race + (*timestamppb.Timestamp)(nil), // 7: google.protobuf.Timestamp } var file_racing_racing_proto_depIdxs = []int32{ - 4, // 0: racing.ListRacesRequest.filter:type_name -> racing.ListRacesRequestFilter - 5, // 1: racing.ListRacesResponse.races:type_name -> racing.Race + 5, // 0: racing.ListRacesRequest.filter:type_name -> racing.ListRacesRequestFilter + 6, // 1: racing.ListRacesResponse.races:type_name -> racing.Race 0, // 2: racing.ListRacesRequestFilter.sort_direction:type_name -> racing.SortDirection - 6, // 3: racing.Race.advertised_start_time:type_name -> google.protobuf.Timestamp + 7, // 3: racing.Race.advertised_start_time:type_name -> google.protobuf.Timestamp 1, // 4: racing.Race.status:type_name -> racing.RaceStatus 2, // 5: racing.Racing.ListRaces:input_type -> racing.ListRacesRequest - 3, // 6: racing.Racing.ListRaces:output_type -> racing.ListRacesResponse - 6, // [6:7] is the sub-list for method output_type - 5, // [5:6] is the sub-list for method input_type + 4, // 6: racing.Racing.GetRace:input_type -> racing.GetRaceRequest + 3, // 7: racing.Racing.ListRaces:output_type -> racing.ListRacesResponse + 6, // 8: racing.Racing.GetRace:output_type -> racing.Race + 7, // [7:9] is the sub-list for method output_type + 5, // [5:7] 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 @@ -525,7 +584,7 @@ func file_racing_racing_proto_init() { } } file_racing_racing_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListRacesRequestFilter); i { + switch v := v.(*GetRaceRequest); i { case 0: return &v.state case 1: @@ -537,6 +596,18 @@ func file_racing_racing_proto_init() { } } file_racing_racing_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListRacesRequestFilter); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_racing_racing_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Race); i { case 0: return &v.state @@ -549,14 +620,14 @@ func file_racing_racing_proto_init() { } } } - file_racing_racing_proto_msgTypes[2].OneofWrappers = []interface{}{} + file_racing_racing_proto_msgTypes[3].OneofWrappers = []interface{}{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_racing_racing_proto_rawDesc, NumEnums: 2, - NumMessages: 4, + NumMessages: 5, NumExtensions: 0, NumServices: 1, }, diff --git a/api/proto/racing/racing.pb.gw.go b/api/proto/racing/racing.pb.gw.go index 3f34377..115ef9c 100644 --- a/api/proto/racing/racing.pb.gw.go +++ b/api/proto/racing/racing.pb.gw.go @@ -65,6 +65,58 @@ func local_request_Racing_ListRaces_0(ctx context.Context, marshaler runtime.Mar } +func request_Racing_GetRace_0(ctx context.Context, marshaler runtime.Marshaler, client RacingClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetRaceRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + msg, err := client.GetRace(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Racing_GetRace_0(ctx context.Context, marshaler runtime.Marshaler, server RacingServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetRaceRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + msg, err := server.GetRace(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterRacingHandlerServer registers the http handlers for service Racing to "mux". // UnaryRPC :call RacingServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -94,6 +146,29 @@ func RegisterRacingHandlerServer(ctx context.Context, mux *runtime.ServeMux, ser }) + mux.Handle("GET", pattern_Racing_GetRace_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/racing.Racing/GetRace") + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Racing_GetRace_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Racing_GetRace_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -155,13 +230,37 @@ func RegisterRacingHandlerClient(ctx context.Context, mux *runtime.ServeMux, cli }) + mux.Handle("GET", pattern_Racing_GetRace_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req, "/racing.Racing/GetRace") + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Racing_GetRace_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Racing_GetRace_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } var ( pattern_Racing_ListRaces_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "list-races"}, "")) + + pattern_Racing_GetRace_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "races", "name"}, "")) ) var ( forward_Racing_ListRaces_0 = runtime.ForwardResponseMessage + + forward_Racing_GetRace_0 = runtime.ForwardResponseMessage ) diff --git a/api/proto/racing/racing.proto b/api/proto/racing/racing.proto index e7fa1d4..fe2e547 100644 --- a/api/proto/racing/racing.proto +++ b/api/proto/racing/racing.proto @@ -25,6 +25,10 @@ service Racing { rpc ListRaces(ListRacesRequest) returns (ListRacesResponse) { option (google.api.http) = { post: "/v1/list-races", body: "*" }; } + // GetRace returns a single race by resource name. + rpc GetRace(GetRaceRequest) returns (Race) { + option (google.api.http) = { get: "/v1/{name=races/*}" }; + } } /* Requests/Responses */ @@ -39,6 +43,12 @@ message ListRacesResponse { repeated Race races = 1; } +message GetRaceRequest { + // The resource name of the race to retrieve. + // Format: races/{race} + string name = 1; // required +} + // Filter for listing races. message ListRacesRequestFilter { repeated int64 meeting_ids = 1; diff --git a/api/proto/racing/racing_grpc.pb.go b/api/proto/racing/racing_grpc.pb.go index 6325105..1b13fde 100644 --- a/api/proto/racing/racing_grpc.pb.go +++ b/api/proto/racing/racing_grpc.pb.go @@ -20,6 +20,8 @@ const _ = grpc.SupportPackageIsVersion7 type RacingClient interface { // ListRaces returns a list of all races. ListRaces(ctx context.Context, in *ListRacesRequest, opts ...grpc.CallOption) (*ListRacesResponse, error) + // GetRace returns a single race by resource name. + GetRace(ctx context.Context, in *GetRaceRequest, opts ...grpc.CallOption) (*Race, error) } type racingClient struct { @@ -39,12 +41,23 @@ func (c *racingClient) ListRaces(ctx context.Context, in *ListRacesRequest, opts return out, nil } +func (c *racingClient) GetRace(ctx context.Context, in *GetRaceRequest, opts ...grpc.CallOption) (*Race, error) { + out := new(Race) + err := c.cc.Invoke(ctx, "/racing.Racing/GetRace", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // RacingServer is the server API for Racing service. // All implementations must embed UnimplementedRacingServer // for forward compatibility type RacingServer interface { // ListRaces returns a list of all races. ListRaces(context.Context, *ListRacesRequest) (*ListRacesResponse, error) + // GetRace returns a single race by resource name. + GetRace(context.Context, *GetRaceRequest) (*Race, error) mustEmbedUnimplementedRacingServer() } @@ -55,6 +68,9 @@ type UnimplementedRacingServer struct { func (UnimplementedRacingServer) ListRaces(context.Context, *ListRacesRequest) (*ListRacesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ListRaces not implemented") } +func (UnimplementedRacingServer) GetRace(context.Context, *GetRaceRequest) (*Race, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetRace not implemented") +} func (UnimplementedRacingServer) mustEmbedUnimplementedRacingServer() {} // UnsafeRacingServer may be embedded to opt out of forward compatibility for this service. @@ -86,6 +102,24 @@ func _Racing_ListRaces_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _Racing_GetRace_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetRaceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RacingServer).GetRace(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/racing.Racing/GetRace", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RacingServer).GetRace(ctx, req.(*GetRaceRequest)) + } + return interceptor(ctx, in, info, handler) +} + // Racing_ServiceDesc is the grpc.ServiceDesc for Racing service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -97,6 +131,10 @@ var Racing_ServiceDesc = grpc.ServiceDesc{ MethodName: "ListRaces", Handler: _Racing_ListRaces_Handler, }, + { + MethodName: "GetRace", + Handler: _Racing_GetRace_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "racing/racing.proto", diff --git a/racing/db/races.go b/racing/db/races.go index a8eddab..ac58c91 100644 --- a/racing/db/races.go +++ b/racing/db/races.go @@ -19,6 +19,9 @@ type RacesRepo interface { // List will return a list of races. List(filter *racing.ListRacesRequestFilter) ([]*racing.Race, error) + + // Get returns a single race by numeric id. + Get(id int64) (*racing.Race, error) } type racesRepo struct { @@ -62,6 +65,32 @@ func (r *racesRepo) List(filter *racing.ListRacesRequestFilter) ([]*racing.Race, return r.scanRaces(rows) } +func (r *racesRepo) Get(id int64) (*racing.Race, error) { + query := "SELECT id, meeting_id, name, number, visible, advertised_start_time FROM races WHERE id = ? LIMIT 1" + row := r.db.QueryRow(query, id) + var ( + race racing.Race + advertisedStart time.Time + ) + if err := row.Scan(&race.Id, &race.MeetingId, &race.Name, &race.Number, &race.Visible, &advertisedStart); err != nil { + if err == sql.ErrNoRows { + return nil, nil + } + return nil, err + } + ts, err := ptypes.TimestampProto(advertisedStart) + if err != nil { + return nil, err + } + race.AdvertisedStartTime = ts + if advertisedStart.After(time.Now()) { + race.Status = racing.RaceStatus_RACE_STATUS_OPEN + } else { + race.Status = racing.RaceStatus_RACE_STATUS_CLOSED + } + return &race, nil +} + func (r *racesRepo) applyFilter(query string, filter *racing.ListRacesRequestFilter) (string, []interface{}) { var ( clauses []string diff --git a/racing/proto/racing.go b/racing/proto/racing.go index afc1049..b9f48f4 100644 --- a/racing/proto/racing.go +++ b/racing/proto/racing.go @@ -1,3 +1,3 @@ package proto -//go:generate protoc --go_out=. --go-grpc_out=require_unimplemented_servers=false:. racing/racing.proto --experimental_allow_proto3_optional +//go:generate protoc -I . -I ../api/proto -I ../../../../baseline_implementation/api/proto -I %GOPATH%/pkg/mod --go_out=. --go-grpc_out=require_unimplemented_servers=false:. racing/racing.proto --experimental_allow_proto3_optional diff --git a/racing/proto/racing/racing.pb.go b/racing/proto/racing/racing.pb.go index 6c22b8d..9b2e887 100644 --- a/racing/proto/racing/racing.pb.go +++ b/racing/proto/racing/racing.pb.go @@ -218,6 +218,56 @@ func (x *ListRacesResponse) GetRaces() []*Race { return nil } +// Request for a single race using its resource name. +type GetRaceRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The resource name of the race to retrieve. + // Format: races/{race} + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // required +} + +func (x *GetRaceRequest) Reset() { + *x = GetRaceRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_racing_racing_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetRaceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetRaceRequest) ProtoMessage() {} + +func (x *GetRaceRequest) ProtoReflect() protoreflect.Message { + mi := &file_racing_racing_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetRaceRequest.ProtoReflect.Descriptor instead. +func (*GetRaceRequest) Descriptor() ([]byte, []int) { + return file_racing_racing_proto_rawDescGZIP(), []int{2} +} + +func (x *GetRaceRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + // Filter for listing races. type ListRacesRequestFilter struct { state protoimpl.MessageState @@ -236,7 +286,7 @@ type ListRacesRequestFilter struct { func (x *ListRacesRequestFilter) Reset() { *x = ListRacesRequestFilter{} if protoimpl.UnsafeEnabled { - mi := &file_racing_racing_proto_msgTypes[2] + mi := &file_racing_racing_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -249,7 +299,7 @@ func (x *ListRacesRequestFilter) String() string { func (*ListRacesRequestFilter) ProtoMessage() {} func (x *ListRacesRequestFilter) ProtoReflect() protoreflect.Message { - mi := &file_racing_racing_proto_msgTypes[2] + mi := &file_racing_racing_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -262,7 +312,7 @@ func (x *ListRacesRequestFilter) ProtoReflect() protoreflect.Message { // Deprecated: Use ListRacesRequestFilter.ProtoReflect.Descriptor instead. func (*ListRacesRequestFilter) Descriptor() ([]byte, []int) { - return file_racing_racing_proto_rawDescGZIP(), []int{2} + return file_racing_racing_proto_rawDescGZIP(), []int{3} } func (x *ListRacesRequestFilter) GetMeetingIds() []int64 { @@ -311,7 +361,7 @@ type Race struct { func (x *Race) Reset() { *x = Race{} if protoimpl.UnsafeEnabled { - mi := &file_racing_racing_proto_msgTypes[3] + mi := &file_racing_racing_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -324,7 +374,7 @@ func (x *Race) String() string { func (*Race) ProtoMessage() {} func (x *Race) ProtoReflect() protoreflect.Message { - mi := &file_racing_racing_proto_msgTypes[3] + mi := &file_racing_racing_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -337,7 +387,7 @@ func (x *Race) ProtoReflect() protoreflect.Message { // Deprecated: Use Race.ProtoReflect.Descriptor instead. func (*Race) Descriptor() ([]byte, []int) { - return file_racing_racing_proto_rawDescGZIP(), []int{3} + return file_racing_racing_proto_rawDescGZIP(), []int{4} } func (x *Race) GetId() int64 { @@ -404,53 +454,58 @@ var file_racing_racing_proto_rawDesc = []byte{ 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x22, 0x0a, 0x05, 0x72, 0x61, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, 0x63, 0x65, 0x52, 0x05, 0x72, 0x61, - 0x63, 0x65, 0x73, 0x22, 0xc8, 0x01, 0x0a, 0x16, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x1f, - 0x0a, 0x0b, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x03, 0x52, 0x0a, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x49, 0x64, 0x73, 0x12, - 0x26, 0x0a, 0x0c, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x0b, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, - 0x4f, 0x6e, 0x6c, 0x79, 0x88, 0x01, 0x01, 0x12, 0x41, 0x0a, 0x0e, 0x73, 0x6f, 0x72, 0x74, 0x5f, - 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, - 0x15, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x53, 0x6f, 0x72, 0x74, 0x44, 0x69, 0x72, - 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x01, 0x52, 0x0d, 0x73, 0x6f, 0x72, 0x74, 0x44, 0x69, - 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, 0x01, 0x42, 0x0f, 0x0a, 0x0d, 0x5f, 0x76, - 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x42, 0x11, 0x0a, 0x0f, 0x5f, - 0x73, 0x6f, 0x72, 0x74, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xf7, - 0x01, 0x0a, 0x04, 0x52, 0x61, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x65, 0x65, 0x74, 0x69, - 0x6e, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x6d, 0x65, 0x65, - 0x74, 0x69, 0x6e, 0x67, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, - 0x6d, 0x62, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, - 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x12, 0x4e, 0x0a, 0x15, - 0x61, 0x64, 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x65, 0x64, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, - 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x13, 0x61, 0x64, 0x76, 0x65, 0x72, 0x74, 0x69, - 0x73, 0x65, 0x64, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x2a, 0x0a, 0x06, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x72, - 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2a, 0x60, 0x0a, 0x0d, 0x53, 0x6f, 0x72, 0x74, - 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x1a, 0x53, 0x4f, 0x52, - 0x54, 0x5f, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x55, 0x4e, 0x53, 0x50, - 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x4f, 0x52, - 0x54, 0x5f, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x41, 0x53, 0x43, 0x10, - 0x01, 0x12, 0x17, 0x0a, 0x13, 0x53, 0x4f, 0x52, 0x54, 0x5f, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, - 0x49, 0x4f, 0x4e, 0x5f, 0x44, 0x45, 0x53, 0x43, 0x10, 0x02, 0x2a, 0x57, 0x0a, 0x0a, 0x52, 0x61, - 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1b, 0x0a, 0x17, 0x52, 0x41, 0x43, 0x45, - 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, - 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x52, 0x41, 0x43, 0x45, 0x5f, 0x53, 0x54, - 0x41, 0x54, 0x55, 0x53, 0x5f, 0x4f, 0x50, 0x45, 0x4e, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x52, - 0x41, 0x43, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x43, 0x4c, 0x4f, 0x53, 0x45, - 0x44, 0x10, 0x02, 0x32, 0x4c, 0x0a, 0x06, 0x52, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x12, 0x42, 0x0a, - 0x09, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x12, 0x18, 0x2e, 0x72, 0x61, 0x63, - 0x69, 0x6e, 0x67, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x4c, 0x69, - 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x42, 0x09, 0x5a, 0x07, 0x2f, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x63, 0x65, 0x73, 0x22, 0x24, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x52, 0x61, 0x63, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xc8, 0x01, 0x0a, 0x16, 0x4c, 0x69, + 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x69, + 0x6c, 0x74, 0x65, 0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x5f, + 0x69, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x03, 0x52, 0x0a, 0x6d, 0x65, 0x65, 0x74, 0x69, + 0x6e, 0x67, 0x49, 0x64, 0x73, 0x12, 0x26, 0x0a, 0x0c, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, + 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x0b, 0x76, + 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x4f, 0x6e, 0x6c, 0x79, 0x88, 0x01, 0x01, 0x12, 0x41, 0x0a, + 0x0e, 0x73, 0x6f, 0x72, 0x74, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x53, + 0x6f, 0x72, 0x74, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x01, 0x52, 0x0d, + 0x73, 0x6f, 0x72, 0x74, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, 0x01, + 0x42, 0x0f, 0x0a, 0x0d, 0x5f, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x5f, 0x6f, 0x6e, 0x6c, + 0x79, 0x42, 0x11, 0x0a, 0x0f, 0x5f, 0x73, 0x6f, 0x72, 0x74, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xf7, 0x01, 0x0a, 0x04, 0x52, 0x61, 0x63, 0x65, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1d, 0x0a, + 0x0a, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x09, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x69, 0x73, 0x69, + 0x62, 0x6c, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, + 0x6c, 0x65, 0x12, 0x4e, 0x0a, 0x15, 0x61, 0x64, 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x65, 0x64, + 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x13, 0x61, + 0x64, 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x65, 0x64, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, + 0x6d, 0x65, 0x12, 0x2a, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x07, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, 0x63, 0x65, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2a, 0x60, + 0x0a, 0x0d, 0x53, 0x6f, 0x72, 0x74, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x1e, 0x0a, 0x1a, 0x53, 0x4f, 0x52, 0x54, 0x5f, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, + 0x4e, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, + 0x16, 0x0a, 0x12, 0x53, 0x4f, 0x52, 0x54, 0x5f, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, + 0x4e, 0x5f, 0x41, 0x53, 0x43, 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, 0x53, 0x4f, 0x52, 0x54, 0x5f, + 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x44, 0x45, 0x53, 0x43, 0x10, 0x02, + 0x2a, 0x57, 0x0a, 0x0a, 0x52, 0x61, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1b, + 0x0a, 0x17, 0x52, 0x41, 0x43, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, + 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x52, + 0x41, 0x43, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x4f, 0x50, 0x45, 0x4e, 0x10, + 0x01, 0x12, 0x16, 0x0a, 0x12, 0x52, 0x41, 0x43, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, + 0x5f, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x10, 0x02, 0x32, 0x7f, 0x0a, 0x06, 0x52, 0x61, 0x63, + 0x69, 0x6e, 0x67, 0x12, 0x42, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, + 0x12, 0x18, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, + 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x61, 0x63, + 0x69, 0x6e, 0x67, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x31, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x52, 0x61, + 0x63, 0x65, 0x12, 0x16, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x47, 0x65, 0x74, 0x52, + 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x72, 0x61, 0x63, + 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, 0x63, 0x65, 0x22, 0x00, 0x42, 0x09, 0x5a, 0x07, 0x2f, 0x72, + 0x61, 0x63, 0x69, 0x6e, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -466,26 +521,29 @@ func file_racing_racing_proto_rawDescGZIP() []byte { } var file_racing_racing_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_racing_racing_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_racing_racing_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_racing_racing_proto_goTypes = []interface{}{ (SortDirection)(0), // 0: racing.SortDirection (RaceStatus)(0), // 1: racing.RaceStatus (*ListRacesRequest)(nil), // 2: racing.ListRacesRequest (*ListRacesResponse)(nil), // 3: racing.ListRacesResponse - (*ListRacesRequestFilter)(nil), // 4: racing.ListRacesRequestFilter - (*Race)(nil), // 5: racing.Race - (*timestamppb.Timestamp)(nil), // 6: google.protobuf.Timestamp + (*GetRaceRequest)(nil), // 4: racing.GetRaceRequest + (*ListRacesRequestFilter)(nil), // 5: racing.ListRacesRequestFilter + (*Race)(nil), // 6: racing.Race + (*timestamppb.Timestamp)(nil), // 7: google.protobuf.Timestamp } var file_racing_racing_proto_depIdxs = []int32{ - 4, // 0: racing.ListRacesRequest.filter:type_name -> racing.ListRacesRequestFilter - 5, // 1: racing.ListRacesResponse.races:type_name -> racing.Race + 5, // 0: racing.ListRacesRequest.filter:type_name -> racing.ListRacesRequestFilter + 6, // 1: racing.ListRacesResponse.races:type_name -> racing.Race 0, // 2: racing.ListRacesRequestFilter.sort_direction:type_name -> racing.SortDirection - 6, // 3: racing.Race.advertised_start_time:type_name -> google.protobuf.Timestamp + 7, // 3: racing.Race.advertised_start_time:type_name -> google.protobuf.Timestamp 1, // 4: racing.Race.status:type_name -> racing.RaceStatus 2, // 5: racing.Racing.ListRaces:input_type -> racing.ListRacesRequest - 3, // 6: racing.Racing.ListRaces:output_type -> racing.ListRacesResponse - 6, // [6:7] is the sub-list for method output_type - 5, // [5:6] is the sub-list for method input_type + 4, // 6: racing.Racing.GetRace:input_type -> racing.GetRaceRequest + 3, // 7: racing.Racing.ListRaces:output_type -> racing.ListRacesResponse + 6, // 8: racing.Racing.GetRace:output_type -> racing.Race + 7, // [7:9] is the sub-list for method output_type + 5, // [5:7] 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 @@ -522,7 +580,7 @@ func file_racing_racing_proto_init() { } } file_racing_racing_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListRacesRequestFilter); i { + switch v := v.(*GetRaceRequest); i { case 0: return &v.state case 1: @@ -534,6 +592,18 @@ func file_racing_racing_proto_init() { } } file_racing_racing_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListRacesRequestFilter); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_racing_racing_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Race); i { case 0: return &v.state @@ -546,14 +616,14 @@ func file_racing_racing_proto_init() { } } } - file_racing_racing_proto_msgTypes[2].OneofWrappers = []interface{}{} + file_racing_racing_proto_msgTypes[3].OneofWrappers = []interface{}{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_racing_racing_proto_rawDesc, NumEnums: 2, - NumMessages: 4, + NumMessages: 5, NumExtensions: 0, NumServices: 1, }, diff --git a/racing/proto/racing/racing.proto b/racing/proto/racing/racing.proto index 175de9b..857fe81 100644 --- a/racing/proto/racing/racing.proto +++ b/racing/proto/racing/racing.proto @@ -24,6 +24,8 @@ enum RaceStatus { service Racing { // ListRaces will return a collection of all races. rpc ListRaces(ListRacesRequest) returns (ListRacesResponse) {} + // GetRace returns a single race by resource name (races/{race}). Returns NOT_FOUND if it doesn't exist. + rpc GetRace(GetRaceRequest) returns (Race) {} } /* Requests/Responses */ @@ -37,6 +39,13 @@ message ListRacesResponse { repeated Race races = 1; } +// Request for a single race using its resource name. +message GetRaceRequest { + // The resource name of the race to retrieve. + // Format: races/{race} + string name = 1; // required +} + // Filter for listing races. message ListRacesRequestFilter { repeated int64 meeting_ids = 1; diff --git a/racing/proto/racing/racing_grpc.pb.go b/racing/proto/racing/racing_grpc.pb.go index 44b6818..7548ab9 100644 --- a/racing/proto/racing/racing_grpc.pb.go +++ b/racing/proto/racing/racing_grpc.pb.go @@ -20,6 +20,8 @@ const _ = grpc.SupportPackageIsVersion7 type RacingClient interface { // ListRaces will return a collection of all races. ListRaces(ctx context.Context, in *ListRacesRequest, opts ...grpc.CallOption) (*ListRacesResponse, error) + // GetRace returns a single race by resource name (races/{race}). Returns NOT_FOUND if it doesn't exist. + GetRace(ctx context.Context, in *GetRaceRequest, opts ...grpc.CallOption) (*Race, error) } type racingClient struct { @@ -39,12 +41,23 @@ func (c *racingClient) ListRaces(ctx context.Context, in *ListRacesRequest, opts return out, nil } +func (c *racingClient) GetRace(ctx context.Context, in *GetRaceRequest, opts ...grpc.CallOption) (*Race, error) { + out := new(Race) + err := c.cc.Invoke(ctx, "/racing.Racing/GetRace", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // RacingServer is the server API for Racing service. // All implementations should embed UnimplementedRacingServer // for forward compatibility type RacingServer interface { // ListRaces will return a collection of all races. ListRaces(context.Context, *ListRacesRequest) (*ListRacesResponse, error) + // GetRace returns a single race by resource name (races/{race}). Returns NOT_FOUND if it doesn't exist. + GetRace(context.Context, *GetRaceRequest) (*Race, error) } // UnimplementedRacingServer should be embedded to have forward compatible implementations. @@ -54,6 +67,9 @@ type UnimplementedRacingServer struct { func (UnimplementedRacingServer) ListRaces(context.Context, *ListRacesRequest) (*ListRacesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ListRaces not implemented") } +func (UnimplementedRacingServer) GetRace(context.Context, *GetRaceRequest) (*Race, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetRace not implemented") +} // UnsafeRacingServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to RacingServer will @@ -84,6 +100,24 @@ func _Racing_ListRaces_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _Racing_GetRace_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetRaceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RacingServer).GetRace(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/racing.Racing/GetRace", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RacingServer).GetRace(ctx, req.(*GetRaceRequest)) + } + return interceptor(ctx, in, info, handler) +} + // Racing_ServiceDesc is the grpc.ServiceDesc for Racing service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -95,6 +129,10 @@ var Racing_ServiceDesc = grpc.ServiceDesc{ MethodName: "ListRaces", Handler: _Racing_ListRaces_Handler, }, + { + MethodName: "GetRace", + Handler: _Racing_GetRace_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "racing/racing.proto", diff --git a/racing/service/racing.go b/racing/service/racing.go index 1960430..e0bd15a 100644 --- a/racing/service/racing.go +++ b/racing/service/racing.go @@ -1,14 +1,21 @@ package service import ( + "fmt" + "strings" + "git.neds.sh/matty/entain/racing/db" "git.neds.sh/matty/entain/racing/proto/racing" "golang.org/x/net/context" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" ) type Racing interface { // ListRaces will return a collection of races. ListRaces(ctx context.Context, in *racing.ListRacesRequest) (*racing.ListRacesResponse, error) + // GetRace returns a single race. + GetRace(ctx context.Context, in *racing.GetRaceRequest) (*racing.Race, error) } // racingService implements the Racing interface. @@ -29,3 +36,26 @@ func (s *racingService) ListRaces(ctx context.Context, in *racing.ListRacesReque return &racing.ListRacesResponse{Races: races}, nil } + +func (s *racingService) GetRace(ctx context.Context, in *racing.GetRaceRequest) (*racing.Race, error) { + if in.GetName() == "" { + return nil, status.Error(codes.InvalidArgument, "name is required") + } + parts := strings.Split(in.GetName(), "/") + if len(parts) != 2 || parts[0] != "races" || parts[1] == "" { + return nil, status.Error(codes.InvalidArgument, "name must be in format races/{id}") + } + var id int64 + _, err := fmt.Sscanf(parts[1], "%d", &id) + if err != nil { + return nil, status.Error(codes.InvalidArgument, "id must be integer in resource name") + } + race, err := s.racesRepo.Get(id) + if err != nil { + return nil, status.Errorf(codes.Internal, "get race: %v", err) + } + if race == nil { + return nil, status.Error(codes.NotFound, "race not found") + } + return race, nil +} From 112fcd17f7520bb6db08538ac73aab2c07a15441 Mon Sep 17 00:00:00 2001 From: benrobey Date: Sun, 17 Aug 2025 19:16:45 +1000 Subject: [PATCH 2/3] Revert "Adds `GetRace`" This reverts commit 3df86292b56d4f40af7dfd586e477a98ab5c5efe. --- api/proto/racing/racing.pb.go | 205 +++++++++----------------- api/proto/racing/racing.pb.gw.go | 99 ------------- api/proto/racing/racing.proto | 10 -- api/proto/racing/racing_grpc.pb.go | 38 ----- racing/db/races.go | 29 ---- racing/proto/racing.go | 2 +- racing/proto/racing/racing.pb.go | 202 +++++++++---------------- racing/proto/racing/racing.proto | 9 -- racing/proto/racing/racing_grpc.pb.go | 38 ----- racing/service/racing.go | 30 ---- 10 files changed, 134 insertions(+), 528 deletions(-) diff --git a/api/proto/racing/racing.pb.go b/api/proto/racing/racing.pb.go index 0ee711e..feef067 100644 --- a/api/proto/racing/racing.pb.go +++ b/api/proto/racing/racing.pb.go @@ -218,55 +218,6 @@ func (x *ListRacesResponse) GetRaces() []*Race { return nil } -type GetRaceRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The resource name of the race to retrieve. - // Format: races/{race} - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // required -} - -func (x *GetRaceRequest) Reset() { - *x = GetRaceRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_racing_racing_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetRaceRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetRaceRequest) ProtoMessage() {} - -func (x *GetRaceRequest) ProtoReflect() protoreflect.Message { - mi := &file_racing_racing_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetRaceRequest.ProtoReflect.Descriptor instead. -func (*GetRaceRequest) Descriptor() ([]byte, []int) { - return file_racing_racing_proto_rawDescGZIP(), []int{2} -} - -func (x *GetRaceRequest) GetName() string { - if x != nil { - return x.Name - } - return "" -} - // Filter for listing races. type ListRacesRequestFilter struct { state protoimpl.MessageState @@ -285,7 +236,7 @@ type ListRacesRequestFilter struct { func (x *ListRacesRequestFilter) Reset() { *x = ListRacesRequestFilter{} if protoimpl.UnsafeEnabled { - mi := &file_racing_racing_proto_msgTypes[3] + mi := &file_racing_racing_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -298,7 +249,7 @@ func (x *ListRacesRequestFilter) String() string { func (*ListRacesRequestFilter) ProtoMessage() {} func (x *ListRacesRequestFilter) ProtoReflect() protoreflect.Message { - mi := &file_racing_racing_proto_msgTypes[3] + mi := &file_racing_racing_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -311,7 +262,7 @@ func (x *ListRacesRequestFilter) ProtoReflect() protoreflect.Message { // Deprecated: Use ListRacesRequestFilter.ProtoReflect.Descriptor instead. func (*ListRacesRequestFilter) Descriptor() ([]byte, []int) { - return file_racing_racing_proto_rawDescGZIP(), []int{3} + return file_racing_racing_proto_rawDescGZIP(), []int{2} } func (x *ListRacesRequestFilter) GetMeetingIds() []int64 { @@ -360,7 +311,7 @@ type Race struct { func (x *Race) Reset() { *x = Race{} if protoimpl.UnsafeEnabled { - mi := &file_racing_racing_proto_msgTypes[4] + mi := &file_racing_racing_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -373,7 +324,7 @@ func (x *Race) String() string { func (*Race) ProtoMessage() {} func (x *Race) ProtoReflect() protoreflect.Message { - mi := &file_racing_racing_proto_msgTypes[4] + mi := &file_racing_racing_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -386,7 +337,7 @@ func (x *Race) ProtoReflect() protoreflect.Message { // Deprecated: Use Race.ProtoReflect.Descriptor instead. func (*Race) Descriptor() ([]byte, []int) { - return file_racing_racing_proto_rawDescGZIP(), []int{4} + return file_racing_racing_proto_rawDescGZIP(), []int{3} } func (x *Race) GetId() int64 { @@ -455,61 +406,54 @@ var file_racing_racing_proto_rawDesc = []byte{ 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x22, 0x0a, 0x05, 0x72, 0x61, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, 0x63, 0x65, 0x52, 0x05, 0x72, 0x61, 0x63, 0x65, - 0x73, 0x22, 0x24, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x52, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xc8, 0x01, 0x0a, 0x16, 0x4c, 0x69, 0x73, 0x74, - 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x69, 0x6c, 0x74, - 0x65, 0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x69, 0x64, - 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x03, 0x52, 0x0a, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, - 0x49, 0x64, 0x73, 0x12, 0x26, 0x0a, 0x0c, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x5f, 0x6f, - 0x6e, 0x6c, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x0b, 0x76, 0x69, 0x73, - 0x69, 0x62, 0x6c, 0x65, 0x4f, 0x6e, 0x6c, 0x79, 0x88, 0x01, 0x01, 0x12, 0x41, 0x0a, 0x0e, 0x73, - 0x6f, 0x72, 0x74, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x53, 0x6f, 0x72, - 0x74, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x01, 0x52, 0x0d, 0x73, 0x6f, - 0x72, 0x74, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, 0x01, 0x42, 0x0f, - 0x0a, 0x0d, 0x5f, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x42, - 0x11, 0x0a, 0x0f, 0x5f, 0x73, 0x6f, 0x72, 0x74, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x22, 0xf7, 0x01, 0x0a, 0x04, 0x52, 0x61, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, - 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x09, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, - 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, - 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, - 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, - 0x12, 0x4e, 0x0a, 0x15, 0x61, 0x64, 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x65, 0x64, 0x5f, 0x73, - 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x13, 0x61, 0x64, 0x76, - 0x65, 0x72, 0x74, 0x69, 0x73, 0x65, 0x64, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, - 0x12, 0x2a, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x12, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, 0x63, 0x65, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2a, 0x60, 0x0a, 0x0d, - 0x53, 0x6f, 0x72, 0x74, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, - 0x1a, 0x53, 0x4f, 0x52, 0x54, 0x5f, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, - 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x16, 0x0a, - 0x12, 0x53, 0x4f, 0x52, 0x54, 0x5f, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, - 0x41, 0x53, 0x43, 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, 0x53, 0x4f, 0x52, 0x54, 0x5f, 0x44, 0x49, - 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x44, 0x45, 0x53, 0x43, 0x10, 0x02, 0x2a, 0x57, - 0x0a, 0x0a, 0x52, 0x61, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1b, 0x0a, 0x17, - 0x52, 0x41, 0x43, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, - 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x52, 0x41, 0x43, - 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x4f, 0x50, 0x45, 0x4e, 0x10, 0x01, 0x12, - 0x16, 0x0a, 0x12, 0x52, 0x41, 0x43, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x43, - 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x10, 0x02, 0x32, 0xb2, 0x01, 0x0a, 0x06, 0x52, 0x61, 0x63, 0x69, - 0x6e, 0x67, 0x12, 0x5b, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x12, - 0x18, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, - 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x61, 0x63, 0x69, - 0x6e, 0x67, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x22, 0x0e, 0x2f, 0x76, - 0x31, 0x2f, 0x6c, 0x69, 0x73, 0x74, 0x2d, 0x72, 0x61, 0x63, 0x65, 0x73, 0x3a, 0x01, 0x2a, 0x12, - 0x4b, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x52, 0x61, 0x63, 0x65, 0x12, 0x16, 0x2e, 0x72, 0x61, 0x63, - 0x69, 0x6e, 0x67, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, 0x63, 0x65, - 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x12, 0x12, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, - 0x61, 0x6d, 0x65, 0x3d, 0x72, 0x61, 0x63, 0x65, 0x73, 0x2f, 0x2a, 0x7d, 0x42, 0x09, 0x5a, 0x07, - 0x2f, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x22, 0xc8, 0x01, 0x0a, 0x16, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x1f, 0x0a, 0x0b, + 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, + 0x03, 0x52, 0x0a, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x49, 0x64, 0x73, 0x12, 0x26, 0x0a, + 0x0c, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x0b, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x4f, 0x6e, + 0x6c, 0x79, 0x88, 0x01, 0x01, 0x12, 0x41, 0x0a, 0x0e, 0x73, 0x6f, 0x72, 0x74, 0x5f, 0x64, 0x69, + 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, + 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x53, 0x6f, 0x72, 0x74, 0x44, 0x69, 0x72, 0x65, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x01, 0x52, 0x0d, 0x73, 0x6f, 0x72, 0x74, 0x44, 0x69, 0x72, 0x65, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, 0x01, 0x42, 0x0f, 0x0a, 0x0d, 0x5f, 0x76, 0x69, 0x73, + 0x69, 0x62, 0x6c, 0x65, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x42, 0x11, 0x0a, 0x0f, 0x5f, 0x73, 0x6f, + 0x72, 0x74, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xf7, 0x01, 0x0a, + 0x04, 0x52, 0x61, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, + 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x6d, 0x65, 0x65, 0x74, 0x69, + 0x6e, 0x67, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, + 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, + 0x12, 0x18, 0x0a, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x12, 0x4e, 0x0a, 0x15, 0x61, 0x64, + 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x65, 0x64, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, + 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x13, 0x61, 0x64, 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x65, + 0x64, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x2a, 0x0a, 0x06, 0x73, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x72, 0x61, 0x63, + 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2a, 0x60, 0x0a, 0x0d, 0x53, 0x6f, 0x72, 0x74, 0x44, 0x69, + 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x1a, 0x53, 0x4f, 0x52, 0x54, 0x5f, + 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, + 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x4f, 0x52, 0x54, 0x5f, + 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x41, 0x53, 0x43, 0x10, 0x01, 0x12, + 0x17, 0x0a, 0x13, 0x53, 0x4f, 0x52, 0x54, 0x5f, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, + 0x4e, 0x5f, 0x44, 0x45, 0x53, 0x43, 0x10, 0x02, 0x2a, 0x57, 0x0a, 0x0a, 0x52, 0x61, 0x63, 0x65, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1b, 0x0a, 0x17, 0x52, 0x41, 0x43, 0x45, 0x5f, 0x53, + 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, + 0x44, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x52, 0x41, 0x43, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, + 0x55, 0x53, 0x5f, 0x4f, 0x50, 0x45, 0x4e, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x52, 0x41, 0x43, + 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x10, + 0x02, 0x32, 0x65, 0x0a, 0x06, 0x52, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x12, 0x5b, 0x0a, 0x09, 0x4c, + 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x12, 0x18, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, + 0x67, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x4c, 0x69, 0x73, 0x74, + 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, + 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x22, 0x0e, 0x2f, 0x76, 0x31, 0x2f, 0x6c, 0x69, 0x73, 0x74, 0x2d, + 0x72, 0x61, 0x63, 0x65, 0x73, 0x3a, 0x01, 0x2a, 0x42, 0x09, 0x5a, 0x07, 0x2f, 0x72, 0x61, 0x63, + 0x69, 0x6e, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -525,29 +469,26 @@ func file_racing_racing_proto_rawDescGZIP() []byte { } var file_racing_racing_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_racing_racing_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_racing_racing_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_racing_racing_proto_goTypes = []interface{}{ (SortDirection)(0), // 0: racing.SortDirection (RaceStatus)(0), // 1: racing.RaceStatus (*ListRacesRequest)(nil), // 2: racing.ListRacesRequest (*ListRacesResponse)(nil), // 3: racing.ListRacesResponse - (*GetRaceRequest)(nil), // 4: racing.GetRaceRequest - (*ListRacesRequestFilter)(nil), // 5: racing.ListRacesRequestFilter - (*Race)(nil), // 6: racing.Race - (*timestamppb.Timestamp)(nil), // 7: google.protobuf.Timestamp + (*ListRacesRequestFilter)(nil), // 4: racing.ListRacesRequestFilter + (*Race)(nil), // 5: racing.Race + (*timestamppb.Timestamp)(nil), // 6: google.protobuf.Timestamp } var file_racing_racing_proto_depIdxs = []int32{ - 5, // 0: racing.ListRacesRequest.filter:type_name -> racing.ListRacesRequestFilter - 6, // 1: racing.ListRacesResponse.races:type_name -> racing.Race + 4, // 0: racing.ListRacesRequest.filter:type_name -> racing.ListRacesRequestFilter + 5, // 1: racing.ListRacesResponse.races:type_name -> racing.Race 0, // 2: racing.ListRacesRequestFilter.sort_direction:type_name -> racing.SortDirection - 7, // 3: racing.Race.advertised_start_time:type_name -> google.protobuf.Timestamp + 6, // 3: racing.Race.advertised_start_time:type_name -> google.protobuf.Timestamp 1, // 4: racing.Race.status:type_name -> racing.RaceStatus 2, // 5: racing.Racing.ListRaces:input_type -> racing.ListRacesRequest - 4, // 6: racing.Racing.GetRace:input_type -> racing.GetRaceRequest - 3, // 7: racing.Racing.ListRaces:output_type -> racing.ListRacesResponse - 6, // 8: racing.Racing.GetRace:output_type -> racing.Race - 7, // [7:9] is the sub-list for method output_type - 5, // [5:7] is the sub-list for method input_type + 3, // 6: racing.Racing.ListRaces:output_type -> racing.ListRacesResponse + 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 @@ -584,18 +525,6 @@ func file_racing_racing_proto_init() { } } file_racing_racing_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetRaceRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_racing_racing_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListRacesRequestFilter); i { case 0: return &v.state @@ -607,7 +536,7 @@ func file_racing_racing_proto_init() { return nil } } - file_racing_racing_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_racing_racing_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Race); i { case 0: return &v.state @@ -620,14 +549,14 @@ func file_racing_racing_proto_init() { } } } - file_racing_racing_proto_msgTypes[3].OneofWrappers = []interface{}{} + file_racing_racing_proto_msgTypes[2].OneofWrappers = []interface{}{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_racing_racing_proto_rawDesc, NumEnums: 2, - NumMessages: 5, + NumMessages: 4, NumExtensions: 0, NumServices: 1, }, diff --git a/api/proto/racing/racing.pb.gw.go b/api/proto/racing/racing.pb.gw.go index 115ef9c..3f34377 100644 --- a/api/proto/racing/racing.pb.gw.go +++ b/api/proto/racing/racing.pb.gw.go @@ -65,58 +65,6 @@ func local_request_Racing_ListRaces_0(ctx context.Context, marshaler runtime.Mar } -func request_Racing_GetRace_0(ctx context.Context, marshaler runtime.Marshaler, client RacingClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetRaceRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["name"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") - } - - protoReq.Name, err = runtime.String(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) - } - - msg, err := client.GetRace(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Racing_GetRace_0(ctx context.Context, marshaler runtime.Marshaler, server RacingServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetRaceRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["name"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") - } - - protoReq.Name, err = runtime.String(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) - } - - msg, err := server.GetRace(ctx, &protoReq) - return msg, metadata, err - -} - // RegisterRacingHandlerServer registers the http handlers for service Racing to "mux". // UnaryRPC :call RacingServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -146,29 +94,6 @@ func RegisterRacingHandlerServer(ctx context.Context, mux *runtime.ServeMux, ser }) - mux.Handle("GET", pattern_Racing_GetRace_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/racing.Racing/GetRace") - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Racing_GetRace_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Racing_GetRace_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - return nil } @@ -230,37 +155,13 @@ func RegisterRacingHandlerClient(ctx context.Context, mux *runtime.ServeMux, cli }) - mux.Handle("GET", pattern_Racing_GetRace_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req, "/racing.Racing/GetRace") - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Racing_GetRace_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Racing_GetRace_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - return nil } var ( pattern_Racing_ListRaces_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "list-races"}, "")) - - pattern_Racing_GetRace_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "races", "name"}, "")) ) var ( forward_Racing_ListRaces_0 = runtime.ForwardResponseMessage - - forward_Racing_GetRace_0 = runtime.ForwardResponseMessage ) diff --git a/api/proto/racing/racing.proto b/api/proto/racing/racing.proto index fe2e547..e7fa1d4 100644 --- a/api/proto/racing/racing.proto +++ b/api/proto/racing/racing.proto @@ -25,10 +25,6 @@ service Racing { rpc ListRaces(ListRacesRequest) returns (ListRacesResponse) { option (google.api.http) = { post: "/v1/list-races", body: "*" }; } - // GetRace returns a single race by resource name. - rpc GetRace(GetRaceRequest) returns (Race) { - option (google.api.http) = { get: "/v1/{name=races/*}" }; - } } /* Requests/Responses */ @@ -43,12 +39,6 @@ message ListRacesResponse { repeated Race races = 1; } -message GetRaceRequest { - // The resource name of the race to retrieve. - // Format: races/{race} - string name = 1; // required -} - // Filter for listing races. message ListRacesRequestFilter { repeated int64 meeting_ids = 1; diff --git a/api/proto/racing/racing_grpc.pb.go b/api/proto/racing/racing_grpc.pb.go index 1b13fde..6325105 100644 --- a/api/proto/racing/racing_grpc.pb.go +++ b/api/proto/racing/racing_grpc.pb.go @@ -20,8 +20,6 @@ const _ = grpc.SupportPackageIsVersion7 type RacingClient interface { // ListRaces returns a list of all races. ListRaces(ctx context.Context, in *ListRacesRequest, opts ...grpc.CallOption) (*ListRacesResponse, error) - // GetRace returns a single race by resource name. - GetRace(ctx context.Context, in *GetRaceRequest, opts ...grpc.CallOption) (*Race, error) } type racingClient struct { @@ -41,23 +39,12 @@ func (c *racingClient) ListRaces(ctx context.Context, in *ListRacesRequest, opts return out, nil } -func (c *racingClient) GetRace(ctx context.Context, in *GetRaceRequest, opts ...grpc.CallOption) (*Race, error) { - out := new(Race) - err := c.cc.Invoke(ctx, "/racing.Racing/GetRace", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - // RacingServer is the server API for Racing service. // All implementations must embed UnimplementedRacingServer // for forward compatibility type RacingServer interface { // ListRaces returns a list of all races. ListRaces(context.Context, *ListRacesRequest) (*ListRacesResponse, error) - // GetRace returns a single race by resource name. - GetRace(context.Context, *GetRaceRequest) (*Race, error) mustEmbedUnimplementedRacingServer() } @@ -68,9 +55,6 @@ type UnimplementedRacingServer struct { func (UnimplementedRacingServer) ListRaces(context.Context, *ListRacesRequest) (*ListRacesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ListRaces not implemented") } -func (UnimplementedRacingServer) GetRace(context.Context, *GetRaceRequest) (*Race, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetRace not implemented") -} func (UnimplementedRacingServer) mustEmbedUnimplementedRacingServer() {} // UnsafeRacingServer may be embedded to opt out of forward compatibility for this service. @@ -102,24 +86,6 @@ func _Racing_ListRaces_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } -func _Racing_GetRace_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetRaceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RacingServer).GetRace(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/racing.Racing/GetRace", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RacingServer).GetRace(ctx, req.(*GetRaceRequest)) - } - return interceptor(ctx, in, info, handler) -} - // Racing_ServiceDesc is the grpc.ServiceDesc for Racing service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -131,10 +97,6 @@ var Racing_ServiceDesc = grpc.ServiceDesc{ MethodName: "ListRaces", Handler: _Racing_ListRaces_Handler, }, - { - MethodName: "GetRace", - Handler: _Racing_GetRace_Handler, - }, }, Streams: []grpc.StreamDesc{}, Metadata: "racing/racing.proto", diff --git a/racing/db/races.go b/racing/db/races.go index ac58c91..a8eddab 100644 --- a/racing/db/races.go +++ b/racing/db/races.go @@ -19,9 +19,6 @@ type RacesRepo interface { // List will return a list of races. List(filter *racing.ListRacesRequestFilter) ([]*racing.Race, error) - - // Get returns a single race by numeric id. - Get(id int64) (*racing.Race, error) } type racesRepo struct { @@ -65,32 +62,6 @@ func (r *racesRepo) List(filter *racing.ListRacesRequestFilter) ([]*racing.Race, return r.scanRaces(rows) } -func (r *racesRepo) Get(id int64) (*racing.Race, error) { - query := "SELECT id, meeting_id, name, number, visible, advertised_start_time FROM races WHERE id = ? LIMIT 1" - row := r.db.QueryRow(query, id) - var ( - race racing.Race - advertisedStart time.Time - ) - if err := row.Scan(&race.Id, &race.MeetingId, &race.Name, &race.Number, &race.Visible, &advertisedStart); err != nil { - if err == sql.ErrNoRows { - return nil, nil - } - return nil, err - } - ts, err := ptypes.TimestampProto(advertisedStart) - if err != nil { - return nil, err - } - race.AdvertisedStartTime = ts - if advertisedStart.After(time.Now()) { - race.Status = racing.RaceStatus_RACE_STATUS_OPEN - } else { - race.Status = racing.RaceStatus_RACE_STATUS_CLOSED - } - return &race, nil -} - func (r *racesRepo) applyFilter(query string, filter *racing.ListRacesRequestFilter) (string, []interface{}) { var ( clauses []string diff --git a/racing/proto/racing.go b/racing/proto/racing.go index b9f48f4..afc1049 100644 --- a/racing/proto/racing.go +++ b/racing/proto/racing.go @@ -1,3 +1,3 @@ package proto -//go:generate protoc -I . -I ../api/proto -I ../../../../baseline_implementation/api/proto -I %GOPATH%/pkg/mod --go_out=. --go-grpc_out=require_unimplemented_servers=false:. racing/racing.proto --experimental_allow_proto3_optional +//go:generate protoc --go_out=. --go-grpc_out=require_unimplemented_servers=false:. racing/racing.proto --experimental_allow_proto3_optional diff --git a/racing/proto/racing/racing.pb.go b/racing/proto/racing/racing.pb.go index 9b2e887..6c22b8d 100644 --- a/racing/proto/racing/racing.pb.go +++ b/racing/proto/racing/racing.pb.go @@ -218,56 +218,6 @@ func (x *ListRacesResponse) GetRaces() []*Race { return nil } -// Request for a single race using its resource name. -type GetRaceRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The resource name of the race to retrieve. - // Format: races/{race} - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // required -} - -func (x *GetRaceRequest) Reset() { - *x = GetRaceRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_racing_racing_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetRaceRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetRaceRequest) ProtoMessage() {} - -func (x *GetRaceRequest) ProtoReflect() protoreflect.Message { - mi := &file_racing_racing_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetRaceRequest.ProtoReflect.Descriptor instead. -func (*GetRaceRequest) Descriptor() ([]byte, []int) { - return file_racing_racing_proto_rawDescGZIP(), []int{2} -} - -func (x *GetRaceRequest) GetName() string { - if x != nil { - return x.Name - } - return "" -} - // Filter for listing races. type ListRacesRequestFilter struct { state protoimpl.MessageState @@ -286,7 +236,7 @@ type ListRacesRequestFilter struct { func (x *ListRacesRequestFilter) Reset() { *x = ListRacesRequestFilter{} if protoimpl.UnsafeEnabled { - mi := &file_racing_racing_proto_msgTypes[3] + mi := &file_racing_racing_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -299,7 +249,7 @@ func (x *ListRacesRequestFilter) String() string { func (*ListRacesRequestFilter) ProtoMessage() {} func (x *ListRacesRequestFilter) ProtoReflect() protoreflect.Message { - mi := &file_racing_racing_proto_msgTypes[3] + mi := &file_racing_racing_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -312,7 +262,7 @@ func (x *ListRacesRequestFilter) ProtoReflect() protoreflect.Message { // Deprecated: Use ListRacesRequestFilter.ProtoReflect.Descriptor instead. func (*ListRacesRequestFilter) Descriptor() ([]byte, []int) { - return file_racing_racing_proto_rawDescGZIP(), []int{3} + return file_racing_racing_proto_rawDescGZIP(), []int{2} } func (x *ListRacesRequestFilter) GetMeetingIds() []int64 { @@ -361,7 +311,7 @@ type Race struct { func (x *Race) Reset() { *x = Race{} if protoimpl.UnsafeEnabled { - mi := &file_racing_racing_proto_msgTypes[4] + mi := &file_racing_racing_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -374,7 +324,7 @@ func (x *Race) String() string { func (*Race) ProtoMessage() {} func (x *Race) ProtoReflect() protoreflect.Message { - mi := &file_racing_racing_proto_msgTypes[4] + mi := &file_racing_racing_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -387,7 +337,7 @@ func (x *Race) ProtoReflect() protoreflect.Message { // Deprecated: Use Race.ProtoReflect.Descriptor instead. func (*Race) Descriptor() ([]byte, []int) { - return file_racing_racing_proto_rawDescGZIP(), []int{4} + return file_racing_racing_proto_rawDescGZIP(), []int{3} } func (x *Race) GetId() int64 { @@ -454,58 +404,53 @@ var file_racing_racing_proto_rawDesc = []byte{ 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x22, 0x0a, 0x05, 0x72, 0x61, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, 0x63, 0x65, 0x52, 0x05, 0x72, 0x61, - 0x63, 0x65, 0x73, 0x22, 0x24, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x52, 0x61, 0x63, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xc8, 0x01, 0x0a, 0x16, 0x4c, 0x69, - 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x69, - 0x6c, 0x74, 0x65, 0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x5f, - 0x69, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x03, 0x52, 0x0a, 0x6d, 0x65, 0x65, 0x74, 0x69, - 0x6e, 0x67, 0x49, 0x64, 0x73, 0x12, 0x26, 0x0a, 0x0c, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, - 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x0b, 0x76, - 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x4f, 0x6e, 0x6c, 0x79, 0x88, 0x01, 0x01, 0x12, 0x41, 0x0a, - 0x0e, 0x73, 0x6f, 0x72, 0x74, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x53, - 0x6f, 0x72, 0x74, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x01, 0x52, 0x0d, - 0x73, 0x6f, 0x72, 0x74, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, 0x01, - 0x42, 0x0f, 0x0a, 0x0d, 0x5f, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x5f, 0x6f, 0x6e, 0x6c, - 0x79, 0x42, 0x11, 0x0a, 0x0f, 0x5f, 0x73, 0x6f, 0x72, 0x74, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xf7, 0x01, 0x0a, 0x04, 0x52, 0x61, 0x63, 0x65, 0x12, 0x0e, 0x0a, - 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1d, 0x0a, - 0x0a, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x09, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x69, 0x73, 0x69, - 0x62, 0x6c, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, - 0x6c, 0x65, 0x12, 0x4e, 0x0a, 0x15, 0x61, 0x64, 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x65, 0x64, - 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x13, 0x61, - 0x64, 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x65, 0x64, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, - 0x6d, 0x65, 0x12, 0x2a, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x07, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, 0x63, 0x65, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2a, 0x60, - 0x0a, 0x0d, 0x53, 0x6f, 0x72, 0x74, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x1e, 0x0a, 0x1a, 0x53, 0x4f, 0x52, 0x54, 0x5f, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, - 0x4e, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, - 0x16, 0x0a, 0x12, 0x53, 0x4f, 0x52, 0x54, 0x5f, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, - 0x4e, 0x5f, 0x41, 0x53, 0x43, 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, 0x53, 0x4f, 0x52, 0x54, 0x5f, - 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x44, 0x45, 0x53, 0x43, 0x10, 0x02, - 0x2a, 0x57, 0x0a, 0x0a, 0x52, 0x61, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1b, - 0x0a, 0x17, 0x52, 0x41, 0x43, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, - 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x52, - 0x41, 0x43, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x4f, 0x50, 0x45, 0x4e, 0x10, - 0x01, 0x12, 0x16, 0x0a, 0x12, 0x52, 0x41, 0x43, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, - 0x5f, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x10, 0x02, 0x32, 0x7f, 0x0a, 0x06, 0x52, 0x61, 0x63, - 0x69, 0x6e, 0x67, 0x12, 0x42, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, - 0x12, 0x18, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, - 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x61, 0x63, - 0x69, 0x6e, 0x67, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x31, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x52, 0x61, - 0x63, 0x65, 0x12, 0x16, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x47, 0x65, 0x74, 0x52, - 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x72, 0x61, 0x63, - 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, 0x63, 0x65, 0x22, 0x00, 0x42, 0x09, 0x5a, 0x07, 0x2f, 0x72, - 0x61, 0x63, 0x69, 0x6e, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x63, 0x65, 0x73, 0x22, 0xc8, 0x01, 0x0a, 0x16, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x1f, + 0x0a, 0x0b, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x03, 0x52, 0x0a, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x49, 0x64, 0x73, 0x12, + 0x26, 0x0a, 0x0c, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x0b, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, + 0x4f, 0x6e, 0x6c, 0x79, 0x88, 0x01, 0x01, 0x12, 0x41, 0x0a, 0x0e, 0x73, 0x6f, 0x72, 0x74, 0x5f, + 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x15, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x53, 0x6f, 0x72, 0x74, 0x44, 0x69, 0x72, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x01, 0x52, 0x0d, 0x73, 0x6f, 0x72, 0x74, 0x44, 0x69, + 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, 0x01, 0x42, 0x0f, 0x0a, 0x0d, 0x5f, 0x76, + 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x42, 0x11, 0x0a, 0x0f, 0x5f, + 0x73, 0x6f, 0x72, 0x74, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xf7, + 0x01, 0x0a, 0x04, 0x52, 0x61, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x65, 0x65, 0x74, 0x69, + 0x6e, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x6d, 0x65, 0x65, + 0x74, 0x69, 0x6e, 0x67, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, + 0x6d, 0x62, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, + 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x12, 0x4e, 0x0a, 0x15, + 0x61, 0x64, 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x65, 0x64, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, + 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x13, 0x61, 0x64, 0x76, 0x65, 0x72, 0x74, 0x69, + 0x73, 0x65, 0x64, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x2a, 0x0a, 0x06, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x72, + 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2a, 0x60, 0x0a, 0x0d, 0x53, 0x6f, 0x72, 0x74, + 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x1a, 0x53, 0x4f, 0x52, + 0x54, 0x5f, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x55, 0x4e, 0x53, 0x50, + 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x4f, 0x52, + 0x54, 0x5f, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x41, 0x53, 0x43, 0x10, + 0x01, 0x12, 0x17, 0x0a, 0x13, 0x53, 0x4f, 0x52, 0x54, 0x5f, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, + 0x49, 0x4f, 0x4e, 0x5f, 0x44, 0x45, 0x53, 0x43, 0x10, 0x02, 0x2a, 0x57, 0x0a, 0x0a, 0x52, 0x61, + 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1b, 0x0a, 0x17, 0x52, 0x41, 0x43, 0x45, + 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, + 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x52, 0x41, 0x43, 0x45, 0x5f, 0x53, 0x54, + 0x41, 0x54, 0x55, 0x53, 0x5f, 0x4f, 0x50, 0x45, 0x4e, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x52, + 0x41, 0x43, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x43, 0x4c, 0x4f, 0x53, 0x45, + 0x44, 0x10, 0x02, 0x32, 0x4c, 0x0a, 0x06, 0x52, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x12, 0x42, 0x0a, + 0x09, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x12, 0x18, 0x2e, 0x72, 0x61, 0x63, + 0x69, 0x6e, 0x67, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x4c, 0x69, + 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x42, 0x09, 0x5a, 0x07, 0x2f, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -521,29 +466,26 @@ func file_racing_racing_proto_rawDescGZIP() []byte { } var file_racing_racing_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_racing_racing_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_racing_racing_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_racing_racing_proto_goTypes = []interface{}{ (SortDirection)(0), // 0: racing.SortDirection (RaceStatus)(0), // 1: racing.RaceStatus (*ListRacesRequest)(nil), // 2: racing.ListRacesRequest (*ListRacesResponse)(nil), // 3: racing.ListRacesResponse - (*GetRaceRequest)(nil), // 4: racing.GetRaceRequest - (*ListRacesRequestFilter)(nil), // 5: racing.ListRacesRequestFilter - (*Race)(nil), // 6: racing.Race - (*timestamppb.Timestamp)(nil), // 7: google.protobuf.Timestamp + (*ListRacesRequestFilter)(nil), // 4: racing.ListRacesRequestFilter + (*Race)(nil), // 5: racing.Race + (*timestamppb.Timestamp)(nil), // 6: google.protobuf.Timestamp } var file_racing_racing_proto_depIdxs = []int32{ - 5, // 0: racing.ListRacesRequest.filter:type_name -> racing.ListRacesRequestFilter - 6, // 1: racing.ListRacesResponse.races:type_name -> racing.Race + 4, // 0: racing.ListRacesRequest.filter:type_name -> racing.ListRacesRequestFilter + 5, // 1: racing.ListRacesResponse.races:type_name -> racing.Race 0, // 2: racing.ListRacesRequestFilter.sort_direction:type_name -> racing.SortDirection - 7, // 3: racing.Race.advertised_start_time:type_name -> google.protobuf.Timestamp + 6, // 3: racing.Race.advertised_start_time:type_name -> google.protobuf.Timestamp 1, // 4: racing.Race.status:type_name -> racing.RaceStatus 2, // 5: racing.Racing.ListRaces:input_type -> racing.ListRacesRequest - 4, // 6: racing.Racing.GetRace:input_type -> racing.GetRaceRequest - 3, // 7: racing.Racing.ListRaces:output_type -> racing.ListRacesResponse - 6, // 8: racing.Racing.GetRace:output_type -> racing.Race - 7, // [7:9] is the sub-list for method output_type - 5, // [5:7] is the sub-list for method input_type + 3, // 6: racing.Racing.ListRaces:output_type -> racing.ListRacesResponse + 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 @@ -580,18 +522,6 @@ func file_racing_racing_proto_init() { } } file_racing_racing_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetRaceRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_racing_racing_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListRacesRequestFilter); i { case 0: return &v.state @@ -603,7 +533,7 @@ func file_racing_racing_proto_init() { return nil } } - file_racing_racing_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_racing_racing_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Race); i { case 0: return &v.state @@ -616,14 +546,14 @@ func file_racing_racing_proto_init() { } } } - file_racing_racing_proto_msgTypes[3].OneofWrappers = []interface{}{} + file_racing_racing_proto_msgTypes[2].OneofWrappers = []interface{}{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_racing_racing_proto_rawDesc, NumEnums: 2, - NumMessages: 5, + NumMessages: 4, NumExtensions: 0, NumServices: 1, }, diff --git a/racing/proto/racing/racing.proto b/racing/proto/racing/racing.proto index 857fe81..175de9b 100644 --- a/racing/proto/racing/racing.proto +++ b/racing/proto/racing/racing.proto @@ -24,8 +24,6 @@ enum RaceStatus { service Racing { // ListRaces will return a collection of all races. rpc ListRaces(ListRacesRequest) returns (ListRacesResponse) {} - // GetRace returns a single race by resource name (races/{race}). Returns NOT_FOUND if it doesn't exist. - rpc GetRace(GetRaceRequest) returns (Race) {} } /* Requests/Responses */ @@ -39,13 +37,6 @@ message ListRacesResponse { repeated Race races = 1; } -// Request for a single race using its resource name. -message GetRaceRequest { - // The resource name of the race to retrieve. - // Format: races/{race} - string name = 1; // required -} - // Filter for listing races. message ListRacesRequestFilter { repeated int64 meeting_ids = 1; diff --git a/racing/proto/racing/racing_grpc.pb.go b/racing/proto/racing/racing_grpc.pb.go index 7548ab9..44b6818 100644 --- a/racing/proto/racing/racing_grpc.pb.go +++ b/racing/proto/racing/racing_grpc.pb.go @@ -20,8 +20,6 @@ const _ = grpc.SupportPackageIsVersion7 type RacingClient interface { // ListRaces will return a collection of all races. ListRaces(ctx context.Context, in *ListRacesRequest, opts ...grpc.CallOption) (*ListRacesResponse, error) - // GetRace returns a single race by resource name (races/{race}). Returns NOT_FOUND if it doesn't exist. - GetRace(ctx context.Context, in *GetRaceRequest, opts ...grpc.CallOption) (*Race, error) } type racingClient struct { @@ -41,23 +39,12 @@ func (c *racingClient) ListRaces(ctx context.Context, in *ListRacesRequest, opts return out, nil } -func (c *racingClient) GetRace(ctx context.Context, in *GetRaceRequest, opts ...grpc.CallOption) (*Race, error) { - out := new(Race) - err := c.cc.Invoke(ctx, "/racing.Racing/GetRace", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - // RacingServer is the server API for Racing service. // All implementations should embed UnimplementedRacingServer // for forward compatibility type RacingServer interface { // ListRaces will return a collection of all races. ListRaces(context.Context, *ListRacesRequest) (*ListRacesResponse, error) - // GetRace returns a single race by resource name (races/{race}). Returns NOT_FOUND if it doesn't exist. - GetRace(context.Context, *GetRaceRequest) (*Race, error) } // UnimplementedRacingServer should be embedded to have forward compatible implementations. @@ -67,9 +54,6 @@ type UnimplementedRacingServer struct { func (UnimplementedRacingServer) ListRaces(context.Context, *ListRacesRequest) (*ListRacesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ListRaces not implemented") } -func (UnimplementedRacingServer) GetRace(context.Context, *GetRaceRequest) (*Race, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetRace not implemented") -} // UnsafeRacingServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to RacingServer will @@ -100,24 +84,6 @@ func _Racing_ListRaces_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } -func _Racing_GetRace_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetRaceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RacingServer).GetRace(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/racing.Racing/GetRace", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RacingServer).GetRace(ctx, req.(*GetRaceRequest)) - } - return interceptor(ctx, in, info, handler) -} - // Racing_ServiceDesc is the grpc.ServiceDesc for Racing service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -129,10 +95,6 @@ var Racing_ServiceDesc = grpc.ServiceDesc{ MethodName: "ListRaces", Handler: _Racing_ListRaces_Handler, }, - { - MethodName: "GetRace", - Handler: _Racing_GetRace_Handler, - }, }, Streams: []grpc.StreamDesc{}, Metadata: "racing/racing.proto", diff --git a/racing/service/racing.go b/racing/service/racing.go index e0bd15a..1960430 100644 --- a/racing/service/racing.go +++ b/racing/service/racing.go @@ -1,21 +1,14 @@ package service import ( - "fmt" - "strings" - "git.neds.sh/matty/entain/racing/db" "git.neds.sh/matty/entain/racing/proto/racing" "golang.org/x/net/context" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" ) type Racing interface { // ListRaces will return a collection of races. ListRaces(ctx context.Context, in *racing.ListRacesRequest) (*racing.ListRacesResponse, error) - // GetRace returns a single race. - GetRace(ctx context.Context, in *racing.GetRaceRequest) (*racing.Race, error) } // racingService implements the Racing interface. @@ -36,26 +29,3 @@ func (s *racingService) ListRaces(ctx context.Context, in *racing.ListRacesReque return &racing.ListRacesResponse{Races: races}, nil } - -func (s *racingService) GetRace(ctx context.Context, in *racing.GetRaceRequest) (*racing.Race, error) { - if in.GetName() == "" { - return nil, status.Error(codes.InvalidArgument, "name is required") - } - parts := strings.Split(in.GetName(), "/") - if len(parts) != 2 || parts[0] != "races" || parts[1] == "" { - return nil, status.Error(codes.InvalidArgument, "name must be in format races/{id}") - } - var id int64 - _, err := fmt.Sscanf(parts[1], "%d", &id) - if err != nil { - return nil, status.Error(codes.InvalidArgument, "id must be integer in resource name") - } - race, err := s.racesRepo.Get(id) - if err != nil { - return nil, status.Errorf(codes.Internal, "get race: %v", err) - } - if race == nil { - return nil, status.Error(codes.NotFound, "race not found") - } - return race, nil -} From c5d5a242f0ad5a654b115b974edb310ee349d1ee Mon Sep 17 00:00:00 2001 From: benrobey Date: Sun, 17 Aug 2025 18:15:26 +1000 Subject: [PATCH 3/3] Adds `GetRace` --- api/proto/racing/racing.pb.go | 205 +++++++++++------ api/proto/racing/racing.pb.gw.go | 99 ++++++++ api/proto/racing/racing.proto | 10 + api/proto/racing/racing_grpc.pb.go | 38 ++++ racing/db/races.go | 29 +++ racing/proto/racing.go | 2 +- racing/proto/racing/racing.pb.go | 314 ++++++++++++-------------- racing/proto/racing/racing.proto | 9 + racing/proto/racing/racing_grpc.pb.go | 76 ++++++- racing/service/racing.go | 30 +++ 10 files changed, 561 insertions(+), 251 deletions(-) diff --git a/api/proto/racing/racing.pb.go b/api/proto/racing/racing.pb.go index feef067..0ee711e 100644 --- a/api/proto/racing/racing.pb.go +++ b/api/proto/racing/racing.pb.go @@ -218,6 +218,55 @@ func (x *ListRacesResponse) GetRaces() []*Race { return nil } +type GetRaceRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The resource name of the race to retrieve. + // Format: races/{race} + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // required +} + +func (x *GetRaceRequest) Reset() { + *x = GetRaceRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_racing_racing_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetRaceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetRaceRequest) ProtoMessage() {} + +func (x *GetRaceRequest) ProtoReflect() protoreflect.Message { + mi := &file_racing_racing_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetRaceRequest.ProtoReflect.Descriptor instead. +func (*GetRaceRequest) Descriptor() ([]byte, []int) { + return file_racing_racing_proto_rawDescGZIP(), []int{2} +} + +func (x *GetRaceRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + // Filter for listing races. type ListRacesRequestFilter struct { state protoimpl.MessageState @@ -236,7 +285,7 @@ type ListRacesRequestFilter struct { func (x *ListRacesRequestFilter) Reset() { *x = ListRacesRequestFilter{} if protoimpl.UnsafeEnabled { - mi := &file_racing_racing_proto_msgTypes[2] + mi := &file_racing_racing_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -249,7 +298,7 @@ func (x *ListRacesRequestFilter) String() string { func (*ListRacesRequestFilter) ProtoMessage() {} func (x *ListRacesRequestFilter) ProtoReflect() protoreflect.Message { - mi := &file_racing_racing_proto_msgTypes[2] + mi := &file_racing_racing_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -262,7 +311,7 @@ func (x *ListRacesRequestFilter) ProtoReflect() protoreflect.Message { // Deprecated: Use ListRacesRequestFilter.ProtoReflect.Descriptor instead. func (*ListRacesRequestFilter) Descriptor() ([]byte, []int) { - return file_racing_racing_proto_rawDescGZIP(), []int{2} + return file_racing_racing_proto_rawDescGZIP(), []int{3} } func (x *ListRacesRequestFilter) GetMeetingIds() []int64 { @@ -311,7 +360,7 @@ type Race struct { func (x *Race) Reset() { *x = Race{} if protoimpl.UnsafeEnabled { - mi := &file_racing_racing_proto_msgTypes[3] + mi := &file_racing_racing_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -324,7 +373,7 @@ func (x *Race) String() string { func (*Race) ProtoMessage() {} func (x *Race) ProtoReflect() protoreflect.Message { - mi := &file_racing_racing_proto_msgTypes[3] + mi := &file_racing_racing_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -337,7 +386,7 @@ func (x *Race) ProtoReflect() protoreflect.Message { // Deprecated: Use Race.ProtoReflect.Descriptor instead. func (*Race) Descriptor() ([]byte, []int) { - return file_racing_racing_proto_rawDescGZIP(), []int{3} + return file_racing_racing_proto_rawDescGZIP(), []int{4} } func (x *Race) GetId() int64 { @@ -406,54 +455,61 @@ var file_racing_racing_proto_rawDesc = []byte{ 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x22, 0x0a, 0x05, 0x72, 0x61, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, 0x63, 0x65, 0x52, 0x05, 0x72, 0x61, 0x63, 0x65, - 0x73, 0x22, 0xc8, 0x01, 0x0a, 0x16, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x1f, 0x0a, 0x0b, - 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, - 0x03, 0x52, 0x0a, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x49, 0x64, 0x73, 0x12, 0x26, 0x0a, - 0x0c, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x0b, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x4f, 0x6e, - 0x6c, 0x79, 0x88, 0x01, 0x01, 0x12, 0x41, 0x0a, 0x0e, 0x73, 0x6f, 0x72, 0x74, 0x5f, 0x64, 0x69, - 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, - 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x53, 0x6f, 0x72, 0x74, 0x44, 0x69, 0x72, 0x65, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x01, 0x52, 0x0d, 0x73, 0x6f, 0x72, 0x74, 0x44, 0x69, 0x72, 0x65, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, 0x01, 0x42, 0x0f, 0x0a, 0x0d, 0x5f, 0x76, 0x69, 0x73, - 0x69, 0x62, 0x6c, 0x65, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x42, 0x11, 0x0a, 0x0f, 0x5f, 0x73, 0x6f, - 0x72, 0x74, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xf7, 0x01, 0x0a, - 0x04, 0x52, 0x61, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, - 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x6d, 0x65, 0x65, 0x74, 0x69, - 0x6e, 0x67, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, - 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, - 0x12, 0x18, 0x0a, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x12, 0x4e, 0x0a, 0x15, 0x61, 0x64, - 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x65, 0x64, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, - 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x13, 0x61, 0x64, 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x65, - 0x64, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x2a, 0x0a, 0x06, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x72, 0x61, 0x63, - 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2a, 0x60, 0x0a, 0x0d, 0x53, 0x6f, 0x72, 0x74, 0x44, 0x69, - 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x1a, 0x53, 0x4f, 0x52, 0x54, 0x5f, - 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, - 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x4f, 0x52, 0x54, 0x5f, - 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x41, 0x53, 0x43, 0x10, 0x01, 0x12, - 0x17, 0x0a, 0x13, 0x53, 0x4f, 0x52, 0x54, 0x5f, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, - 0x4e, 0x5f, 0x44, 0x45, 0x53, 0x43, 0x10, 0x02, 0x2a, 0x57, 0x0a, 0x0a, 0x52, 0x61, 0x63, 0x65, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1b, 0x0a, 0x17, 0x52, 0x41, 0x43, 0x45, 0x5f, 0x53, - 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, - 0x44, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x52, 0x41, 0x43, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, - 0x55, 0x53, 0x5f, 0x4f, 0x50, 0x45, 0x4e, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x52, 0x41, 0x43, - 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x10, - 0x02, 0x32, 0x65, 0x0a, 0x06, 0x52, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x12, 0x5b, 0x0a, 0x09, 0x4c, - 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x12, 0x18, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, - 0x67, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x4c, 0x69, 0x73, 0x74, - 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, - 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x22, 0x0e, 0x2f, 0x76, 0x31, 0x2f, 0x6c, 0x69, 0x73, 0x74, 0x2d, - 0x72, 0x61, 0x63, 0x65, 0x73, 0x3a, 0x01, 0x2a, 0x42, 0x09, 0x5a, 0x07, 0x2f, 0x72, 0x61, 0x63, - 0x69, 0x6e, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x22, 0x24, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x52, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xc8, 0x01, 0x0a, 0x16, 0x4c, 0x69, 0x73, 0x74, + 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x69, 0x6c, 0x74, + 0x65, 0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x69, 0x64, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x03, 0x52, 0x0a, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, + 0x49, 0x64, 0x73, 0x12, 0x26, 0x0a, 0x0c, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x5f, 0x6f, + 0x6e, 0x6c, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x0b, 0x76, 0x69, 0x73, + 0x69, 0x62, 0x6c, 0x65, 0x4f, 0x6e, 0x6c, 0x79, 0x88, 0x01, 0x01, 0x12, 0x41, 0x0a, 0x0e, 0x73, + 0x6f, 0x72, 0x74, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x53, 0x6f, 0x72, + 0x74, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x01, 0x52, 0x0d, 0x73, 0x6f, + 0x72, 0x74, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, 0x01, 0x42, 0x0f, + 0x0a, 0x0d, 0x5f, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x42, + 0x11, 0x0a, 0x0f, 0x5f, 0x73, 0x6f, 0x72, 0x74, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x22, 0xf7, 0x01, 0x0a, 0x04, 0x52, 0x61, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, + 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x09, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, + 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, + 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, + 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, + 0x12, 0x4e, 0x0a, 0x15, 0x61, 0x64, 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x65, 0x64, 0x5f, 0x73, + 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x13, 0x61, 0x64, 0x76, + 0x65, 0x72, 0x74, 0x69, 0x73, 0x65, 0x64, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, + 0x12, 0x2a, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x12, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, 0x63, 0x65, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2a, 0x60, 0x0a, 0x0d, + 0x53, 0x6f, 0x72, 0x74, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, + 0x1a, 0x53, 0x4f, 0x52, 0x54, 0x5f, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, + 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x16, 0x0a, + 0x12, 0x53, 0x4f, 0x52, 0x54, 0x5f, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, + 0x41, 0x53, 0x43, 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, 0x53, 0x4f, 0x52, 0x54, 0x5f, 0x44, 0x49, + 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x44, 0x45, 0x53, 0x43, 0x10, 0x02, 0x2a, 0x57, + 0x0a, 0x0a, 0x52, 0x61, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1b, 0x0a, 0x17, + 0x52, 0x41, 0x43, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, + 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x52, 0x41, 0x43, + 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x4f, 0x50, 0x45, 0x4e, 0x10, 0x01, 0x12, + 0x16, 0x0a, 0x12, 0x52, 0x41, 0x43, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x43, + 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x10, 0x02, 0x32, 0xb2, 0x01, 0x0a, 0x06, 0x52, 0x61, 0x63, 0x69, + 0x6e, 0x67, 0x12, 0x5b, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x12, + 0x18, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, + 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x61, 0x63, 0x69, + 0x6e, 0x67, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x22, 0x0e, 0x2f, 0x76, + 0x31, 0x2f, 0x6c, 0x69, 0x73, 0x74, 0x2d, 0x72, 0x61, 0x63, 0x65, 0x73, 0x3a, 0x01, 0x2a, 0x12, + 0x4b, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x52, 0x61, 0x63, 0x65, 0x12, 0x16, 0x2e, 0x72, 0x61, 0x63, + 0x69, 0x6e, 0x67, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, 0x63, 0x65, + 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x12, 0x12, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, + 0x61, 0x6d, 0x65, 0x3d, 0x72, 0x61, 0x63, 0x65, 0x73, 0x2f, 0x2a, 0x7d, 0x42, 0x09, 0x5a, 0x07, + 0x2f, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -469,26 +525,29 @@ func file_racing_racing_proto_rawDescGZIP() []byte { } var file_racing_racing_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_racing_racing_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_racing_racing_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_racing_racing_proto_goTypes = []interface{}{ (SortDirection)(0), // 0: racing.SortDirection (RaceStatus)(0), // 1: racing.RaceStatus (*ListRacesRequest)(nil), // 2: racing.ListRacesRequest (*ListRacesResponse)(nil), // 3: racing.ListRacesResponse - (*ListRacesRequestFilter)(nil), // 4: racing.ListRacesRequestFilter - (*Race)(nil), // 5: racing.Race - (*timestamppb.Timestamp)(nil), // 6: google.protobuf.Timestamp + (*GetRaceRequest)(nil), // 4: racing.GetRaceRequest + (*ListRacesRequestFilter)(nil), // 5: racing.ListRacesRequestFilter + (*Race)(nil), // 6: racing.Race + (*timestamppb.Timestamp)(nil), // 7: google.protobuf.Timestamp } var file_racing_racing_proto_depIdxs = []int32{ - 4, // 0: racing.ListRacesRequest.filter:type_name -> racing.ListRacesRequestFilter - 5, // 1: racing.ListRacesResponse.races:type_name -> racing.Race + 5, // 0: racing.ListRacesRequest.filter:type_name -> racing.ListRacesRequestFilter + 6, // 1: racing.ListRacesResponse.races:type_name -> racing.Race 0, // 2: racing.ListRacesRequestFilter.sort_direction:type_name -> racing.SortDirection - 6, // 3: racing.Race.advertised_start_time:type_name -> google.protobuf.Timestamp + 7, // 3: racing.Race.advertised_start_time:type_name -> google.protobuf.Timestamp 1, // 4: racing.Race.status:type_name -> racing.RaceStatus 2, // 5: racing.Racing.ListRaces:input_type -> racing.ListRacesRequest - 3, // 6: racing.Racing.ListRaces:output_type -> racing.ListRacesResponse - 6, // [6:7] is the sub-list for method output_type - 5, // [5:6] is the sub-list for method input_type + 4, // 6: racing.Racing.GetRace:input_type -> racing.GetRaceRequest + 3, // 7: racing.Racing.ListRaces:output_type -> racing.ListRacesResponse + 6, // 8: racing.Racing.GetRace:output_type -> racing.Race + 7, // [7:9] is the sub-list for method output_type + 5, // [5:7] 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 @@ -525,7 +584,7 @@ func file_racing_racing_proto_init() { } } file_racing_racing_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListRacesRequestFilter); i { + switch v := v.(*GetRaceRequest); i { case 0: return &v.state case 1: @@ -537,6 +596,18 @@ func file_racing_racing_proto_init() { } } file_racing_racing_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListRacesRequestFilter); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_racing_racing_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Race); i { case 0: return &v.state @@ -549,14 +620,14 @@ func file_racing_racing_proto_init() { } } } - file_racing_racing_proto_msgTypes[2].OneofWrappers = []interface{}{} + file_racing_racing_proto_msgTypes[3].OneofWrappers = []interface{}{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_racing_racing_proto_rawDesc, NumEnums: 2, - NumMessages: 4, + NumMessages: 5, NumExtensions: 0, NumServices: 1, }, diff --git a/api/proto/racing/racing.pb.gw.go b/api/proto/racing/racing.pb.gw.go index 3f34377..115ef9c 100644 --- a/api/proto/racing/racing.pb.gw.go +++ b/api/proto/racing/racing.pb.gw.go @@ -65,6 +65,58 @@ func local_request_Racing_ListRaces_0(ctx context.Context, marshaler runtime.Mar } +func request_Racing_GetRace_0(ctx context.Context, marshaler runtime.Marshaler, client RacingClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetRaceRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + msg, err := client.GetRace(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Racing_GetRace_0(ctx context.Context, marshaler runtime.Marshaler, server RacingServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetRaceRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + msg, err := server.GetRace(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterRacingHandlerServer registers the http handlers for service Racing to "mux". // UnaryRPC :call RacingServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -94,6 +146,29 @@ func RegisterRacingHandlerServer(ctx context.Context, mux *runtime.ServeMux, ser }) + mux.Handle("GET", pattern_Racing_GetRace_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/racing.Racing/GetRace") + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Racing_GetRace_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Racing_GetRace_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -155,13 +230,37 @@ func RegisterRacingHandlerClient(ctx context.Context, mux *runtime.ServeMux, cli }) + mux.Handle("GET", pattern_Racing_GetRace_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req, "/racing.Racing/GetRace") + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Racing_GetRace_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Racing_GetRace_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } var ( pattern_Racing_ListRaces_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "list-races"}, "")) + + pattern_Racing_GetRace_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "races", "name"}, "")) ) var ( forward_Racing_ListRaces_0 = runtime.ForwardResponseMessage + + forward_Racing_GetRace_0 = runtime.ForwardResponseMessage ) diff --git a/api/proto/racing/racing.proto b/api/proto/racing/racing.proto index e7fa1d4..fe2e547 100644 --- a/api/proto/racing/racing.proto +++ b/api/proto/racing/racing.proto @@ -25,6 +25,10 @@ service Racing { rpc ListRaces(ListRacesRequest) returns (ListRacesResponse) { option (google.api.http) = { post: "/v1/list-races", body: "*" }; } + // GetRace returns a single race by resource name. + rpc GetRace(GetRaceRequest) returns (Race) { + option (google.api.http) = { get: "/v1/{name=races/*}" }; + } } /* Requests/Responses */ @@ -39,6 +43,12 @@ message ListRacesResponse { repeated Race races = 1; } +message GetRaceRequest { + // The resource name of the race to retrieve. + // Format: races/{race} + string name = 1; // required +} + // Filter for listing races. message ListRacesRequestFilter { repeated int64 meeting_ids = 1; diff --git a/api/proto/racing/racing_grpc.pb.go b/api/proto/racing/racing_grpc.pb.go index 6325105..1b13fde 100644 --- a/api/proto/racing/racing_grpc.pb.go +++ b/api/proto/racing/racing_grpc.pb.go @@ -20,6 +20,8 @@ const _ = grpc.SupportPackageIsVersion7 type RacingClient interface { // ListRaces returns a list of all races. ListRaces(ctx context.Context, in *ListRacesRequest, opts ...grpc.CallOption) (*ListRacesResponse, error) + // GetRace returns a single race by resource name. + GetRace(ctx context.Context, in *GetRaceRequest, opts ...grpc.CallOption) (*Race, error) } type racingClient struct { @@ -39,12 +41,23 @@ func (c *racingClient) ListRaces(ctx context.Context, in *ListRacesRequest, opts return out, nil } +func (c *racingClient) GetRace(ctx context.Context, in *GetRaceRequest, opts ...grpc.CallOption) (*Race, error) { + out := new(Race) + err := c.cc.Invoke(ctx, "/racing.Racing/GetRace", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // RacingServer is the server API for Racing service. // All implementations must embed UnimplementedRacingServer // for forward compatibility type RacingServer interface { // ListRaces returns a list of all races. ListRaces(context.Context, *ListRacesRequest) (*ListRacesResponse, error) + // GetRace returns a single race by resource name. + GetRace(context.Context, *GetRaceRequest) (*Race, error) mustEmbedUnimplementedRacingServer() } @@ -55,6 +68,9 @@ type UnimplementedRacingServer struct { func (UnimplementedRacingServer) ListRaces(context.Context, *ListRacesRequest) (*ListRacesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ListRaces not implemented") } +func (UnimplementedRacingServer) GetRace(context.Context, *GetRaceRequest) (*Race, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetRace not implemented") +} func (UnimplementedRacingServer) mustEmbedUnimplementedRacingServer() {} // UnsafeRacingServer may be embedded to opt out of forward compatibility for this service. @@ -86,6 +102,24 @@ func _Racing_ListRaces_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _Racing_GetRace_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetRaceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RacingServer).GetRace(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/racing.Racing/GetRace", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RacingServer).GetRace(ctx, req.(*GetRaceRequest)) + } + return interceptor(ctx, in, info, handler) +} + // Racing_ServiceDesc is the grpc.ServiceDesc for Racing service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -97,6 +131,10 @@ var Racing_ServiceDesc = grpc.ServiceDesc{ MethodName: "ListRaces", Handler: _Racing_ListRaces_Handler, }, + { + MethodName: "GetRace", + Handler: _Racing_GetRace_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "racing/racing.proto", diff --git a/racing/db/races.go b/racing/db/races.go index a8eddab..ac58c91 100644 --- a/racing/db/races.go +++ b/racing/db/races.go @@ -19,6 +19,9 @@ type RacesRepo interface { // List will return a list of races. List(filter *racing.ListRacesRequestFilter) ([]*racing.Race, error) + + // Get returns a single race by numeric id. + Get(id int64) (*racing.Race, error) } type racesRepo struct { @@ -62,6 +65,32 @@ func (r *racesRepo) List(filter *racing.ListRacesRequestFilter) ([]*racing.Race, return r.scanRaces(rows) } +func (r *racesRepo) Get(id int64) (*racing.Race, error) { + query := "SELECT id, meeting_id, name, number, visible, advertised_start_time FROM races WHERE id = ? LIMIT 1" + row := r.db.QueryRow(query, id) + var ( + race racing.Race + advertisedStart time.Time + ) + if err := row.Scan(&race.Id, &race.MeetingId, &race.Name, &race.Number, &race.Visible, &advertisedStart); err != nil { + if err == sql.ErrNoRows { + return nil, nil + } + return nil, err + } + ts, err := ptypes.TimestampProto(advertisedStart) + if err != nil { + return nil, err + } + race.AdvertisedStartTime = ts + if advertisedStart.After(time.Now()) { + race.Status = racing.RaceStatus_RACE_STATUS_OPEN + } else { + race.Status = racing.RaceStatus_RACE_STATUS_CLOSED + } + return &race, nil +} + func (r *racesRepo) applyFilter(query string, filter *racing.ListRacesRequestFilter) (string, []interface{}) { var ( clauses []string diff --git a/racing/proto/racing.go b/racing/proto/racing.go index afc1049..fee1a85 100644 --- a/racing/proto/racing.go +++ b/racing/proto/racing.go @@ -1,3 +1,3 @@ package proto -//go:generate protoc --go_out=. --go-grpc_out=require_unimplemented_servers=false:. racing/racing.proto --experimental_allow_proto3_optional +//go:generate protoc -I . --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative,require_unimplemented_servers=false:. racing/racing.proto --experimental_allow_proto3_optional diff --git a/racing/proto/racing/racing.pb.go b/racing/proto/racing/racing.pb.go index 6c22b8d..7681b47 100644 --- a/racing/proto/racing/racing.pb.go +++ b/racing/proto/racing/racing.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 +// protoc-gen-go v1.36.7 // protoc v6.32.0 // source: racing/racing.proto @@ -12,6 +12,7 @@ import ( timestamppb "google.golang.org/protobuf/types/known/timestamppb" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -124,20 +125,17 @@ func (RaceStatus) EnumDescriptor() ([]byte, []int) { } type ListRacesRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Filter *ListRacesRequestFilter `protobuf:"bytes,1,opt,name=filter,proto3" json:"filter,omitempty"` unknownFields protoimpl.UnknownFields - - Filter *ListRacesRequestFilter `protobuf:"bytes,1,opt,name=filter,proto3" json:"filter,omitempty"` + sizeCache protoimpl.SizeCache } func (x *ListRacesRequest) Reset() { *x = ListRacesRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_racing_racing_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_racing_racing_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ListRacesRequest) String() string { @@ -148,7 +146,7 @@ func (*ListRacesRequest) ProtoMessage() {} func (x *ListRacesRequest) ProtoReflect() protoreflect.Message { mi := &file_racing_racing_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -172,20 +170,17 @@ func (x *ListRacesRequest) GetFilter() *ListRacesRequestFilter { // Response to ListRaces call. type ListRacesResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Races []*Race `protobuf:"bytes,1,rep,name=races,proto3" json:"races,omitempty"` unknownFields protoimpl.UnknownFields - - Races []*Race `protobuf:"bytes,1,rep,name=races,proto3" json:"races,omitempty"` + sizeCache protoimpl.SizeCache } func (x *ListRacesResponse) Reset() { *x = ListRacesResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_racing_racing_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_racing_racing_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ListRacesResponse) String() string { @@ -196,7 +191,7 @@ func (*ListRacesResponse) ProtoMessage() {} func (x *ListRacesResponse) ProtoReflect() protoreflect.Message { mi := &file_racing_racing_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -218,28 +213,72 @@ func (x *ListRacesResponse) GetRaces() []*Race { return nil } -// Filter for listing races. -type ListRacesRequestFilter struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache +// Request for a single race using its resource name. +type GetRaceRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The resource name of the race to retrieve. + // Format: races/{race} + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // required unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetRaceRequest) Reset() { + *x = GetRaceRequest{} + mi := &file_racing_racing_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetRaceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetRaceRequest) ProtoMessage() {} + +func (x *GetRaceRequest) ProtoReflect() protoreflect.Message { + mi := &file_racing_racing_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) +} - MeetingIds []int64 `protobuf:"varint,1,rep,packed,name=meeting_ids,json=meetingIds,proto3" json:"meeting_ids,omitempty"` +// Deprecated: Use GetRaceRequest.ProtoReflect.Descriptor instead. +func (*GetRaceRequest) Descriptor() ([]byte, []int) { + return file_racing_racing_proto_rawDescGZIP(), []int{2} +} + +func (x *GetRaceRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +// Filter for listing races. +type ListRacesRequestFilter struct { + state protoimpl.MessageState `protogen:"open.v1"` + MeetingIds []int64 `protobuf:"varint,1,rep,packed,name=meeting_ids,json=meetingIds,proto3" json:"meeting_ids,omitempty"` // visible_only, when true, restricts results to only races marked visible. // When omitted or false, all races (visible or not) are returned. VisibleOnly *bool `protobuf:"varint,2,opt,name=visible_only,json=visibleOnly,proto3,oneof" json:"visible_only,omitempty"` // sort_direction chooses ascending or descending order by advertised_start_time. // If omitted or UNSPECIFIED the results are returned ascending (earliest first). SortDirection *SortDirection `protobuf:"varint,3,opt,name=sort_direction,json=sortDirection,proto3,enum=racing.SortDirection,oneof" json:"sort_direction,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ListRacesRequestFilter) Reset() { *x = ListRacesRequestFilter{} - if protoimpl.UnsafeEnabled { - mi := &file_racing_racing_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_racing_racing_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ListRacesRequestFilter) String() string { @@ -249,8 +288,8 @@ func (x *ListRacesRequestFilter) String() string { func (*ListRacesRequestFilter) ProtoMessage() {} func (x *ListRacesRequestFilter) ProtoReflect() protoreflect.Message { - mi := &file_racing_racing_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + mi := &file_racing_racing_proto_msgTypes[3] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -262,7 +301,7 @@ func (x *ListRacesRequestFilter) ProtoReflect() protoreflect.Message { // Deprecated: Use ListRacesRequestFilter.ProtoReflect.Descriptor instead. func (*ListRacesRequestFilter) Descriptor() ([]byte, []int) { - return file_racing_racing_proto_rawDescGZIP(), []int{2} + return file_racing_racing_proto_rawDescGZIP(), []int{3} } func (x *ListRacesRequestFilter) GetMeetingIds() []int64 { @@ -288,10 +327,7 @@ func (x *ListRacesRequestFilter) GetSortDirection() SortDirection { // A race resource. type Race struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // ID represents a unique identifier for the race. Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // MeetingID represents a unique identifier for the races meeting. @@ -305,16 +341,16 @@ type Race struct { // AdvertisedStartTime is the time the race is advertised to run. AdvertisedStartTime *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=advertised_start_time,json=advertisedStartTime,proto3" json:"advertised_start_time,omitempty"` // Status is derived: OPEN if advertised_start_time is in the future; else CLOSED. - Status RaceStatus `protobuf:"varint,7,opt,name=status,proto3,enum=racing.RaceStatus" json:"status,omitempty"` + Status RaceStatus `protobuf:"varint,7,opt,name=status,proto3,enum=racing.RaceStatus" json:"status,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Race) Reset() { *x = Race{} - if protoimpl.UnsafeEnabled { - mi := &file_racing_racing_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_racing_racing_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Race) String() string { @@ -324,8 +360,8 @@ func (x *Race) String() string { func (*Race) ProtoMessage() {} func (x *Race) ProtoReflect() protoreflect.Message { - mi := &file_racing_racing_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + mi := &file_racing_racing_proto_msgTypes[4] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -337,7 +373,7 @@ func (x *Race) ProtoReflect() protoreflect.Message { // Deprecated: Use Race.ProtoReflect.Descriptor instead. func (*Race) Descriptor() ([]byte, []int) { - return file_racing_racing_proto_rawDescGZIP(), []int{3} + return file_racing_racing_proto_rawDescGZIP(), []int{4} } func (x *Race) GetId() int64 { @@ -391,101 +427,80 @@ func (x *Race) GetStatus() RaceStatus { var File_racing_racing_proto protoreflect.FileDescriptor -var file_racing_racing_proto_rawDesc = []byte{ - 0x0a, 0x13, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2f, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x1a, 0x1f, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, - 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x4a, - 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x36, 0x0a, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x4c, 0x69, 0x73, 0x74, - 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x69, 0x6c, 0x74, - 0x65, 0x72, 0x52, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x22, 0x37, 0x0a, 0x11, 0x4c, 0x69, - 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x22, 0x0a, 0x05, 0x72, 0x61, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, - 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, 0x63, 0x65, 0x52, 0x05, 0x72, 0x61, - 0x63, 0x65, 0x73, 0x22, 0xc8, 0x01, 0x0a, 0x16, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x1f, - 0x0a, 0x0b, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x03, 0x52, 0x0a, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x49, 0x64, 0x73, 0x12, - 0x26, 0x0a, 0x0c, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x0b, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, - 0x4f, 0x6e, 0x6c, 0x79, 0x88, 0x01, 0x01, 0x12, 0x41, 0x0a, 0x0e, 0x73, 0x6f, 0x72, 0x74, 0x5f, - 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, - 0x15, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x53, 0x6f, 0x72, 0x74, 0x44, 0x69, 0x72, - 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x01, 0x52, 0x0d, 0x73, 0x6f, 0x72, 0x74, 0x44, 0x69, - 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, 0x01, 0x42, 0x0f, 0x0a, 0x0d, 0x5f, 0x76, - 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x42, 0x11, 0x0a, 0x0f, 0x5f, - 0x73, 0x6f, 0x72, 0x74, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xf7, - 0x01, 0x0a, 0x04, 0x52, 0x61, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x65, 0x65, 0x74, 0x69, - 0x6e, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x6d, 0x65, 0x65, - 0x74, 0x69, 0x6e, 0x67, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, - 0x6d, 0x62, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, - 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x12, 0x4e, 0x0a, 0x15, - 0x61, 0x64, 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x65, 0x64, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, - 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x13, 0x61, 0x64, 0x76, 0x65, 0x72, 0x74, 0x69, - 0x73, 0x65, 0x64, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x2a, 0x0a, 0x06, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x72, - 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2a, 0x60, 0x0a, 0x0d, 0x53, 0x6f, 0x72, 0x74, - 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x1a, 0x53, 0x4f, 0x52, - 0x54, 0x5f, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x55, 0x4e, 0x53, 0x50, - 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x4f, 0x52, - 0x54, 0x5f, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x41, 0x53, 0x43, 0x10, - 0x01, 0x12, 0x17, 0x0a, 0x13, 0x53, 0x4f, 0x52, 0x54, 0x5f, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, - 0x49, 0x4f, 0x4e, 0x5f, 0x44, 0x45, 0x53, 0x43, 0x10, 0x02, 0x2a, 0x57, 0x0a, 0x0a, 0x52, 0x61, - 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1b, 0x0a, 0x17, 0x52, 0x41, 0x43, 0x45, - 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, - 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x52, 0x41, 0x43, 0x45, 0x5f, 0x53, 0x54, - 0x41, 0x54, 0x55, 0x53, 0x5f, 0x4f, 0x50, 0x45, 0x4e, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x52, - 0x41, 0x43, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x43, 0x4c, 0x4f, 0x53, 0x45, - 0x44, 0x10, 0x02, 0x32, 0x4c, 0x0a, 0x06, 0x52, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x12, 0x42, 0x0a, - 0x09, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x12, 0x18, 0x2e, 0x72, 0x61, 0x63, - 0x69, 0x6e, 0x67, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x4c, 0x69, - 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x42, 0x09, 0x5a, 0x07, 0x2f, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, -} +const file_racing_racing_proto_rawDesc = "" + + "\n" + + "\x13racing/racing.proto\x12\x06racing\x1a\x1fgoogle/protobuf/timestamp.proto\"J\n" + + "\x10ListRacesRequest\x126\n" + + "\x06filter\x18\x01 \x01(\v2\x1e.racing.ListRacesRequestFilterR\x06filter\"7\n" + + "\x11ListRacesResponse\x12\"\n" + + "\x05races\x18\x01 \x03(\v2\f.racing.RaceR\x05races\"$\n" + + "\x0eGetRaceRequest\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\"\xc8\x01\n" + + "\x16ListRacesRequestFilter\x12\x1f\n" + + "\vmeeting_ids\x18\x01 \x03(\x03R\n" + + "meetingIds\x12&\n" + + "\fvisible_only\x18\x02 \x01(\bH\x00R\vvisibleOnly\x88\x01\x01\x12A\n" + + "\x0esort_direction\x18\x03 \x01(\x0e2\x15.racing.SortDirectionH\x01R\rsortDirection\x88\x01\x01B\x0f\n" + + "\r_visible_onlyB\x11\n" + + "\x0f_sort_direction\"\xf7\x01\n" + + "\x04Race\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x1d\n" + + "\n" + + "meeting_id\x18\x02 \x01(\x03R\tmeetingId\x12\x12\n" + + "\x04name\x18\x03 \x01(\tR\x04name\x12\x16\n" + + "\x06number\x18\x04 \x01(\x03R\x06number\x12\x18\n" + + "\avisible\x18\x05 \x01(\bR\avisible\x12N\n" + + "\x15advertised_start_time\x18\x06 \x01(\v2\x1a.google.protobuf.TimestampR\x13advertisedStartTime\x12*\n" + + "\x06status\x18\a \x01(\x0e2\x12.racing.RaceStatusR\x06status*`\n" + + "\rSortDirection\x12\x1e\n" + + "\x1aSORT_DIRECTION_UNSPECIFIED\x10\x00\x12\x16\n" + + "\x12SORT_DIRECTION_ASC\x10\x01\x12\x17\n" + + "\x13SORT_DIRECTION_DESC\x10\x02*W\n" + + "\n" + + "RaceStatus\x12\x1b\n" + + "\x17RACE_STATUS_UNSPECIFIED\x10\x00\x12\x14\n" + + "\x10RACE_STATUS_OPEN\x10\x01\x12\x16\n" + + "\x12RACE_STATUS_CLOSED\x10\x022\x7f\n" + + "\x06Racing\x12B\n" + + "\tListRaces\x12\x18.racing.ListRacesRequest\x1a\x19.racing.ListRacesResponse\"\x00\x121\n" + + "\aGetRace\x12\x16.racing.GetRaceRequest\x1a\f.racing.Race\"\x00B\tZ\a/racingb\x06proto3" var ( file_racing_racing_proto_rawDescOnce sync.Once - file_racing_racing_proto_rawDescData = file_racing_racing_proto_rawDesc + file_racing_racing_proto_rawDescData []byte ) func file_racing_racing_proto_rawDescGZIP() []byte { file_racing_racing_proto_rawDescOnce.Do(func() { - file_racing_racing_proto_rawDescData = protoimpl.X.CompressGZIP(file_racing_racing_proto_rawDescData) + file_racing_racing_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_racing_racing_proto_rawDesc), len(file_racing_racing_proto_rawDesc))) }) return file_racing_racing_proto_rawDescData } var file_racing_racing_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_racing_racing_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_racing_racing_proto_goTypes = []interface{}{ +var file_racing_racing_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_racing_racing_proto_goTypes = []any{ (SortDirection)(0), // 0: racing.SortDirection (RaceStatus)(0), // 1: racing.RaceStatus (*ListRacesRequest)(nil), // 2: racing.ListRacesRequest (*ListRacesResponse)(nil), // 3: racing.ListRacesResponse - (*ListRacesRequestFilter)(nil), // 4: racing.ListRacesRequestFilter - (*Race)(nil), // 5: racing.Race - (*timestamppb.Timestamp)(nil), // 6: google.protobuf.Timestamp + (*GetRaceRequest)(nil), // 4: racing.GetRaceRequest + (*ListRacesRequestFilter)(nil), // 5: racing.ListRacesRequestFilter + (*Race)(nil), // 6: racing.Race + (*timestamppb.Timestamp)(nil), // 7: google.protobuf.Timestamp } var file_racing_racing_proto_depIdxs = []int32{ - 4, // 0: racing.ListRacesRequest.filter:type_name -> racing.ListRacesRequestFilter - 5, // 1: racing.ListRacesResponse.races:type_name -> racing.Race + 5, // 0: racing.ListRacesRequest.filter:type_name -> racing.ListRacesRequestFilter + 6, // 1: racing.ListRacesResponse.races:type_name -> racing.Race 0, // 2: racing.ListRacesRequestFilter.sort_direction:type_name -> racing.SortDirection - 6, // 3: racing.Race.advertised_start_time:type_name -> google.protobuf.Timestamp + 7, // 3: racing.Race.advertised_start_time:type_name -> google.protobuf.Timestamp 1, // 4: racing.Race.status:type_name -> racing.RaceStatus 2, // 5: racing.Racing.ListRaces:input_type -> racing.ListRacesRequest - 3, // 6: racing.Racing.ListRaces:output_type -> racing.ListRacesResponse - 6, // [6:7] is the sub-list for method output_type - 5, // [5:6] is the sub-list for method input_type + 4, // 6: racing.Racing.GetRace:input_type -> racing.GetRaceRequest + 3, // 7: racing.Racing.ListRaces:output_type -> racing.ListRacesResponse + 6, // 8: racing.Racing.GetRace:output_type -> racing.Race + 7, // [7:9] is the sub-list for method output_type + 5, // [5:7] 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 @@ -496,64 +511,14 @@ func file_racing_racing_proto_init() { if File_racing_racing_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_racing_racing_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListRacesRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_racing_racing_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListRacesResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_racing_racing_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListRacesRequestFilter); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_racing_racing_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Race); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_racing_racing_proto_msgTypes[2].OneofWrappers = []interface{}{} + file_racing_racing_proto_msgTypes[3].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_racing_racing_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_racing_racing_proto_rawDesc), len(file_racing_racing_proto_rawDesc)), NumEnums: 2, - NumMessages: 4, + NumMessages: 5, NumExtensions: 0, NumServices: 1, }, @@ -563,7 +528,6 @@ func file_racing_racing_proto_init() { MessageInfos: file_racing_racing_proto_msgTypes, }.Build() File_racing_racing_proto = out.File - file_racing_racing_proto_rawDesc = nil file_racing_racing_proto_goTypes = nil file_racing_racing_proto_depIdxs = nil } diff --git a/racing/proto/racing/racing.proto b/racing/proto/racing/racing.proto index 175de9b..857fe81 100644 --- a/racing/proto/racing/racing.proto +++ b/racing/proto/racing/racing.proto @@ -24,6 +24,8 @@ enum RaceStatus { service Racing { // ListRaces will return a collection of all races. rpc ListRaces(ListRacesRequest) returns (ListRacesResponse) {} + // GetRace returns a single race by resource name (races/{race}). Returns NOT_FOUND if it doesn't exist. + rpc GetRace(GetRaceRequest) returns (Race) {} } /* Requests/Responses */ @@ -37,6 +39,13 @@ message ListRacesResponse { repeated Race races = 1; } +// Request for a single race using its resource name. +message GetRaceRequest { + // The resource name of the race to retrieve. + // Format: races/{race} + string name = 1; // required +} + // Filter for listing races. message ListRacesRequestFilter { repeated int64 meeting_ids = 1; diff --git a/racing/proto/racing/racing_grpc.pb.go b/racing/proto/racing/racing_grpc.pb.go index 44b6818..162ae5e 100644 --- a/racing/proto/racing/racing_grpc.pb.go +++ b/racing/proto/racing/racing_grpc.pb.go @@ -1,4 +1,8 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc v6.32.0 +// source: racing/racing.proto package racing @@ -11,8 +15,13 @@ import ( // 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.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + Racing_ListRaces_FullMethodName = "/racing.Racing/ListRaces" + Racing_GetRace_FullMethodName = "/racing.Racing/GetRace" +) // RacingClient is the client API for Racing service. // @@ -20,6 +29,8 @@ const _ = grpc.SupportPackageIsVersion7 type RacingClient interface { // ListRaces will return a collection of all races. ListRaces(ctx context.Context, in *ListRacesRequest, opts ...grpc.CallOption) (*ListRacesResponse, error) + // GetRace returns a single race by resource name (races/{race}). Returns NOT_FOUND if it doesn't exist. + GetRace(ctx context.Context, in *GetRaceRequest, opts ...grpc.CallOption) (*Race, error) } type racingClient struct { @@ -31,8 +42,19 @@ func NewRacingClient(cc grpc.ClientConnInterface) RacingClient { } func (c *racingClient) ListRaces(ctx context.Context, in *ListRacesRequest, opts ...grpc.CallOption) (*ListRacesResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ListRacesResponse) - err := c.cc.Invoke(ctx, "/racing.Racing/ListRaces", in, out, opts...) + err := c.cc.Invoke(ctx, Racing_ListRaces_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *racingClient) GetRace(ctx context.Context, in *GetRaceRequest, opts ...grpc.CallOption) (*Race, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Race) + err := c.cc.Invoke(ctx, Racing_GetRace_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -41,19 +63,28 @@ func (c *racingClient) ListRaces(ctx context.Context, in *ListRacesRequest, opts // RacingServer is the server API for Racing service. // All implementations should embed UnimplementedRacingServer -// for forward compatibility +// for forward compatibility. type RacingServer interface { // ListRaces will return a collection of all races. ListRaces(context.Context, *ListRacesRequest) (*ListRacesResponse, error) + // GetRace returns a single race by resource name (races/{race}). Returns NOT_FOUND if it doesn't exist. + GetRace(context.Context, *GetRaceRequest) (*Race, error) } -// UnimplementedRacingServer should be embedded to have forward compatible implementations. -type UnimplementedRacingServer struct { -} +// UnimplementedRacingServer should 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 UnimplementedRacingServer struct{} func (UnimplementedRacingServer) ListRaces(context.Context, *ListRacesRequest) (*ListRacesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ListRaces not implemented") } +func (UnimplementedRacingServer) GetRace(context.Context, *GetRaceRequest) (*Race, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetRace not implemented") +} +func (UnimplementedRacingServer) testEmbeddedByValue() {} // UnsafeRacingServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to RacingServer will @@ -63,6 +94,13 @@ type UnsafeRacingServer interface { } func RegisterRacingServer(s grpc.ServiceRegistrar, srv RacingServer) { + // If the following call pancis, it indicates UnimplementedRacingServer 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(&Racing_ServiceDesc, srv) } @@ -76,7 +114,7 @@ func _Racing_ListRaces_Handler(srv interface{}, ctx context.Context, dec func(in } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/racing.Racing/ListRaces", + FullMethod: Racing_ListRaces_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(RacingServer).ListRaces(ctx, req.(*ListRacesRequest)) @@ -84,6 +122,24 @@ func _Racing_ListRaces_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _Racing_GetRace_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetRaceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RacingServer).GetRace(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Racing_GetRace_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RacingServer).GetRace(ctx, req.(*GetRaceRequest)) + } + return interceptor(ctx, in, info, handler) +} + // Racing_ServiceDesc is the grpc.ServiceDesc for Racing service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -95,6 +151,10 @@ var Racing_ServiceDesc = grpc.ServiceDesc{ MethodName: "ListRaces", Handler: _Racing_ListRaces_Handler, }, + { + MethodName: "GetRace", + Handler: _Racing_GetRace_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "racing/racing.proto", diff --git a/racing/service/racing.go b/racing/service/racing.go index 1960430..e0bd15a 100644 --- a/racing/service/racing.go +++ b/racing/service/racing.go @@ -1,14 +1,21 @@ package service import ( + "fmt" + "strings" + "git.neds.sh/matty/entain/racing/db" "git.neds.sh/matty/entain/racing/proto/racing" "golang.org/x/net/context" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" ) type Racing interface { // ListRaces will return a collection of races. ListRaces(ctx context.Context, in *racing.ListRacesRequest) (*racing.ListRacesResponse, error) + // GetRace returns a single race. + GetRace(ctx context.Context, in *racing.GetRaceRequest) (*racing.Race, error) } // racingService implements the Racing interface. @@ -29,3 +36,26 @@ func (s *racingService) ListRaces(ctx context.Context, in *racing.ListRacesReque return &racing.ListRacesResponse{Races: races}, nil } + +func (s *racingService) GetRace(ctx context.Context, in *racing.GetRaceRequest) (*racing.Race, error) { + if in.GetName() == "" { + return nil, status.Error(codes.InvalidArgument, "name is required") + } + parts := strings.Split(in.GetName(), "/") + if len(parts) != 2 || parts[0] != "races" || parts[1] == "" { + return nil, status.Error(codes.InvalidArgument, "name must be in format races/{id}") + } + var id int64 + _, err := fmt.Sscanf(parts[1], "%d", &id) + if err != nil { + return nil, status.Error(codes.InvalidArgument, "id must be integer in resource name") + } + race, err := s.racesRepo.Get(id) + if err != nil { + return nil, status.Errorf(codes.Internal, "get race: %v", err) + } + if race == nil { + return nil, status.Error(codes.NotFound, "race not found") + } + return race, nil +}