diff --git a/api/proto/racing/racing.pb.go b/api/proto/racing/racing.pb.go index d0e3313..05037a4 100644 --- a/api/proto/racing/racing.pb.go +++ b/api/proto/racing/racing.pb.go @@ -71,7 +71,54 @@ func (x Race_Status) Number() protoreflect.EnumNumber { // Deprecated: Use Race_Status.Descriptor instead. func (Race_Status) EnumDescriptor() ([]byte, []int) { - return file_racing_racing_proto_rawDescGZIP(), []int{3, 0} + return file_racing_racing_proto_rawDescGZIP(), []int{4, 0} +} + +type GetRaceRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *GetRaceRequest) Reset() { + *x = GetRaceRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_racing_racing_proto_msgTypes[0] + 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[0] + 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{0} +} + +func (x *GetRaceRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 } // Request for ListRaces call. @@ -87,7 +134,7 @@ type ListRacesRequest struct { func (x *ListRacesRequest) Reset() { *x = ListRacesRequest{} if protoimpl.UnsafeEnabled { - mi := &file_racing_racing_proto_msgTypes[0] + mi := &file_racing_racing_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -100,7 +147,7 @@ func (x *ListRacesRequest) String() string { func (*ListRacesRequest) ProtoMessage() {} func (x *ListRacesRequest) ProtoReflect() protoreflect.Message { - mi := &file_racing_racing_proto_msgTypes[0] + mi := &file_racing_racing_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -113,7 +160,7 @@ func (x *ListRacesRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ListRacesRequest.ProtoReflect.Descriptor instead. func (*ListRacesRequest) Descriptor() ([]byte, []int) { - return file_racing_racing_proto_rawDescGZIP(), []int{0} + return file_racing_racing_proto_rawDescGZIP(), []int{1} } func (x *ListRacesRequest) GetFilter() *ListRacesRequestFilter { @@ -142,7 +189,7 @@ type ListRacesResponse struct { func (x *ListRacesResponse) Reset() { *x = ListRacesResponse{} if protoimpl.UnsafeEnabled { - mi := &file_racing_racing_proto_msgTypes[1] + mi := &file_racing_racing_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -155,7 +202,7 @@ func (x *ListRacesResponse) String() string { func (*ListRacesResponse) ProtoMessage() {} func (x *ListRacesResponse) ProtoReflect() protoreflect.Message { - mi := &file_racing_racing_proto_msgTypes[1] + mi := &file_racing_racing_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -168,7 +215,7 @@ func (x *ListRacesResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ListRacesResponse.ProtoReflect.Descriptor instead. func (*ListRacesResponse) Descriptor() ([]byte, []int) { - return file_racing_racing_proto_rawDescGZIP(), []int{1} + return file_racing_racing_proto_rawDescGZIP(), []int{2} } func (x *ListRacesResponse) GetRaces() []*Race { @@ -192,7 +239,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) } @@ -205,7 +252,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 { @@ -218,7 +265,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 { @@ -259,7 +306,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) } @@ -272,7 +319,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 { @@ -285,7 +332,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 { @@ -345,50 +392,57 @@ var file_racing_racing_proto_rawDesc = []byte{ 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, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x65, 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, 0x12, 0x19, 0x0a, 0x08, 0x6f, 0x72, 0x64, 0x65, - 0x72, 0x5f, 0x62, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x72, 0x64, 0x65, - 0x72, 0x42, 0x79, 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, 0x64, 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, 0x1d, 0x0a, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, - 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x07, 0x76, 0x69, 0x73, 0x69, - 0x62, 0x6c, 0x65, 0x88, 0x01, 0x01, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x76, 0x69, 0x73, 0x69, 0x62, - 0x6c, 0x65, 0x22, 0xb0, 0x02, 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, 0x2b, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x13, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, 0x63, 0x65, 0x2e, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x36, 0x0a, - 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x54, 0x41, 0x54, 0x55, - 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, - 0x08, 0x0a, 0x04, 0x4f, 0x50, 0x45, 0x4e, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 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, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x20, 0x0a, 0x0e, + 0x47, 0x65, 0x74, 0x52, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x22, 0x65, + 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, 0x12, 0x19, 0x0a, 0x08, 0x6f, 0x72, + 0x64, 0x65, 0x72, 0x5f, 0x62, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x72, + 0x64, 0x65, 0x72, 0x42, 0x79, 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, 0x64, + 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, 0x1d, 0x0a, 0x07, 0x76, 0x69, 0x73, + 0x69, 0x62, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x07, 0x76, 0x69, + 0x73, 0x69, 0x62, 0x6c, 0x65, 0x88, 0x01, 0x01, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x76, 0x69, 0x73, + 0x69, 0x62, 0x6c, 0x65, 0x22, 0xb0, 0x02, 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, 0x2b, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x07, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x13, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, 0x63, 0x65, + 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, + 0x36, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x54, 0x41, + 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, + 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4f, 0x50, 0x45, 0x4e, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x43, + 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x10, 0x02, 0x32, 0xae, 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, + 0x47, 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, 0x16, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x12, 0x0e, 0x2f, 0x76, 0x31, 0x2f, 0x72, 0x61, + 0x63, 0x65, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x42, 0x09, 0x5a, 0x07, 0x2f, 0x72, 0x61, 0x63, + 0x69, 0x6e, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -404,24 +458,27 @@ func file_racing_racing_proto_rawDescGZIP() []byte { } var file_racing_racing_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -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{}{ (Race_Status)(0), // 0: racing.Race.Status - (*ListRacesRequest)(nil), // 1: racing.ListRacesRequest - (*ListRacesResponse)(nil), // 2: racing.ListRacesResponse - (*ListRacesRequestFilter)(nil), // 3: racing.ListRacesRequestFilter - (*Race)(nil), // 4: racing.Race - (*timestamp.Timestamp)(nil), // 5: google.protobuf.Timestamp + (*GetRaceRequest)(nil), // 1: racing.GetRaceRequest + (*ListRacesRequest)(nil), // 2: racing.ListRacesRequest + (*ListRacesResponse)(nil), // 3: racing.ListRacesResponse + (*ListRacesRequestFilter)(nil), // 4: racing.ListRacesRequestFilter + (*Race)(nil), // 5: racing.Race + (*timestamp.Timestamp)(nil), // 6: google.protobuf.Timestamp } var file_racing_racing_proto_depIdxs = []int32{ - 3, // 0: racing.ListRacesRequest.filter:type_name -> racing.ListRacesRequestFilter - 4, // 1: racing.ListRacesResponse.races:type_name -> racing.Race - 5, // 2: racing.Race.advertised_start_time:type_name -> google.protobuf.Timestamp + 4, // 0: racing.ListRacesRequest.filter:type_name -> racing.ListRacesRequestFilter + 5, // 1: racing.ListRacesResponse.races:type_name -> racing.Race + 6, // 2: racing.Race.advertised_start_time:type_name -> google.protobuf.Timestamp 0, // 3: racing.Race.status:type_name -> racing.Race.Status - 1, // 4: racing.Racing.ListRaces:input_type -> racing.ListRacesRequest - 2, // 5: racing.Racing.ListRaces:output_type -> racing.ListRacesResponse - 5, // [5:6] is the sub-list for method output_type - 4, // [4:5] is the sub-list for method input_type + 2, // 4: racing.Racing.ListRaces:input_type -> racing.ListRacesRequest + 1, // 5: racing.Racing.GetRace:input_type -> racing.GetRaceRequest + 3, // 6: racing.Racing.ListRaces:output_type -> racing.ListRacesResponse + 5, // 7: racing.Racing.GetRace:output_type -> racing.Race + 6, // [6:8] is the sub-list for method output_type + 4, // [4:6] is the sub-list for method input_type 4, // [4:4] is the sub-list for extension type_name 4, // [4:4] is the sub-list for extension extendee 0, // [0:4] is the sub-list for field type_name @@ -434,7 +491,7 @@ func file_racing_racing_proto_init() { } if !protoimpl.UnsafeEnabled { file_racing_racing_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListRacesRequest); i { + switch v := v.(*GetRaceRequest); i { case 0: return &v.state case 1: @@ -446,7 +503,7 @@ func file_racing_racing_proto_init() { } } file_racing_racing_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListRacesResponse); i { + switch v := v.(*ListRacesRequest); i { case 0: return &v.state case 1: @@ -458,7 +515,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.(*ListRacesResponse); i { case 0: return &v.state case 1: @@ -470,6 +527,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 @@ -482,14 +551,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: 1, - 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..eac11da 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["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", 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["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", 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, 1, 5, 2}, []string{"v1", "races", "id"}, "")) ) 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 d691b3e..8d291bf 100644 --- a/api/proto/racing/racing.proto +++ b/api/proto/racing/racing.proto @@ -11,10 +11,19 @@ service Racing { rpc ListRaces(ListRacesRequest) returns (ListRacesResponse) { option (google.api.http) = { post: "/v1/list-races", body: "*" }; } + + // GetRace will return a specific Race by its ID. + rpc GetRace(GetRaceRequest) returns (Race) { + option (google.api.http) = { get: "/v1/races/{id}" }; + } } /* Requests/Responses */ +message GetRaceRequest { + int64 id = 1; +} + // Request for ListRaces call. message ListRacesRequest { ListRacesRequestFilter filter = 1; diff --git a/api/proto/racing/racing_grpc.pb.go b/api/proto/racing/racing_grpc.pb.go index 6325105..eeff980 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 will return a specific Race by its ID. + 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 will return a specific Race by its ID. + 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/queries.go b/racing/db/queries.go index f8bd7a1..23a67a2 100644 --- a/racing/db/queries.go +++ b/racing/db/queries.go @@ -2,6 +2,7 @@ package db const ( racesList = "list" + racesGet = "get" ) func getRaceQueries() map[string]string { @@ -16,5 +17,16 @@ func getRaceQueries() map[string]string { advertised_start_time FROM races `, + racesGet: ` + SELECT + id, + meeting_id, + name, + number, + visible, + advertised_start_time + FROM races + WHERE id = ? + `, } } diff --git a/racing/db/races.go b/racing/db/races.go index b50ed6c..b226808 100644 --- a/racing/db/races.go +++ b/racing/db/races.go @@ -15,6 +15,8 @@ import ( ) var advertised_start_time = "advertised_start_time" + +// Add more in the future as we want to order by other fields var validOrderByFields = []string{advertised_start_time} // RacesRepo provides repository access to races. @@ -24,6 +26,9 @@ type RacesRepo interface { // List will return a list of races. List(filter *racing.ListRacesRequestFilter, orderBy string) ([]*racing.Race, error) + + // Get will return a specific Race by its ID. + Get(id int64) (*racing.Race, error) } type racesRepo struct { @@ -80,6 +85,30 @@ func (r *racesRepo) List(filter *racing.ListRacesRequestFilter, orderBy string) return races, nil } +func (r *racesRepo) Get(id int64) (*racing.Race, error) { + var ( + query string + args []interface{} + ) + + query = getRaceQueries()[racesGet] + + args = append(args, id) + + row := r.db.QueryRow(query, args...) + + race, err := r.scanRace(row) + + if err != nil { + return nil, err + } + + r.addStatusToRace(race) + + return race, nil + +} + func (r *racesRepo) applyFilter(query string, filter *racing.ListRacesRequestFilter) (string, []interface{}) { var ( clauses []string @@ -204,3 +233,26 @@ func (m *racesRepo) scanRaces( return races, nil } + +func (m *racesRepo) scanRace( + row *sql.Row, +) (*racing.Race, error) { + var race racing.Race + var 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 + + return &race, nil +} diff --git a/racing/errors/errors.go b/racing/errors/errors.go new file mode 100644 index 0000000..1141f7b --- /dev/null +++ b/racing/errors/errors.go @@ -0,0 +1,9 @@ +package errors + +const ErrInvalidRaceID = RacingErr("invalid Race ID") + +type RacingErr string + +func (e RacingErr) Error() string { + return string(e) +} diff --git a/racing/proto/racing/racing.pb.go b/racing/proto/racing/racing.pb.go index c54d1e2..607d808 100644 --- a/racing/proto/racing/racing.pb.go +++ b/racing/proto/racing/racing.pb.go @@ -70,7 +70,54 @@ func (x Race_Status) Number() protoreflect.EnumNumber { // Deprecated: Use Race_Status.Descriptor instead. func (Race_Status) EnumDescriptor() ([]byte, []int) { - return file_racing_racing_proto_rawDescGZIP(), []int{3, 0} + return file_racing_racing_proto_rawDescGZIP(), []int{4, 0} +} + +type GetRaceRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *GetRaceRequest) Reset() { + *x = GetRaceRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_racing_racing_proto_msgTypes[0] + 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[0] + 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{0} +} + +func (x *GetRaceRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 } type ListRacesRequest struct { @@ -85,7 +132,7 @@ type ListRacesRequest struct { func (x *ListRacesRequest) Reset() { *x = ListRacesRequest{} if protoimpl.UnsafeEnabled { - mi := &file_racing_racing_proto_msgTypes[0] + mi := &file_racing_racing_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -98,7 +145,7 @@ func (x *ListRacesRequest) String() string { func (*ListRacesRequest) ProtoMessage() {} func (x *ListRacesRequest) ProtoReflect() protoreflect.Message { - mi := &file_racing_racing_proto_msgTypes[0] + mi := &file_racing_racing_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -111,7 +158,7 @@ func (x *ListRacesRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ListRacesRequest.ProtoReflect.Descriptor instead. func (*ListRacesRequest) Descriptor() ([]byte, []int) { - return file_racing_racing_proto_rawDescGZIP(), []int{0} + return file_racing_racing_proto_rawDescGZIP(), []int{1} } func (x *ListRacesRequest) GetFilter() *ListRacesRequestFilter { @@ -140,7 +187,7 @@ type ListRacesResponse struct { func (x *ListRacesResponse) Reset() { *x = ListRacesResponse{} if protoimpl.UnsafeEnabled { - mi := &file_racing_racing_proto_msgTypes[1] + mi := &file_racing_racing_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -153,7 +200,7 @@ func (x *ListRacesResponse) String() string { func (*ListRacesResponse) ProtoMessage() {} func (x *ListRacesResponse) ProtoReflect() protoreflect.Message { - mi := &file_racing_racing_proto_msgTypes[1] + mi := &file_racing_racing_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -166,7 +213,7 @@ func (x *ListRacesResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ListRacesResponse.ProtoReflect.Descriptor instead. func (*ListRacesResponse) Descriptor() ([]byte, []int) { - return file_racing_racing_proto_rawDescGZIP(), []int{1} + return file_racing_racing_proto_rawDescGZIP(), []int{2} } func (x *ListRacesResponse) GetRaces() []*Race { @@ -190,7 +237,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) } @@ -203,7 +250,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 { @@ -216,7 +263,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 { @@ -257,7 +304,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) } @@ -270,7 +317,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 { @@ -283,7 +330,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 { @@ -341,49 +388,54 @@ 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, 0x65, - 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, 0x12, 0x19, 0x0a, 0x08, 0x6f, 0x72, - 0x64, 0x65, 0x72, 0x5f, 0x62, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x72, - 0x64, 0x65, 0x72, 0x42, 0x79, 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, 0x64, - 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, 0x1d, 0x0a, 0x07, 0x76, 0x69, 0x73, - 0x69, 0x62, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x07, 0x76, 0x69, - 0x73, 0x69, 0x62, 0x6c, 0x65, 0x88, 0x01, 0x01, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x76, 0x69, 0x73, - 0x69, 0x62, 0x6c, 0x65, 0x22, 0xb0, 0x02, 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, 0x2b, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x07, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x13, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, 0x63, 0x65, - 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, - 0x36, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x54, 0x41, - 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, - 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4f, 0x50, 0x45, 0x4e, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 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, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x20, + 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x52, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, + 0x22, 0x65, 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, 0x12, 0x19, 0x0a, 0x08, + 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x62, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x6f, 0x72, 0x64, 0x65, 0x72, 0x42, 0x79, 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, 0x64, 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, 0x1d, 0x0a, 0x07, 0x76, + 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x07, + 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x88, 0x01, 0x01, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x76, + 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x22, 0xb0, 0x02, 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, 0x2b, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x13, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, + 0x63, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x22, 0x36, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x12, 0x53, + 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, + 0x44, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4f, 0x50, 0x45, 0x4e, 0x10, 0x01, 0x12, 0x0a, 0x0a, + 0x06, 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 ( @@ -399,24 +451,27 @@ func file_racing_racing_proto_rawDescGZIP() []byte { } var file_racing_racing_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -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{}{ (Race_Status)(0), // 0: racing.Race.Status - (*ListRacesRequest)(nil), // 1: racing.ListRacesRequest - (*ListRacesResponse)(nil), // 2: racing.ListRacesResponse - (*ListRacesRequestFilter)(nil), // 3: racing.ListRacesRequestFilter - (*Race)(nil), // 4: racing.Race - (*timestamp.Timestamp)(nil), // 5: google.protobuf.Timestamp + (*GetRaceRequest)(nil), // 1: racing.GetRaceRequest + (*ListRacesRequest)(nil), // 2: racing.ListRacesRequest + (*ListRacesResponse)(nil), // 3: racing.ListRacesResponse + (*ListRacesRequestFilter)(nil), // 4: racing.ListRacesRequestFilter + (*Race)(nil), // 5: racing.Race + (*timestamp.Timestamp)(nil), // 6: google.protobuf.Timestamp } var file_racing_racing_proto_depIdxs = []int32{ - 3, // 0: racing.ListRacesRequest.filter:type_name -> racing.ListRacesRequestFilter - 4, // 1: racing.ListRacesResponse.races:type_name -> racing.Race - 5, // 2: racing.Race.advertised_start_time:type_name -> google.protobuf.Timestamp + 4, // 0: racing.ListRacesRequest.filter:type_name -> racing.ListRacesRequestFilter + 5, // 1: racing.ListRacesResponse.races:type_name -> racing.Race + 6, // 2: racing.Race.advertised_start_time:type_name -> google.protobuf.Timestamp 0, // 3: racing.Race.status:type_name -> racing.Race.Status - 1, // 4: racing.Racing.ListRaces:input_type -> racing.ListRacesRequest - 2, // 5: racing.Racing.ListRaces:output_type -> racing.ListRacesResponse - 5, // [5:6] is the sub-list for method output_type - 4, // [4:5] is the sub-list for method input_type + 2, // 4: racing.Racing.ListRaces:input_type -> racing.ListRacesRequest + 1, // 5: racing.Racing.GetRace:input_type -> racing.GetRaceRequest + 3, // 6: racing.Racing.ListRaces:output_type -> racing.ListRacesResponse + 5, // 7: racing.Racing.GetRace:output_type -> racing.Race + 6, // [6:8] is the sub-list for method output_type + 4, // [4:6] is the sub-list for method input_type 4, // [4:4] is the sub-list for extension type_name 4, // [4:4] is the sub-list for extension extendee 0, // [0:4] is the sub-list for field type_name @@ -429,7 +484,7 @@ func file_racing_racing_proto_init() { } if !protoimpl.UnsafeEnabled { file_racing_racing_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListRacesRequest); i { + switch v := v.(*GetRaceRequest); i { case 0: return &v.state case 1: @@ -441,7 +496,7 @@ func file_racing_racing_proto_init() { } } file_racing_racing_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListRacesResponse); i { + switch v := v.(*ListRacesRequest); i { case 0: return &v.state case 1: @@ -453,7 +508,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.(*ListRacesResponse); i { case 0: return &v.state case 1: @@ -465,6 +520,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 @@ -477,14 +544,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: 1, - NumMessages: 4, + NumMessages: 5, NumExtensions: 0, NumServices: 1, }, diff --git a/racing/proto/racing/racing.proto b/racing/proto/racing/racing.proto index 4591a0c..989f0f2 100644 --- a/racing/proto/racing/racing.proto +++ b/racing/proto/racing/racing.proto @@ -8,10 +8,17 @@ import "google/protobuf/timestamp.proto"; service Racing { // ListRaces will return a collection of all races. rpc ListRaces(ListRacesRequest) returns (ListRacesResponse) {} + + // GetRace will return a specific Race by its ID. + rpc GetRace(GetRaceRequest) returns (Race) {} } /* Requests/Responses */ +message GetRaceRequest { + int64 id = 1; +} + message ListRacesRequest { ListRacesRequestFilter filter = 1; string order_by = 2; diff --git a/racing/proto/racing/racing_grpc.pb.go b/racing/proto/racing/racing_grpc.pb.go index 44b6818..08bea09 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 will return a specific Race by its ID. + 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 will return a specific Race by its ID. + 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 576023c..3864b4f 100644 --- a/racing/service/racing.go +++ b/racing/service/racing.go @@ -2,6 +2,7 @@ package service import ( "git.neds.sh/matty/entain/racing/db" + "git.neds.sh/matty/entain/racing/errors" "git.neds.sh/matty/entain/racing/proto/racing" "golang.org/x/net/context" ) @@ -9,6 +10,9 @@ import ( type Racing interface { // ListRaces will return a collection of races. ListRaces(ctx context.Context, in *racing.ListRacesRequest) (*racing.ListRacesResponse, error) + + // GetRace will return a specific race by its ID. + GetRace(ctx context.Context, in *racing.GetRaceRequest) (*racing.Race, error) } // racingService implements the Racing interface. @@ -29,3 +33,15 @@ 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.Id <= 0 { + return nil, errors.ErrInvalidRaceID + } + race, err := s.racesRepo.Get(in.Id) + if err != nil { + return nil, err + } + + return race, nil +} diff --git a/racing/service/racing_test.go b/racing/service/racing_test.go index 295e05e..e6212ab 100644 --- a/racing/service/racing_test.go +++ b/racing/service/racing_test.go @@ -1,10 +1,12 @@ package service import ( + "errors" "sort" "testing" "time" + re "git.neds.sh/matty/entain/racing/errors" "git.neds.sh/matty/entain/racing/proto/racing" "git.neds.sh/matty/entain/racing/utils" "github.com/golang/protobuf/ptypes/timestamp" @@ -13,12 +15,17 @@ import ( ) // Mocking the repo for testing the service layer -type mockRacesRepo struct{} +type mockRacesRepo struct { + shouldError bool +} func (m *mockRacesRepo) Init() error { return nil } // Need to mock the return values from the List method so the repo "returns" what the service expects, so we can test the service logic func (m *mockRacesRepo) List(filter *racing.ListRacesRequestFilter, orderBy string) ([]*racing.Race, error) { + if m.shouldError { + return nil, errors.New("[List] mock error") + } races := []*racing.Race{ {Id: 1, Name: "Race 1", Visible: true, MeetingId: 1, AdvertisedStartTime: utils.GetProtoTimestamp(2024, time.December, 25, 0, 0, 0), Status: racing.Race_CLOSED}, {Id: 2, Name: "Race 2", Visible: false, MeetingId: 2, AdvertisedStartTime: ×tamp.Timestamp{Seconds: time.Now().Add(24 * time.Hour).Unix()}, Status: racing.Race_OPEN}, @@ -77,6 +84,19 @@ func (m *mockRacesRepo) List(filter *racing.ListRacesRequestFilter, orderBy stri // no filter set, return all potentially sorted races return races, nil } +func (m *mockRacesRepo) Get(id int64) (*racing.Race, error) { + if m.shouldError { + return nil, errors.New("[Get] mock error") + } + return &racing.Race{ + Id: 1, + Name: "Race 1", + Visible: true, + MeetingId: 1, + AdvertisedStartTime: utils.GetProtoTimestamp(2024, time.December, 25, 0, 0, 0), + Status: racing.Race_CLOSED, + }, nil +} func TestListRacesFilter(t *testing.T) { repo := &mockRacesRepo{} @@ -296,3 +316,100 @@ func TestRacesHaveStatus(t *testing.T) { } }) } + +func TestListRaces(t *testing.T) { + repo := &mockRacesRepo{} + service := NewRacingService(repo) + ctx := context.Background() + + t.Run("returns all races", func(t *testing.T) { + req := &racing.ListRacesRequest{} + resp, err := service.ListRaces(ctx, req) + + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if len(resp.Races) != 2 { + t.Errorf("expected 2 races, got %d", len(resp.Races)) + } + }) + t.Run("returns an error", func(t *testing.T) { + repo.shouldError = true // Simulate an error in the repo + defer func() { repo.shouldError = false }() // Reset after test + req := &racing.ListRacesRequest{} + resp, err := service.ListRaces(ctx, req) + + if err == nil { + t.Fatalf("expected error, got nil") + } + + if resp != nil { + t.Errorf("expected nil response, got %v", resp) + } + }) +} + +func TestGetRace(t *testing.T) { + repo := &mockRacesRepo{} + service := NewRacingService(repo) + ctx := context.Background() + + t.Run("returns race by ID", func(t *testing.T) { + req := &racing.GetRaceRequest{ + Id: 1, + } + + race, err := service.GetRace(ctx, req) + + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if race == nil { + t.Errorf("expected race, got nil") + } + + if race.Id != 1 { + t.Errorf("expected race ID 1, got %d", race.Id) + } + }) + + t.Run("returns an error for non-existent race", func(t *testing.T) { + repo.shouldError = true // Simulate an error in the repo + defer func() { repo.shouldError = false }() // Reset after test + req := &racing.GetRaceRequest{ + Id: 999, + } + + race, err := service.GetRace(ctx, req) + + if err == nil { + t.Fatalf("expected error, got nil") + } + + if race != nil { + t.Errorf("expected nil race, got %v", race) + } + }) + + t.Run("returns ErrInvalidRaceID error for invalid race ID", func(t *testing.T) { + req := &racing.GetRaceRequest{ + Id: 0, + } + + race, err := service.GetRace(ctx, req) + + if err == nil { + t.Fatalf("expected error, got nil") + } + + if race != nil { + t.Errorf("expected nil race, got %v", race) + } + + if err != re.ErrInvalidRaceID { + t.Errorf("expected error %v, got %v", re.ErrInvalidRaceID, err) + } + }) +}