diff --git a/api/proto/racing/racing.pb.go b/api/proto/racing/racing.pb.go index d60096a..dd60288 100644 --- a/api/proto/racing/racing.pb.go +++ b/api/proto/racing/racing.pb.go @@ -65,7 +65,7 @@ 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} } // Request for ListRaces call. @@ -124,6 +124,53 @@ func (x *ListRacesRequest) GetOrderBy() string { return "" } +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[1] + 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[1] + 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{1} +} + +func (x *GetRaceRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + // Response to ListRaces call. type ListRacesResponse struct { state protoimpl.MessageState @@ -136,7 +183,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) } @@ -149,7 +196,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 { @@ -162,7 +209,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 { @@ -185,7 +232,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) } @@ -198,7 +245,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 { @@ -211,7 +258,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 { @@ -252,7 +299,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) } @@ -265,7 +312,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 { @@ -278,7 +325,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 { @@ -346,42 +393,49 @@ var file_racing_racing_proto_rawDesc = []byte{ 0x52, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x1e, 0x0a, 0x08, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x62, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x07, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x42, 0x79, 0x88, 0x01, 0x01, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x6f, 0x72, 0x64, - 0x65, 0x72, 0x5f, 0x62, 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, 0x98, 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, - 0x1e, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0a, 0x0a, 0x06, 0x43, 0x4c, 0x4f, - 0x53, 0x45, 0x44, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4f, 0x50, 0x45, 0x4e, 0x10, 0x01, 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, + 0x65, 0x72, 0x5f, 0x62, 0x79, 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, 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, 0x98, 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, 0x1e, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0a, 0x0a, 0x06, 0x43, + 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4f, 0x50, 0x45, 0x4e, 0x10, + 0x01, 0x32, 0xad, 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, 0x46, 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, 0x15, 0x82, 0xd3, 0xe4, 0x93, + 0x02, 0x0f, 0x12, 0x0d, 0x2f, 0x76, 0x31, 0x2f, 0x72, 0x61, 0x63, 0x65, 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 ( @@ -397,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 - (*timestamppb.Timestamp)(nil), // 5: google.protobuf.Timestamp + (*GetRaceRequest)(nil), // 2: racing.GetRaceRequest + (*ListRacesResponse)(nil), // 3: racing.ListRacesResponse + (*ListRacesRequestFilter)(nil), // 4: racing.ListRacesRequestFilter + (*Race)(nil), // 5: racing.Race + (*timestamppb.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, // 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 @@ -439,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.(*GetRaceRequest); i { case 0: return &v.state case 1: @@ -451,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: @@ -463,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 @@ -476,14 +545,14 @@ func file_racing_racing_proto_init() { } } file_racing_racing_proto_msgTypes[0].OneofWrappers = []interface{}{} - 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 337b288..b579ac4 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", runtime.WithHTTPPathPattern("/v1/race/{id}")) + 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", runtime.WithHTTPPathPattern("/v1/race/{id}")) + 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", "race", "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 3075bf7..54e9620 100644 --- a/api/proto/racing/racing.proto +++ b/api/proto/racing/racing.proto @@ -11,6 +11,9 @@ service Racing { rpc ListRaces(ListRacesRequest) returns (ListRacesResponse) { option (google.api.http) = { post: "/v1/list-races", body: "*" }; } + rpc GetRace(GetRaceRequest) returns (Race) { + option (google.api.http) = { get: "/v1/race/{id}" }; + } } /* Requests/Responses */ @@ -22,6 +25,12 @@ message ListRacesRequest { optional string order_by = 2; } +// Request for GetRace call. +message GetRaceRequest { + // The unique id of the race. + int64 id = 1; +} + // Response to ListRaces call. message ListRacesResponse { repeated Race races = 1; diff --git a/api/proto/racing/racing_grpc.pb.go b/api/proto/racing/racing_grpc.pb.go index 6325105..5d45f70 100644 --- a/api/proto/racing/racing_grpc.pb.go +++ b/api/proto/racing/racing_grpc.pb.go @@ -20,6 +20,7 @@ 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(ctx context.Context, in *GetRaceRequest, opts ...grpc.CallOption) (*Race, error) } type racingClient struct { @@ -39,12 +40,22 @@ 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(context.Context, *GetRaceRequest) (*Race, error) mustEmbedUnimplementedRacingServer() } @@ -55,6 +66,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 +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) @@ -97,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/db/queries.go b/racing/db/queries.go index f8bd7a1..e401d8a 100644 --- a/racing/db/queries.go +++ b/racing/db/queries.go @@ -2,6 +2,7 @@ package db const ( racesList = "list" + getRace = "get" ) func getRaceQueries() map[string]string { @@ -16,5 +17,16 @@ func getRaceQueries() map[string]string { advertised_start_time FROM races `, + getRace: ` + 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 4c84ac5..9b5cb3c 100644 --- a/racing/db/races.go +++ b/racing/db/races.go @@ -22,6 +22,7 @@ type RacesRepo interface { InsertRace(*racing.Race) error // List will return a list of races. List(request *racing.ListRacesRequest) ([]*racing.Race, error) + Get(request *racing.GetRaceRequest) (*racing.Race, error) ListAll() ([]*racing.Race, error) } @@ -81,6 +82,32 @@ func (r *racesRepo) List(request *racing.ListRacesRequest) ([]*racing.Race, erro return r.scanRaces(rows) } +func (r *racesRepo) Get(request *racing.GetRaceRequest) (*racing.Race, error) { + var ( + query string + args []interface{} + ) + + query = getRaceQueries()[getRace] + + args = append(args, request.Id) + rows, err := r.db.Query(query, args...) + if err != nil { + return nil, err + } + + races, err := r.scanRaces(rows) + if err != nil { + return nil, err + } else if len(races) == 0 { + // No race found, return error. + return nil, sql.ErrNoRows + } else { + // Race found, return single race. + return races[0], nil + } +} + func (r *racesRepo) ListAll() ([]*racing.Race, error) { return r.listAll() } diff --git a/racing/db/races_test.go b/racing/db/races_test.go index 864ee11..f9e7a75 100644 --- a/racing/db/races_test.go +++ b/racing/db/races_test.go @@ -304,6 +304,43 @@ func TestStatusField(t *testing.T) { } } +func TestGetRaceRequest(t *testing.T) { + racingDB, err := GetTestDB("races", "TestGetRaceRequest") + if err != nil { + t.Fatalf("Failed to open testdb %v", err) + } + racesRepo := db.NewRacesRepo(racingDB) + _ = racesRepo.Init(false) + + tm1 := timestamppb.New(time.Now().AddDate(0, 0, 2)) + race1 := + racing.Race{Id: int64(1), MeetingId: int64(5), + Name: "Test1", Number: int64(5), + Visible: true, AdvertisedStartTime: tm1} + err = racesRepo.InsertRace(&race1) + if err != nil { + t.Fatalf("Failed to insert first race %v.", err) + } + tm2 := timestamppb.New(time.Now().AddDate(0, 0, -2)) + race2 := + racing.Race{Id: int64(5), MeetingId: int64(3), + Name: "Test2", Number: int64(9), + Visible: false, AdvertisedStartTime: tm2} + err = racesRepo.InsertRace(&race2) + if err != nil { + t.Fatalf("Failed to insert second race %v.", err) + } + + rq := racing.GetRaceRequest{Id: race2.Id} + rsp, err := racesRepo.Get(&rq) + if err != nil { + t.Fatalf("Unable to retrieve individual race %v", rq.Id) + } + if rsp.Name != race2.Name { + t.Fatalf("Invalid race returned %v", rsp.Id) + } +} + // Helpers // func GetRaces() []*racing.Race { diff --git a/racing/proto/README.md b/racing/proto/README.md index e7d0c5e..863afc8 100644 --- a/racing/proto/README.md +++ b/racing/proto/README.md @@ -6,11 +6,15 @@ This defines the protobuf message types for the racing API. **RPCS** - `ListRaces(ListRacesRequest) ListRacesResponse` +- `GetRace(GetRaceRequest) Race` ### ListRacesRequest - Supports a filter parameter of type `ListRacesRequestFilter`. - Supports a order_by parameter of the form defined by [Google API Design](https://cloud.google.com/apis/design/design_patterns#sorting_order). +### GetRaceRequest +- The ID of the race to be retrieved (int64). + ### ListRacesRequestFilter - A list of integer IDs can be supplied to perform a bulk lookup request. (optional) - A category filter can be supplied which finds any races which match the category (optional, case-insensitive). diff --git a/racing/proto/racing/racing.pb.go b/racing/proto/racing/racing.pb.go index 02495d3..7478213 100644 --- a/racing/proto/racing/racing.pb.go +++ b/racing/proto/racing/racing.pb.go @@ -64,7 +64,7 @@ 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 ListRacesRequest struct { @@ -122,6 +122,53 @@ func (x *ListRacesRequest) GetOrderBy() string { return "" } +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[1] + 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[1] + 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{1} +} + +func (x *GetRaceRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + // Response to ListRaces call. type ListRacesResponse struct { state protoimpl.MessageState @@ -134,7 +181,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) } @@ -147,7 +194,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 { @@ -160,7 +207,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 { @@ -183,7 +230,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) } @@ -196,7 +243,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 { @@ -209,7 +256,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 { @@ -250,7 +297,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) } @@ -263,7 +310,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 { @@ -276,7 +323,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 { @@ -342,41 +389,46 @@ var file_racing_racing_proto_rawDesc = []byte{ 0x65, 0x72, 0x52, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x1e, 0x0a, 0x08, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x62, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x07, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x42, 0x79, 0x88, 0x01, 0x01, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x6f, - 0x72, 0x64, 0x65, 0x72, 0x5f, 0x62, 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, 0x98, 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, 0x1e, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0a, 0x0a, 0x06, 0x43, - 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4f, 0x50, 0x45, 0x4e, 0x10, - 0x01, 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, + 0x72, 0x64, 0x65, 0x72, 0x5f, 0x62, 0x79, 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, 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, 0x98, 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, 0x1e, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0a, 0x0a, + 0x06, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4f, 0x50, 0x45, + 0x4e, 0x10, 0x01, 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 ( @@ -392,24 +444,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 - (*timestamppb.Timestamp)(nil), // 5: google.protobuf.Timestamp + (*GetRaceRequest)(nil), // 2: racing.GetRaceRequest + (*ListRacesResponse)(nil), // 3: racing.ListRacesResponse + (*ListRacesRequestFilter)(nil), // 4: racing.ListRacesRequestFilter + (*Race)(nil), // 5: racing.Race + (*timestamppb.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, // 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 +489,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.(*GetRaceRequest); i { case 0: return &v.state case 1: @@ -446,7 +501,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: @@ -458,6 +513,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 @@ -471,14 +538,14 @@ func file_racing_racing_proto_init() { } } file_racing_racing_proto_msgTypes[0].OneofWrappers = []interface{}{} - 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 892a858..cb85579 100644 --- a/racing/proto/racing/racing.proto +++ b/racing/proto/racing/racing.proto @@ -8,6 +8,7 @@ import "google/protobuf/timestamp.proto"; service Racing { // ListRaces will return a collection of all races. rpc ListRaces(ListRacesRequest) returns (ListRacesResponse) {} + rpc GetRace(GetRaceRequest) returns (Race) {} } /* Requests/Responses */ @@ -18,6 +19,12 @@ message ListRacesRequest { optional string order_by = 2; } +// Request for GetRace call. +message GetRaceRequest { + // The unique id of the race. + int64 id = 1; +} + // Response to ListRaces call. message ListRacesResponse { repeated Race races = 1; diff --git a/racing/proto/racing/racing_grpc.pb.go b/racing/proto/racing/racing_grpc.pb.go index 44b6818..133c23a 100644 --- a/racing/proto/racing/racing_grpc.pb.go +++ b/racing/proto/racing/racing_grpc.pb.go @@ -20,6 +20,7 @@ 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(ctx context.Context, in *GetRaceRequest, opts ...grpc.CallOption) (*Race, error) } type racingClient struct { @@ -39,12 +40,22 @@ 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(context.Context, *GetRaceRequest) (*Race, error) } // UnimplementedRacingServer should be embedded to have forward compatible implementations. @@ -54,6 +65,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 +98,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 +127,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 0464b11..b5f05bb 100644 --- a/racing/service/racing.go +++ b/racing/service/racing.go @@ -9,6 +9,7 @@ import ( type Racing interface { // ListRaces will return a collection of races. ListRaces(ctx context.Context, in *racing.ListRacesRequest) (*racing.ListRacesResponse, error) + GetRace(ctx context.Context, in *racing.GetRaceRequest) (*racing.Race, error) } // racingService implements the Racing interface. @@ -29,3 +30,12 @@ func (s *racingService) ListRaces(ctx context.Context, in *racing.ListRacesReque return &racing.ListRacesResponse{Races: races}, nil } + +// Retrieves a single race by its identifier, or, returns an error. +func (s *racingService) GetRace(ctx context.Context, in *racing.GetRaceRequest) (*racing.Race, error) { + race, err := s.racesRepo.Get(in) + if err != nil { + return nil, err + } + return race, nil +}