From 9be2511882a054c2c6262c0bce8e87b436de7d01 Mon Sep 17 00:00:00 2001 From: Jakob Haahr Taankvist Date: Thu, 21 Nov 2024 15:50:17 +0100 Subject: [PATCH] Add IDL for shard distributor lookups (#6516) What changed? Added IDLs for looking up the owner of a shard in shard distributor Why? To enable looking up the owner of a shard in shard distributor How did you test it? Potential risks Release notes Documentation Changes --- .gen/proto/sharddistributor/v1/service.pb.go | 640 ++++++++++++++++++ .../sharddistributor/v1/service.pb.yarpc.go | 283 ++++++++ .../cadence/sharddistributor/v1/service.proto | 42 ++ 3 files changed, 965 insertions(+) create mode 100644 .gen/proto/sharddistributor/v1/service.pb.go create mode 100644 .gen/proto/sharddistributor/v1/service.pb.yarpc.go create mode 100644 proto/internal/uber/cadence/sharddistributor/v1/service.proto diff --git a/.gen/proto/sharddistributor/v1/service.pb.go b/.gen/proto/sharddistributor/v1/service.pb.go new file mode 100644 index 00000000000..ecd7956a0bb --- /dev/null +++ b/.gen/proto/sharddistributor/v1/service.pb.go @@ -0,0 +1,640 @@ +// The MIT License (MIT) + +// Copyright (c) 2017-2020 Uber Technologies Inc. + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: uber/cadence/sharddistributor/v1/service.proto + +package sharddistributorv1 + +import ( + fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + + proto "github.com/gogo/protobuf/proto" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type GetShardOwnerRequest struct { + ShardKey string `protobuf:"bytes,1,opt,name=shard_key,json=shardKey,proto3" json:"shard_key,omitempty"` + Namespace string `protobuf:"bytes,2,opt,name=namespace,proto3" json:"namespace,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetShardOwnerRequest) Reset() { *m = GetShardOwnerRequest{} } +func (m *GetShardOwnerRequest) String() string { return proto.CompactTextString(m) } +func (*GetShardOwnerRequest) ProtoMessage() {} +func (*GetShardOwnerRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_0055bfd59dff1f95, []int{0} +} +func (m *GetShardOwnerRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetShardOwnerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetShardOwnerRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GetShardOwnerRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetShardOwnerRequest.Merge(m, src) +} +func (m *GetShardOwnerRequest) XXX_Size() int { + return m.Size() +} +func (m *GetShardOwnerRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetShardOwnerRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetShardOwnerRequest proto.InternalMessageInfo + +func (m *GetShardOwnerRequest) GetShardKey() string { + if m != nil { + return m.ShardKey + } + return "" +} + +func (m *GetShardOwnerRequest) GetNamespace() string { + if m != nil { + return m.Namespace + } + return "" +} + +type GetShardOwnerResponse struct { + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` + Namespace string `protobuf:"bytes,2,opt,name=namespace,proto3" json:"namespace,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetShardOwnerResponse) Reset() { *m = GetShardOwnerResponse{} } +func (m *GetShardOwnerResponse) String() string { return proto.CompactTextString(m) } +func (*GetShardOwnerResponse) ProtoMessage() {} +func (*GetShardOwnerResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_0055bfd59dff1f95, []int{1} +} +func (m *GetShardOwnerResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetShardOwnerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetShardOwnerResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GetShardOwnerResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetShardOwnerResponse.Merge(m, src) +} +func (m *GetShardOwnerResponse) XXX_Size() int { + return m.Size() +} +func (m *GetShardOwnerResponse) XXX_DiscardUnknown() { + xxx_messageInfo_GetShardOwnerResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_GetShardOwnerResponse proto.InternalMessageInfo + +func (m *GetShardOwnerResponse) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *GetShardOwnerResponse) GetNamespace() string { + if m != nil { + return m.Namespace + } + return "" +} + +func init() { + proto.RegisterType((*GetShardOwnerRequest)(nil), "uber.cadence.sharddistributor.v1.GetShardOwnerRequest") + proto.RegisterType((*GetShardOwnerResponse)(nil), "uber.cadence.sharddistributor.v1.GetShardOwnerResponse") +} + +func init() { + proto.RegisterFile("uber/cadence/sharddistributor/v1/service.proto", fileDescriptor_0055bfd59dff1f95) +} + +var fileDescriptor_0055bfd59dff1f95 = []byte{ + // 261 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x2b, 0x4d, 0x4a, 0x2d, + 0xd2, 0x4f, 0x4e, 0x4c, 0x49, 0xcd, 0x4b, 0x4e, 0xd5, 0x2f, 0xce, 0x48, 0x2c, 0x4a, 0x49, 0xc9, + 0x2c, 0x2e, 0x29, 0xca, 0x4c, 0x2a, 0x2d, 0xc9, 0x2f, 0xd2, 0x2f, 0x33, 0xd4, 0x2f, 0x4e, 0x2d, + 0x2a, 0xcb, 0x4c, 0x4e, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, 0x00, 0xa9, 0xd7, 0x83, + 0xaa, 0xd7, 0x43, 0x57, 0xaf, 0x57, 0x66, 0xa8, 0x14, 0xc8, 0x25, 0xe2, 0x9e, 0x5a, 0x12, 0x0c, + 0x92, 0xf1, 0x2f, 0xcf, 0x4b, 0x2d, 0x0a, 0x4a, 0x2d, 0x2c, 0x4d, 0x2d, 0x2e, 0x11, 0x92, 0xe6, + 0xe2, 0x04, 0x2b, 0x8f, 0xcf, 0x4e, 0xad, 0x94, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0xe2, 0x00, + 0x0b, 0x78, 0xa7, 0x56, 0x0a, 0xc9, 0x70, 0x71, 0xe6, 0x25, 0xe6, 0xa6, 0x16, 0x17, 0x24, 0x26, + 0xa7, 0x4a, 0x30, 0x81, 0x25, 0x11, 0x02, 0x4a, 0xde, 0x5c, 0xa2, 0x68, 0x46, 0x16, 0x17, 0xe4, + 0xe7, 0x15, 0xa7, 0x0a, 0x89, 0x70, 0xb1, 0xe6, 0x83, 0x04, 0xa0, 0xe6, 0x41, 0x38, 0xf8, 0x0d, + 0x33, 0x9a, 0xc1, 0xc8, 0x25, 0x0c, 0x36, 0xca, 0x05, 0xe1, 0x6e, 0xc7, 0x00, 0x4f, 0xa1, 0x06, + 0x46, 0x2e, 0x5e, 0x14, 0x5b, 0x84, 0xcc, 0xf4, 0x08, 0x79, 0x56, 0x0f, 0x9b, 0x4f, 0xa5, 0xcc, + 0x49, 0xd6, 0x07, 0xf1, 0x8e, 0x53, 0xf8, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, + 0x78, 0x24, 0xc7, 0x18, 0xe5, 0x99, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, + 0x8f, 0x12, 0x4b, 0x7a, 0xe9, 0xa9, 0x79, 0xfa, 0xe0, 0xe8, 0xc0, 0x16, 0x61, 0xd6, 0xe8, 0x62, + 0x65, 0x86, 0x49, 0x6c, 0x60, 0xd5, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf1, 0x35, 0xe6, + 0x74, 0xee, 0x01, 0x00, 0x00, +} + +func (m *GetShardOwnerRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GetShardOwnerRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetShardOwnerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if len(m.Namespace) > 0 { + i -= len(m.Namespace) + copy(dAtA[i:], m.Namespace) + i = encodeVarintService(dAtA, i, uint64(len(m.Namespace))) + i-- + dAtA[i] = 0x12 + } + if len(m.ShardKey) > 0 { + i -= len(m.ShardKey) + copy(dAtA[i:], m.ShardKey) + i = encodeVarintService(dAtA, i, uint64(len(m.ShardKey))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *GetShardOwnerResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GetShardOwnerResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetShardOwnerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if len(m.Namespace) > 0 { + i -= len(m.Namespace) + copy(dAtA[i:], m.Namespace) + i = encodeVarintService(dAtA, i, uint64(len(m.Namespace))) + i-- + dAtA[i] = 0x12 + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintService(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintService(dAtA []byte, offset int, v uint64) int { + offset -= sovService(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GetShardOwnerRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ShardKey) + if l > 0 { + n += 1 + l + sovService(uint64(l)) + } + l = len(m.Namespace) + if l > 0 { + n += 1 + l + sovService(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *GetShardOwnerResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovService(uint64(l)) + } + l = len(m.Namespace) + if l > 0 { + n += 1 + l + sovService(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func sovService(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozService(x uint64) (n int) { + return sovService(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GetShardOwnerRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetShardOwnerRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetShardOwnerRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ShardKey", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthService + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ShardKey = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Namespace", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthService + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Namespace = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipService(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthService + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GetShardOwnerResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetShardOwnerResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetShardOwnerResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthService + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Namespace", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthService + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Namespace = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipService(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthService + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipService(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowService + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowService + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowService + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthService + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupService + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthService + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthService = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowService = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupService = fmt.Errorf("proto: unexpected end of group") +) diff --git a/.gen/proto/sharddistributor/v1/service.pb.yarpc.go b/.gen/proto/sharddistributor/v1/service.pb.yarpc.go new file mode 100644 index 00000000000..0c89a83d740 --- /dev/null +++ b/.gen/proto/sharddistributor/v1/service.pb.yarpc.go @@ -0,0 +1,283 @@ +// The MIT License (MIT) + +// Copyright (c) 2017-2020 Uber Technologies Inc. + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +// Code generated by protoc-gen-yarpc-go. DO NOT EDIT. +// source: uber/cadence/sharddistributor/v1/service.proto + +package sharddistributorv1 + +import ( + "context" + "io/ioutil" + "reflect" + + "github.com/gogo/protobuf/jsonpb" + "github.com/gogo/protobuf/proto" + "go.uber.org/fx" + "go.uber.org/yarpc" + "go.uber.org/yarpc/api/transport" + "go.uber.org/yarpc/api/x/restriction" + "go.uber.org/yarpc/encoding/protobuf" + "go.uber.org/yarpc/encoding/protobuf/reflection" +) + +var _ = ioutil.NopCloser + +// ShardDistributorAPIYARPCClient is the YARPC client-side interface for the ShardDistributorAPI service. +type ShardDistributorAPIYARPCClient interface { + GetShardOwner(context.Context, *GetShardOwnerRequest, ...yarpc.CallOption) (*GetShardOwnerResponse, error) +} + +func newShardDistributorAPIYARPCClient(clientConfig transport.ClientConfig, anyResolver jsonpb.AnyResolver, options ...protobuf.ClientOption) ShardDistributorAPIYARPCClient { + return &_ShardDistributorAPIYARPCCaller{protobuf.NewStreamClient( + protobuf.ClientParams{ + ServiceName: "uber.cadence.sharddistributor.v1.ShardDistributorAPI", + ClientConfig: clientConfig, + AnyResolver: anyResolver, + Options: options, + }, + )} +} + +// NewShardDistributorAPIYARPCClient builds a new YARPC client for the ShardDistributorAPI service. +func NewShardDistributorAPIYARPCClient(clientConfig transport.ClientConfig, options ...protobuf.ClientOption) ShardDistributorAPIYARPCClient { + return newShardDistributorAPIYARPCClient(clientConfig, nil, options...) +} + +// ShardDistributorAPIYARPCServer is the YARPC server-side interface for the ShardDistributorAPI service. +type ShardDistributorAPIYARPCServer interface { + GetShardOwner(context.Context, *GetShardOwnerRequest) (*GetShardOwnerResponse, error) +} + +type buildShardDistributorAPIYARPCProceduresParams struct { + Server ShardDistributorAPIYARPCServer + AnyResolver jsonpb.AnyResolver +} + +func buildShardDistributorAPIYARPCProcedures(params buildShardDistributorAPIYARPCProceduresParams) []transport.Procedure { + handler := &_ShardDistributorAPIYARPCHandler{params.Server} + return protobuf.BuildProcedures( + protobuf.BuildProceduresParams{ + ServiceName: "uber.cadence.sharddistributor.v1.ShardDistributorAPI", + UnaryHandlerParams: []protobuf.BuildProceduresUnaryHandlerParams{ + { + MethodName: "GetShardOwner", + Handler: protobuf.NewUnaryHandler( + protobuf.UnaryHandlerParams{ + Handle: handler.GetShardOwner, + NewRequest: newShardDistributorAPIServiceGetShardOwnerYARPCRequest, + AnyResolver: params.AnyResolver, + }, + ), + }, + }, + OnewayHandlerParams: []protobuf.BuildProceduresOnewayHandlerParams{}, + StreamHandlerParams: []protobuf.BuildProceduresStreamHandlerParams{}, + }, + ) +} + +// BuildShardDistributorAPIYARPCProcedures prepares an implementation of the ShardDistributorAPI service for YARPC registration. +func BuildShardDistributorAPIYARPCProcedures(server ShardDistributorAPIYARPCServer) []transport.Procedure { + return buildShardDistributorAPIYARPCProcedures(buildShardDistributorAPIYARPCProceduresParams{Server: server}) +} + +// FxShardDistributorAPIYARPCClientParams defines the input +// for NewFxShardDistributorAPIYARPCClient. It provides the +// paramaters to get a ShardDistributorAPIYARPCClient in an +// Fx application. +type FxShardDistributorAPIYARPCClientParams struct { + fx.In + + Provider yarpc.ClientConfig + AnyResolver jsonpb.AnyResolver `name:"yarpcfx" optional:"true"` + Restriction restriction.Checker `optional:"true"` +} + +// FxShardDistributorAPIYARPCClientResult defines the output +// of NewFxShardDistributorAPIYARPCClient. It provides a +// ShardDistributorAPIYARPCClient to an Fx application. +type FxShardDistributorAPIYARPCClientResult struct { + fx.Out + + Client ShardDistributorAPIYARPCClient + + // We are using an fx.Out struct here instead of just returning a client + // so that we can add more values or add named versions of the client in + // the future without breaking any existing code. +} + +// NewFxShardDistributorAPIYARPCClient provides a ShardDistributorAPIYARPCClient +// to an Fx application using the given name for routing. +// +// fx.Provide( +// sharddistributorv1.NewFxShardDistributorAPIYARPCClient("service-name"), +// ... +// ) +func NewFxShardDistributorAPIYARPCClient(name string, options ...protobuf.ClientOption) interface{} { + return func(params FxShardDistributorAPIYARPCClientParams) FxShardDistributorAPIYARPCClientResult { + cc := params.Provider.ClientConfig(name) + + if params.Restriction != nil { + if namer, ok := cc.GetUnaryOutbound().(transport.Namer); ok { + if err := params.Restriction.Check(protobuf.Encoding, namer.TransportName()); err != nil { + panic(err.Error()) + } + } + } + + return FxShardDistributorAPIYARPCClientResult{ + Client: newShardDistributorAPIYARPCClient(cc, params.AnyResolver, options...), + } + } +} + +// FxShardDistributorAPIYARPCProceduresParams defines the input +// for NewFxShardDistributorAPIYARPCProcedures. It provides the +// paramaters to get ShardDistributorAPIYARPCServer procedures in an +// Fx application. +type FxShardDistributorAPIYARPCProceduresParams struct { + fx.In + + Server ShardDistributorAPIYARPCServer + AnyResolver jsonpb.AnyResolver `name:"yarpcfx" optional:"true"` +} + +// FxShardDistributorAPIYARPCProceduresResult defines the output +// of NewFxShardDistributorAPIYARPCProcedures. It provides +// ShardDistributorAPIYARPCServer procedures to an Fx application. +// +// The procedures are provided to the "yarpcfx" value group. +// Dig 1.2 or newer must be used for this feature to work. +type FxShardDistributorAPIYARPCProceduresResult struct { + fx.Out + + Procedures []transport.Procedure `group:"yarpcfx"` + ReflectionMeta reflection.ServerMeta `group:"yarpcfx"` +} + +// NewFxShardDistributorAPIYARPCProcedures provides ShardDistributorAPIYARPCServer procedures to an Fx application. +// It expects a ShardDistributorAPIYARPCServer to be present in the container. +// +// fx.Provide( +// sharddistributorv1.NewFxShardDistributorAPIYARPCProcedures(), +// ... +// ) +func NewFxShardDistributorAPIYARPCProcedures() interface{} { + return func(params FxShardDistributorAPIYARPCProceduresParams) FxShardDistributorAPIYARPCProceduresResult { + return FxShardDistributorAPIYARPCProceduresResult{ + Procedures: buildShardDistributorAPIYARPCProcedures(buildShardDistributorAPIYARPCProceduresParams{ + Server: params.Server, + AnyResolver: params.AnyResolver, + }), + ReflectionMeta: ShardDistributorAPIReflectionMeta, + } + } +} + +// ShardDistributorAPIReflectionMeta is the reflection server metadata +// required for using the gRPC reflection protocol with YARPC. +// +// See https://github.com/grpc/grpc/blob/master/doc/server-reflection.md. +var ShardDistributorAPIReflectionMeta = reflection.ServerMeta{ + ServiceName: "uber.cadence.sharddistributor.v1.ShardDistributorAPI", + FileDescriptors: yarpcFileDescriptorClosure0055bfd59dff1f95, +} + +type _ShardDistributorAPIYARPCCaller struct { + streamClient protobuf.StreamClient +} + +func (c *_ShardDistributorAPIYARPCCaller) GetShardOwner(ctx context.Context, request *GetShardOwnerRequest, options ...yarpc.CallOption) (*GetShardOwnerResponse, error) { + responseMessage, err := c.streamClient.Call(ctx, "GetShardOwner", request, newShardDistributorAPIServiceGetShardOwnerYARPCResponse, options...) + if responseMessage == nil { + return nil, err + } + response, ok := responseMessage.(*GetShardOwnerResponse) + if !ok { + return nil, protobuf.CastError(emptyShardDistributorAPIServiceGetShardOwnerYARPCResponse, responseMessage) + } + return response, err +} + +type _ShardDistributorAPIYARPCHandler struct { + server ShardDistributorAPIYARPCServer +} + +func (h *_ShardDistributorAPIYARPCHandler) GetShardOwner(ctx context.Context, requestMessage proto.Message) (proto.Message, error) { + var request *GetShardOwnerRequest + var ok bool + if requestMessage != nil { + request, ok = requestMessage.(*GetShardOwnerRequest) + if !ok { + return nil, protobuf.CastError(emptyShardDistributorAPIServiceGetShardOwnerYARPCRequest, requestMessage) + } + } + response, err := h.server.GetShardOwner(ctx, request) + if response == nil { + return nil, err + } + return response, err +} + +func newShardDistributorAPIServiceGetShardOwnerYARPCRequest() proto.Message { + return &GetShardOwnerRequest{} +} + +func newShardDistributorAPIServiceGetShardOwnerYARPCResponse() proto.Message { + return &GetShardOwnerResponse{} +} + +var ( + emptyShardDistributorAPIServiceGetShardOwnerYARPCRequest = &GetShardOwnerRequest{} + emptyShardDistributorAPIServiceGetShardOwnerYARPCResponse = &GetShardOwnerResponse{} +) + +var yarpcFileDescriptorClosure0055bfd59dff1f95 = [][]byte{ + // uber/cadence/sharddistributor/v1/service.proto + []byte{ + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x2b, 0x4d, 0x4a, 0x2d, + 0xd2, 0x4f, 0x4e, 0x4c, 0x49, 0xcd, 0x4b, 0x4e, 0xd5, 0x2f, 0xce, 0x48, 0x2c, 0x4a, 0x49, 0xc9, + 0x2c, 0x2e, 0x29, 0xca, 0x4c, 0x2a, 0x2d, 0xc9, 0x2f, 0xd2, 0x2f, 0x33, 0xd4, 0x2f, 0x4e, 0x2d, + 0x2a, 0xcb, 0x4c, 0x4e, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, 0x00, 0xa9, 0xd7, 0x83, + 0xaa, 0xd7, 0x43, 0x57, 0xaf, 0x57, 0x66, 0xa8, 0x14, 0xc8, 0x25, 0xe2, 0x9e, 0x5a, 0x12, 0x0c, + 0x92, 0xf1, 0x2f, 0xcf, 0x4b, 0x2d, 0x0a, 0x4a, 0x2d, 0x2c, 0x4d, 0x2d, 0x2e, 0x11, 0x92, 0xe6, + 0xe2, 0x04, 0x2b, 0x8f, 0xcf, 0x4e, 0xad, 0x94, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0xe2, 0x00, + 0x0b, 0x78, 0xa7, 0x56, 0x0a, 0xc9, 0x70, 0x71, 0xe6, 0x25, 0xe6, 0xa6, 0x16, 0x17, 0x24, 0x26, + 0xa7, 0x4a, 0x30, 0x81, 0x25, 0x11, 0x02, 0x4a, 0xde, 0x5c, 0xa2, 0x68, 0x46, 0x16, 0x17, 0xe4, + 0xe7, 0x15, 0xa7, 0x0a, 0x89, 0x70, 0xb1, 0xe6, 0x83, 0x04, 0xa0, 0xe6, 0x41, 0x38, 0xf8, 0x0d, + 0x33, 0x9a, 0xc1, 0xc8, 0x25, 0x0c, 0x36, 0xca, 0x05, 0xe1, 0x6e, 0xc7, 0x00, 0x4f, 0xa1, 0x06, + 0x46, 0x2e, 0x5e, 0x14, 0x5b, 0x84, 0xcc, 0xf4, 0x08, 0x79, 0x56, 0x0f, 0x9b, 0x4f, 0xa5, 0xcc, + 0x49, 0xd6, 0x07, 0xf1, 0x8e, 0x93, 0x77, 0x94, 0x67, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, + 0x72, 0x7e, 0xae, 0x3e, 0x4a, 0xcc, 0xe8, 0xa5, 0xa7, 0xe6, 0xe9, 0x83, 0xa3, 0x00, 0x5b, 0x24, + 0x59, 0xa3, 0x8b, 0x95, 0x19, 0x26, 0xb1, 0x81, 0x55, 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, + 0x55, 0x06, 0xa6, 0x2a, 0xe2, 0x01, 0x00, 0x00, + }, +} + +func init() { + yarpc.RegisterClientBuilder( + func(clientConfig transport.ClientConfig, structField reflect.StructField) ShardDistributorAPIYARPCClient { + return NewShardDistributorAPIYARPCClient(clientConfig, protobuf.ClientBuilderOptions(clientConfig, structField)...) + }, + ) +} diff --git a/proto/internal/uber/cadence/sharddistributor/v1/service.proto b/proto/internal/uber/cadence/sharddistributor/v1/service.proto new file mode 100644 index 00000000000..3be71b4480c --- /dev/null +++ b/proto/internal/uber/cadence/sharddistributor/v1/service.proto @@ -0,0 +1,42 @@ +// Copyright (c) 2020 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +syntax = "proto3"; + +package uber.cadence.sharddistributor.v1; + +option go_package = "github.com/uber/cadence/.gen/proto/sharddistributor/v1;sharddistributorv1"; + +// ShardDistributorAPI is used to query shard distributor for the current owner of a shard +service ShardDistributorAPI { + + // GetShardOwner returns the owner of a specific shard + rpc GetShardOwner(GetShardOwnerRequest) returns (GetShardOwnerResponse); +} + +message GetShardOwnerRequest { + string shard_key = 1; + string namespace = 2; +} + +message GetShardOwnerResponse { + string owner = 1; + string namespace = 2; +}