diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 3bfa890..25bdda0 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -23,5 +23,8 @@ # Data /svr/ @smartcontractkit/oev @smartcontractkit/op-tooling +# Ring +/ring/ @smartcontractkit/foundations @smartcontractkit/op-tooling + # Release changesets do not have owners /.changeset/** diff --git a/buf.yaml b/buf.yaml index 8fe18a9..6e28495 100644 --- a/buf.yaml +++ b/buf.yaml @@ -13,6 +13,13 @@ modules: - BASIC except: - FIELD_LOWER_SNAKE_CASE + - path: ring/pb + lint: + use: + - BASIC + except: + - FIELD_LOWER_SNAKE_CASE + - PACKAGE_DIRECTORY_MATCH - path: rmn/v1.6/proto lint: except: diff --git a/ring/Makefile b/ring/Makefile new file mode 100644 index 0000000..bf3965a --- /dev/null +++ b/ring/Makefile @@ -0,0 +1,7 @@ +.PHONY: clean +clean: ## Remove generated files + find ./go -name '*.pb.go' -delete + +.PHONY: generate +generate: clean ## Generate go-proto files + cd go && go generate ./... diff --git a/ring/go/arbiter.pb.go b/ring/go/arbiter.pb.go new file mode 100644 index 0000000..ac73244 --- /dev/null +++ b/ring/go/arbiter.pb.go @@ -0,0 +1,301 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc v5.29.3 +// source: arbiter.proto + +package ring + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + emptypb "google.golang.org/protobuf/types/known/emptypb" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ShardStatusRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Status map[uint32]*ShardStatus `protobuf:"bytes,1,rep,name=status,proto3" json:"status,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // shard_id -> status + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ShardStatusRequest) Reset() { + *x = ShardStatusRequest{} + mi := &file_arbiter_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ShardStatusRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ShardStatusRequest) ProtoMessage() {} + +func (x *ShardStatusRequest) ProtoReflect() protoreflect.Message { + mi := &file_arbiter_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ShardStatusRequest.ProtoReflect.Descriptor instead. +func (*ShardStatusRequest) Descriptor() ([]byte, []int) { + return file_arbiter_proto_rawDescGZIP(), []int{0} +} + +func (x *ShardStatusRequest) GetStatus() map[uint32]*ShardStatus { + if x != nil { + return x.Status + } + return nil +} + +type ArbiterResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + WantShards uint32 `protobuf:"varint,1,opt,name=want_shards,json=wantShards,proto3" json:"want_shards,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ArbiterResponse) Reset() { + *x = ArbiterResponse{} + mi := &file_arbiter_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ArbiterResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ArbiterResponse) ProtoMessage() {} + +func (x *ArbiterResponse) ProtoReflect() protoreflect.Message { + mi := &file_arbiter_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ArbiterResponse.ProtoReflect.Descriptor instead. +func (*ArbiterResponse) Descriptor() ([]byte, []int) { + return file_arbiter_proto_rawDescGZIP(), []int{1} +} + +func (x *ArbiterResponse) GetWantShards() uint32 { + if x != nil { + return x.WantShards + } + return 0 +} + +type ReplicaStatus struct { + state protoimpl.MessageState `protogen:"open.v1"` + WantShards uint32 `protobuf:"varint,1,opt,name=want_shards,json=wantShards,proto3" json:"want_shards,omitempty"` + Status map[uint32]*ShardStatus `protobuf:"bytes,2,rep,name=status,proto3" json:"status,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ReplicaStatus) Reset() { + *x = ReplicaStatus{} + mi := &file_arbiter_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ReplicaStatus) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReplicaStatus) ProtoMessage() {} + +func (x *ReplicaStatus) ProtoReflect() protoreflect.Message { + mi := &file_arbiter_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReplicaStatus.ProtoReflect.Descriptor instead. +func (*ReplicaStatus) Descriptor() ([]byte, []int) { + return file_arbiter_proto_rawDescGZIP(), []int{2} +} + +func (x *ReplicaStatus) GetWantShards() uint32 { + if x != nil { + return x.WantShards + } + return 0 +} + +func (x *ReplicaStatus) GetStatus() map[uint32]*ShardStatus { + if x != nil { + return x.Status + } + return nil +} + +type ConsensusWantShardsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + NShards uint32 `protobuf:"varint,1,opt,name=n_shards,json=nShards,proto3" json:"n_shards,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ConsensusWantShardsRequest) Reset() { + *x = ConsensusWantShardsRequest{} + mi := &file_arbiter_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ConsensusWantShardsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ConsensusWantShardsRequest) ProtoMessage() {} + +func (x *ConsensusWantShardsRequest) ProtoReflect() protoreflect.Message { + mi := &file_arbiter_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ConsensusWantShardsRequest.ProtoReflect.Descriptor instead. +func (*ConsensusWantShardsRequest) Descriptor() ([]byte, []int) { + return file_arbiter_proto_rawDescGZIP(), []int{3} +} + +func (x *ConsensusWantShardsRequest) GetNShards() uint32 { + if x != nil { + return x.NShards + } + return 0 +} + +var File_arbiter_proto protoreflect.FileDescriptor + +const file_arbiter_proto_rawDesc = "" + + "\n" + + "\rarbiter.proto\x12\x04ring\x1a\x1bgoogle/protobuf/empty.proto\x1a\fshared.proto\"\xa0\x01\n" + + "\x12ShardStatusRequest\x12<\n" + + "\x06status\x18\x01 \x03(\v2$.ring.ShardStatusRequest.StatusEntryR\x06status\x1aL\n" + + "\vStatusEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\rR\x03key\x12'\n" + + "\x05value\x18\x02 \x01(\v2\x11.ring.ShardStatusR\x05value:\x028\x01\"2\n" + + "\x0fArbiterResponse\x12\x1f\n" + + "\vwant_shards\x18\x01 \x01(\rR\n" + + "wantShards\"\xb7\x01\n" + + "\rReplicaStatus\x12\x1f\n" + + "\vwant_shards\x18\x01 \x01(\rR\n" + + "wantShards\x127\n" + + "\x06status\x18\x02 \x03(\v2\x1f.ring.ReplicaStatus.StatusEntryR\x06status\x1aL\n" + + "\vStatusEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\rR\x03key\x12'\n" + + "\x05value\x18\x02 \x01(\v2\x11.ring.ShardStatusR\x05value:\x028\x01\"7\n" + + "\x1aConsensusWantShardsRequest\x12\x19\n" + + "\bn_shards\x18\x01 \x01(\rR\anShards2P\n" + + "\aArbiter\x12E\n" + + "\x12GetDesiredReplicas\x12\x18.ring.ShardStatusRequest\x1a\x15.ring.ArbiterResponse2\x97\x01\n" + + "\rArbiterScaler\x125\n" + + "\x06Status\x12\x16.google.protobuf.Empty\x1a\x13.ring.ReplicaStatus\x12O\n" + + "\x13ConsensusWantShards\x12 .ring.ConsensusWantShardsRequest\x1a\x16.google.protobuf.EmptyB;Z9github.com/smartcontractkit/chainlink-protos/ring/go;ringb\x06proto3" + +var ( + file_arbiter_proto_rawDescOnce sync.Once + file_arbiter_proto_rawDescData []byte +) + +func file_arbiter_proto_rawDescGZIP() []byte { + file_arbiter_proto_rawDescOnce.Do(func() { + file_arbiter_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_arbiter_proto_rawDesc), len(file_arbiter_proto_rawDesc))) + }) + return file_arbiter_proto_rawDescData +} + +var file_arbiter_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_arbiter_proto_goTypes = []any{ + (*ShardStatusRequest)(nil), // 0: ring.ShardStatusRequest + (*ArbiterResponse)(nil), // 1: ring.ArbiterResponse + (*ReplicaStatus)(nil), // 2: ring.ReplicaStatus + (*ConsensusWantShardsRequest)(nil), // 3: ring.ConsensusWantShardsRequest + nil, // 4: ring.ShardStatusRequest.StatusEntry + nil, // 5: ring.ReplicaStatus.StatusEntry + (*ShardStatus)(nil), // 6: ring.ShardStatus + (*emptypb.Empty)(nil), // 7: google.protobuf.Empty +} +var file_arbiter_proto_depIdxs = []int32{ + 4, // 0: ring.ShardStatusRequest.status:type_name -> ring.ShardStatusRequest.StatusEntry + 5, // 1: ring.ReplicaStatus.status:type_name -> ring.ReplicaStatus.StatusEntry + 6, // 2: ring.ShardStatusRequest.StatusEntry.value:type_name -> ring.ShardStatus + 6, // 3: ring.ReplicaStatus.StatusEntry.value:type_name -> ring.ShardStatus + 0, // 4: ring.Arbiter.GetDesiredReplicas:input_type -> ring.ShardStatusRequest + 7, // 5: ring.ArbiterScaler.Status:input_type -> google.protobuf.Empty + 3, // 6: ring.ArbiterScaler.ConsensusWantShards:input_type -> ring.ConsensusWantShardsRequest + 1, // 7: ring.Arbiter.GetDesiredReplicas:output_type -> ring.ArbiterResponse + 2, // 8: ring.ArbiterScaler.Status:output_type -> ring.ReplicaStatus + 7, // 9: ring.ArbiterScaler.ConsensusWantShards:output_type -> google.protobuf.Empty + 7, // [7:10] is the sub-list for method output_type + 4, // [4:7] 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 +} + +func init() { file_arbiter_proto_init() } +func file_arbiter_proto_init() { + if File_arbiter_proto != nil { + return + } + file_shared_proto_init() + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_arbiter_proto_rawDesc), len(file_arbiter_proto_rawDesc)), + NumEnums: 0, + NumMessages: 6, + NumExtensions: 0, + NumServices: 2, + }, + GoTypes: file_arbiter_proto_goTypes, + DependencyIndexes: file_arbiter_proto_depIdxs, + MessageInfos: file_arbiter_proto_msgTypes, + }.Build() + File_arbiter_proto = out.File + file_arbiter_proto_goTypes = nil + file_arbiter_proto_depIdxs = nil +} diff --git a/ring/go/arbiter_grpc.pb.go b/ring/go/arbiter_grpc.pb.go new file mode 100644 index 0000000..d889409 --- /dev/null +++ b/ring/go/arbiter_grpc.pb.go @@ -0,0 +1,262 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc v5.29.3 +// source: arbiter.proto + +package ring + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + emptypb "google.golang.org/protobuf/types/known/emptypb" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + Arbiter_GetDesiredReplicas_FullMethodName = "/ring.Arbiter/GetDesiredReplicas" +) + +// ArbiterClient is the client API for Arbiter service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type ArbiterClient interface { + GetDesiredReplicas(ctx context.Context, in *ShardStatusRequest, opts ...grpc.CallOption) (*ArbiterResponse, error) +} + +type arbiterClient struct { + cc grpc.ClientConnInterface +} + +func NewArbiterClient(cc grpc.ClientConnInterface) ArbiterClient { + return &arbiterClient{cc} +} + +func (c *arbiterClient) GetDesiredReplicas(ctx context.Context, in *ShardStatusRequest, opts ...grpc.CallOption) (*ArbiterResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ArbiterResponse) + err := c.cc.Invoke(ctx, Arbiter_GetDesiredReplicas_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ArbiterServer is the server API for Arbiter service. +// All implementations must embed UnimplementedArbiterServer +// for forward compatibility. +type ArbiterServer interface { + GetDesiredReplicas(context.Context, *ShardStatusRequest) (*ArbiterResponse, error) + mustEmbedUnimplementedArbiterServer() +} + +// UnimplementedArbiterServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedArbiterServer struct{} + +func (UnimplementedArbiterServer) GetDesiredReplicas(context.Context, *ShardStatusRequest) (*ArbiterResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetDesiredReplicas not implemented") +} +func (UnimplementedArbiterServer) mustEmbedUnimplementedArbiterServer() {} +func (UnimplementedArbiterServer) testEmbeddedByValue() {} + +// UnsafeArbiterServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ArbiterServer will +// result in compilation errors. +type UnsafeArbiterServer interface { + mustEmbedUnimplementedArbiterServer() +} + +func RegisterArbiterServer(s grpc.ServiceRegistrar, srv ArbiterServer) { + // If the following call pancis, it indicates UnimplementedArbiterServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&Arbiter_ServiceDesc, srv) +} + +func _Arbiter_GetDesiredReplicas_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ShardStatusRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ArbiterServer).GetDesiredReplicas(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Arbiter_GetDesiredReplicas_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ArbiterServer).GetDesiredReplicas(ctx, req.(*ShardStatusRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Arbiter_ServiceDesc is the grpc.ServiceDesc for Arbiter service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Arbiter_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "ring.Arbiter", + HandlerType: (*ArbiterServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetDesiredReplicas", + Handler: _Arbiter_GetDesiredReplicas_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "arbiter.proto", +} + +const ( + ArbiterScaler_Status_FullMethodName = "/ring.ArbiterScaler/Status" + ArbiterScaler_ConsensusWantShards_FullMethodName = "/ring.ArbiterScaler/ConsensusWantShards" +) + +// ArbiterScalerClient is the client API for ArbiterScaler service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type ArbiterScalerClient interface { + Status(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ReplicaStatus, error) + ConsensusWantShards(ctx context.Context, in *ConsensusWantShardsRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) +} + +type arbiterScalerClient struct { + cc grpc.ClientConnInterface +} + +func NewArbiterScalerClient(cc grpc.ClientConnInterface) ArbiterScalerClient { + return &arbiterScalerClient{cc} +} + +func (c *arbiterScalerClient) Status(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ReplicaStatus, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ReplicaStatus) + err := c.cc.Invoke(ctx, ArbiterScaler_Status_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *arbiterScalerClient) ConsensusWantShards(ctx context.Context, in *ConsensusWantShardsRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, ArbiterScaler_ConsensusWantShards_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ArbiterScalerServer is the server API for ArbiterScaler service. +// All implementations must embed UnimplementedArbiterScalerServer +// for forward compatibility. +type ArbiterScalerServer interface { + Status(context.Context, *emptypb.Empty) (*ReplicaStatus, error) + ConsensusWantShards(context.Context, *ConsensusWantShardsRequest) (*emptypb.Empty, error) + mustEmbedUnimplementedArbiterScalerServer() +} + +// UnimplementedArbiterScalerServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedArbiterScalerServer struct{} + +func (UnimplementedArbiterScalerServer) Status(context.Context, *emptypb.Empty) (*ReplicaStatus, error) { + return nil, status.Errorf(codes.Unimplemented, "method Status not implemented") +} +func (UnimplementedArbiterScalerServer) ConsensusWantShards(context.Context, *ConsensusWantShardsRequest) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method ConsensusWantShards not implemented") +} +func (UnimplementedArbiterScalerServer) mustEmbedUnimplementedArbiterScalerServer() {} +func (UnimplementedArbiterScalerServer) testEmbeddedByValue() {} + +// UnsafeArbiterScalerServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ArbiterScalerServer will +// result in compilation errors. +type UnsafeArbiterScalerServer interface { + mustEmbedUnimplementedArbiterScalerServer() +} + +func RegisterArbiterScalerServer(s grpc.ServiceRegistrar, srv ArbiterScalerServer) { + // If the following call pancis, it indicates UnimplementedArbiterScalerServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&ArbiterScaler_ServiceDesc, srv) +} + +func _ArbiterScaler_Status_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(emptypb.Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ArbiterScalerServer).Status(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ArbiterScaler_Status_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ArbiterScalerServer).Status(ctx, req.(*emptypb.Empty)) + } + return interceptor(ctx, in, info, handler) +} + +func _ArbiterScaler_ConsensusWantShards_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ConsensusWantShardsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ArbiterScalerServer).ConsensusWantShards(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ArbiterScaler_ConsensusWantShards_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ArbiterScalerServer).ConsensusWantShards(ctx, req.(*ConsensusWantShardsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// ArbiterScaler_ServiceDesc is the grpc.ServiceDesc for ArbiterScaler service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var ArbiterScaler_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "ring.ArbiterScaler", + HandlerType: (*ArbiterScalerServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Status", + Handler: _ArbiterScaler_Status_Handler, + }, + { + MethodName: "ConsensusWantShards", + Handler: _ArbiterScaler_ConsensusWantShards_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "arbiter.proto", +} diff --git a/ring/go/consensus.pb.go b/ring/go/consensus.pb.go new file mode 100644 index 0000000..133dd41 --- /dev/null +++ b/ring/go/consensus.pb.go @@ -0,0 +1,442 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc v5.29.3 +// source: consensus.proto + +package ring + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Observation struct { + state protoimpl.MessageState `protogen:"open.v1"` + ShardStatus map[uint32]*ShardStatus `protobuf:"bytes,1,rep,name=shard_status,json=shardStatus,proto3" json:"shard_status,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // shard_id -> status + WorkflowIds []string `protobuf:"bytes,2,rep,name=workflow_ids,json=workflowIds,proto3" json:"workflow_ids,omitempty"` + Now *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=now,proto3" json:"now,omitempty"` + WantShards uint32 `protobuf:"varint,4,opt,name=want_shards,json=wantShards,proto3" json:"want_shards,omitempty"` // from ArbiterScaler.Status() + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Observation) Reset() { + *x = Observation{} + mi := &file_consensus_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Observation) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Observation) ProtoMessage() {} + +func (x *Observation) ProtoReflect() protoreflect.Message { + mi := &file_consensus_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Observation.ProtoReflect.Descriptor instead. +func (*Observation) Descriptor() ([]byte, []int) { + return file_consensus_proto_rawDescGZIP(), []int{0} +} + +func (x *Observation) GetShardStatus() map[uint32]*ShardStatus { + if x != nil { + return x.ShardStatus + } + return nil +} + +func (x *Observation) GetWorkflowIds() []string { + if x != nil { + return x.WorkflowIds + } + return nil +} + +func (x *Observation) GetNow() *timestamppb.Timestamp { + if x != nil { + return x.Now + } + return nil +} + +func (x *Observation) GetWantShards() uint32 { + if x != nil { + return x.WantShards + } + return 0 +} + +type WorkflowRoute struct { + state protoimpl.MessageState `protogen:"open.v1"` + Shard uint32 `protobuf:"varint,1,opt,name=shard,proto3" json:"shard,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *WorkflowRoute) Reset() { + *x = WorkflowRoute{} + mi := &file_consensus_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *WorkflowRoute) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WorkflowRoute) ProtoMessage() {} + +func (x *WorkflowRoute) ProtoReflect() protoreflect.Message { + mi := &file_consensus_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use WorkflowRoute.ProtoReflect.Descriptor instead. +func (*WorkflowRoute) Descriptor() ([]byte, []int) { + return file_consensus_proto_rawDescGZIP(), []int{1} +} + +func (x *WorkflowRoute) GetShard() uint32 { + if x != nil { + return x.Shard + } + return 0 +} + +type Transition struct { + state protoimpl.MessageState `protogen:"open.v1"` + WantShards uint32 `protobuf:"varint,1,opt,name=want_shards,json=wantShards,proto3" json:"want_shards,omitempty"` + LastStableCount uint32 `protobuf:"varint,2,opt,name=last_stable_count,json=lastStableCount,proto3" json:"last_stable_count,omitempty"` + ChangesSafeAfter *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=changes_safe_after,json=changesSafeAfter,proto3" json:"changes_safe_after,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Transition) Reset() { + *x = Transition{} + mi := &file_consensus_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Transition) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Transition) ProtoMessage() {} + +func (x *Transition) ProtoReflect() protoreflect.Message { + mi := &file_consensus_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Transition.ProtoReflect.Descriptor instead. +func (*Transition) Descriptor() ([]byte, []int) { + return file_consensus_proto_rawDescGZIP(), []int{2} +} + +func (x *Transition) GetWantShards() uint32 { + if x != nil { + return x.WantShards + } + return 0 +} + +func (x *Transition) GetLastStableCount() uint32 { + if x != nil { + return x.LastStableCount + } + return 0 +} + +func (x *Transition) GetChangesSafeAfter() *timestamppb.Timestamp { + if x != nil { + return x.ChangesSafeAfter + } + return nil +} + +type RoutingState struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // Types that are valid to be assigned to State: + // + // *RoutingState_Transition + // *RoutingState_RoutableShards + State isRoutingState_State `protobuf_oneof:"state"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RoutingState) Reset() { + *x = RoutingState{} + mi := &file_consensus_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RoutingState) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RoutingState) ProtoMessage() {} + +func (x *RoutingState) ProtoReflect() protoreflect.Message { + mi := &file_consensus_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RoutingState.ProtoReflect.Descriptor instead. +func (*RoutingState) Descriptor() ([]byte, []int) { + return file_consensus_proto_rawDescGZIP(), []int{3} +} + +func (x *RoutingState) GetId() uint64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *RoutingState) GetState() isRoutingState_State { + if x != nil { + return x.State + } + return nil +} + +func (x *RoutingState) GetTransition() *Transition { + if x != nil { + if x, ok := x.State.(*RoutingState_Transition); ok { + return x.Transition + } + } + return nil +} + +func (x *RoutingState) GetRoutableShards() uint32 { + if x != nil { + if x, ok := x.State.(*RoutingState_RoutableShards); ok { + return x.RoutableShards + } + } + return 0 +} + +type isRoutingState_State interface { + isRoutingState_State() +} + +type RoutingState_Transition struct { + Transition *Transition `protobuf:"bytes,2,opt,name=transition,proto3,oneof"` +} + +type RoutingState_RoutableShards struct { + RoutableShards uint32 `protobuf:"varint,3,opt,name=routable_shards,json=routableShards,proto3,oneof"` +} + +func (*RoutingState_Transition) isRoutingState_State() {} + +func (*RoutingState_RoutableShards) isRoutingState_State() {} + +type Outcome struct { + state protoimpl.MessageState `protogen:"open.v1"` + State *RoutingState `protobuf:"bytes,1,opt,name=state,proto3" json:"state,omitempty"` // used internally for ring plugin + Routes map[string]*WorkflowRoute `protobuf:"bytes,2,rep,name=routes,proto3" json:"routes,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // used by consumers to route requests to the appropriate shard + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Outcome) Reset() { + *x = Outcome{} + mi := &file_consensus_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Outcome) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Outcome) ProtoMessage() {} + +func (x *Outcome) ProtoReflect() protoreflect.Message { + mi := &file_consensus_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Outcome.ProtoReflect.Descriptor instead. +func (*Outcome) Descriptor() ([]byte, []int) { + return file_consensus_proto_rawDescGZIP(), []int{4} +} + +func (x *Outcome) GetState() *RoutingState { + if x != nil { + return x.State + } + return nil +} + +func (x *Outcome) GetRoutes() map[string]*WorkflowRoute { + if x != nil { + return x.Routes + } + return nil +} + +var File_consensus_proto protoreflect.FileDescriptor + +const file_consensus_proto_rawDesc = "" + + "\n" + + "\x0fconsensus.proto\x12\x04ring\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\fshared.proto\"\x99\x02\n" + + "\vObservation\x12E\n" + + "\fshard_status\x18\x01 \x03(\v2\".ring.Observation.ShardStatusEntryR\vshardStatus\x12!\n" + + "\fworkflow_ids\x18\x02 \x03(\tR\vworkflowIds\x12,\n" + + "\x03now\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\x03now\x12\x1f\n" + + "\vwant_shards\x18\x04 \x01(\rR\n" + + "wantShards\x1aQ\n" + + "\x10ShardStatusEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\rR\x03key\x12'\n" + + "\x05value\x18\x02 \x01(\v2\x11.ring.ShardStatusR\x05value:\x028\x01\"%\n" + + "\rWorkflowRoute\x12\x14\n" + + "\x05shard\x18\x01 \x01(\rR\x05shard\"\xa3\x01\n" + + "\n" + + "Transition\x12\x1f\n" + + "\vwant_shards\x18\x01 \x01(\rR\n" + + "wantShards\x12*\n" + + "\x11last_stable_count\x18\x02 \x01(\rR\x0flastStableCount\x12H\n" + + "\x12changes_safe_after\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\x10changesSafeAfter\"\x86\x01\n" + + "\fRoutingState\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x04R\x02id\x122\n" + + "\n" + + "transition\x18\x02 \x01(\v2\x10.ring.TransitionH\x00R\n" + + "transition\x12)\n" + + "\x0froutable_shards\x18\x03 \x01(\rH\x00R\x0eroutableShardsB\a\n" + + "\x05state\"\xb6\x01\n" + + "\aOutcome\x12(\n" + + "\x05state\x18\x01 \x01(\v2\x12.ring.RoutingStateR\x05state\x121\n" + + "\x06routes\x18\x02 \x03(\v2\x19.ring.Outcome.RoutesEntryR\x06routes\x1aN\n" + + "\vRoutesEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12)\n" + + "\x05value\x18\x02 \x01(\v2\x13.ring.WorkflowRouteR\x05value:\x028\x01B;Z9github.com/smartcontractkit/chainlink-protos/ring/go;ringb\x06proto3" + +var ( + file_consensus_proto_rawDescOnce sync.Once + file_consensus_proto_rawDescData []byte +) + +func file_consensus_proto_rawDescGZIP() []byte { + file_consensus_proto_rawDescOnce.Do(func() { + file_consensus_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_consensus_proto_rawDesc), len(file_consensus_proto_rawDesc))) + }) + return file_consensus_proto_rawDescData +} + +var file_consensus_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_consensus_proto_goTypes = []any{ + (*Observation)(nil), // 0: ring.Observation + (*WorkflowRoute)(nil), // 1: ring.WorkflowRoute + (*Transition)(nil), // 2: ring.Transition + (*RoutingState)(nil), // 3: ring.RoutingState + (*Outcome)(nil), // 4: ring.Outcome + nil, // 5: ring.Observation.ShardStatusEntry + nil, // 6: ring.Outcome.RoutesEntry + (*timestamppb.Timestamp)(nil), // 7: google.protobuf.Timestamp + (*ShardStatus)(nil), // 8: ring.ShardStatus +} +var file_consensus_proto_depIdxs = []int32{ + 5, // 0: ring.Observation.shard_status:type_name -> ring.Observation.ShardStatusEntry + 7, // 1: ring.Observation.now:type_name -> google.protobuf.Timestamp + 7, // 2: ring.Transition.changes_safe_after:type_name -> google.protobuf.Timestamp + 2, // 3: ring.RoutingState.transition:type_name -> ring.Transition + 3, // 4: ring.Outcome.state:type_name -> ring.RoutingState + 6, // 5: ring.Outcome.routes:type_name -> ring.Outcome.RoutesEntry + 8, // 6: ring.Observation.ShardStatusEntry.value:type_name -> ring.ShardStatus + 1, // 7: ring.Outcome.RoutesEntry.value:type_name -> ring.WorkflowRoute + 8, // [8:8] is the sub-list for method output_type + 8, // [8:8] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name +} + +func init() { file_consensus_proto_init() } +func file_consensus_proto_init() { + if File_consensus_proto != nil { + return + } + file_shared_proto_init() + file_consensus_proto_msgTypes[3].OneofWrappers = []any{ + (*RoutingState_Transition)(nil), + (*RoutingState_RoutableShards)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_consensus_proto_rawDesc), len(file_consensus_proto_rawDesc)), + NumEnums: 0, + NumMessages: 7, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_consensus_proto_goTypes, + DependencyIndexes: file_consensus_proto_depIdxs, + MessageInfos: file_consensus_proto_msgTypes, + }.Build() + File_consensus_proto = out.File + file_consensus_proto_goTypes = nil + file_consensus_proto_depIdxs = nil +} diff --git a/ring/go/generate.go b/ring/go/generate.go new file mode 100644 index 0000000..9d21569 --- /dev/null +++ b/ring/go/generate.go @@ -0,0 +1,3 @@ +package ring + +//go:generate protoc --proto_path=../pb --go_out=./ --go_opt=module=github.com/smartcontractkit/chainlink-protos/ring/go --go-grpc_out=./ --go-grpc_opt=module=github.com/smartcontractkit/chainlink-protos/ring/go ../pb/shared.proto ../pb/arbiter.proto ../pb/consensus.proto ../pb/shard_orchestrator.proto diff --git a/ring/go/go.mod b/ring/go/go.mod new file mode 100644 index 0000000..2aefb6b --- /dev/null +++ b/ring/go/go.mod @@ -0,0 +1,15 @@ +module github.com/smartcontractkit/chainlink-protos/ring/go + +go 1.24.5 + +require ( + google.golang.org/grpc v1.72.0 + google.golang.org/protobuf v1.36.6 +) + +require ( + golang.org/x/net v0.35.0 // indirect + golang.org/x/sys v0.30.0 // indirect + golang.org/x/text v0.22.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a // indirect +) diff --git a/ring/go/go.sum b/ring/go/go.sum new file mode 100644 index 0000000..35bd6a7 --- /dev/null +++ b/ring/go/go.sum @@ -0,0 +1,34 @@ +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= +go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= +go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY= +go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI= +go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ= +go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE= +go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A= +go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU= +go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk= +go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w= +go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k= +go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE= +golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8= +golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk= +golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= +golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= +golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a h1:51aaUVRocpvUOSQKM6Q7VuoaktNIaMCLuhZB6DKksq4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a/go.mod h1:uRxBH1mhmO8PGhU89cMcHaXKZqO+OfakD8QQO0oYwlQ= +google.golang.org/grpc v1.72.0 h1:S7UkcVa60b5AAQTaO6ZKamFp1zMZSU0fGDK2WZLbBnM= +google.golang.org/grpc v1.72.0/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= +google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= +google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= diff --git a/ring/go/shard_orchestrator.pb.go b/ring/go/shard_orchestrator.pb.go new file mode 100644 index 0000000..2ebdf25 --- /dev/null +++ b/ring/go/shard_orchestrator.pb.go @@ -0,0 +1,389 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc v5.29.3 +// source: shard_orchestrator.proto + +package ring + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type GetWorkflowShardMappingRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + WorkflowIds []string `protobuf:"bytes,1,rep,name=workflow_ids,json=workflowIds,proto3" json:"workflow_ids,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetWorkflowShardMappingRequest) Reset() { + *x = GetWorkflowShardMappingRequest{} + mi := &file_shard_orchestrator_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetWorkflowShardMappingRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetWorkflowShardMappingRequest) ProtoMessage() {} + +func (x *GetWorkflowShardMappingRequest) ProtoReflect() protoreflect.Message { + mi := &file_shard_orchestrator_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetWorkflowShardMappingRequest.ProtoReflect.Descriptor instead. +func (*GetWorkflowShardMappingRequest) Descriptor() ([]byte, []int) { + return file_shard_orchestrator_proto_rawDescGZIP(), []int{0} +} + +func (x *GetWorkflowShardMappingRequest) GetWorkflowIds() []string { + if x != nil { + return x.WorkflowIds + } + return nil +} + +type WorkflowMappingState struct { + state protoimpl.MessageState `protogen:"open.v1"` + OldShardId uint32 `protobuf:"varint,1,opt,name=old_shard_id,json=oldShardId,proto3" json:"old_shard_id,omitempty"` + NewShardId uint32 `protobuf:"varint,2,opt,name=new_shard_id,json=newShardId,proto3" json:"new_shard_id,omitempty"` + InTransition bool `protobuf:"varint,3,opt,name=in_transition,json=inTransition,proto3" json:"in_transition,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *WorkflowMappingState) Reset() { + *x = WorkflowMappingState{} + mi := &file_shard_orchestrator_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *WorkflowMappingState) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WorkflowMappingState) ProtoMessage() {} + +func (x *WorkflowMappingState) ProtoReflect() protoreflect.Message { + mi := &file_shard_orchestrator_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use WorkflowMappingState.ProtoReflect.Descriptor instead. +func (*WorkflowMappingState) Descriptor() ([]byte, []int) { + return file_shard_orchestrator_proto_rawDescGZIP(), []int{1} +} + +func (x *WorkflowMappingState) GetOldShardId() uint32 { + if x != nil { + return x.OldShardId + } + return 0 +} + +func (x *WorkflowMappingState) GetNewShardId() uint32 { + if x != nil { + return x.NewShardId + } + return 0 +} + +func (x *WorkflowMappingState) GetInTransition() bool { + if x != nil { + return x.InTransition + } + return false +} + +type GetWorkflowShardMappingResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Mappings map[string]uint32 `protobuf:"bytes,1,rep,name=mappings,proto3" json:"mappings,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"` + MappingStates map[string]*WorkflowMappingState `protobuf:"bytes,2,rep,name=mapping_states,json=mappingStates,proto3" json:"mapping_states,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + MappingVersion uint64 `protobuf:"varint,3,opt,name=mapping_version,json=mappingVersion,proto3" json:"mapping_version,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetWorkflowShardMappingResponse) Reset() { + *x = GetWorkflowShardMappingResponse{} + mi := &file_shard_orchestrator_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetWorkflowShardMappingResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetWorkflowShardMappingResponse) ProtoMessage() {} + +func (x *GetWorkflowShardMappingResponse) ProtoReflect() protoreflect.Message { + mi := &file_shard_orchestrator_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetWorkflowShardMappingResponse.ProtoReflect.Descriptor instead. +func (*GetWorkflowShardMappingResponse) Descriptor() ([]byte, []int) { + return file_shard_orchestrator_proto_rawDescGZIP(), []int{2} +} + +func (x *GetWorkflowShardMappingResponse) GetMappings() map[string]uint32 { + if x != nil { + return x.Mappings + } + return nil +} + +func (x *GetWorkflowShardMappingResponse) GetMappingStates() map[string]*WorkflowMappingState { + if x != nil { + return x.MappingStates + } + return nil +} + +func (x *GetWorkflowShardMappingResponse) GetMappingVersion() uint64 { + if x != nil { + return x.MappingVersion + } + return 0 +} + +type ReportWorkflowTriggerRegistrationRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + SourceShardId uint32 `protobuf:"varint,1,opt,name=source_shard_id,json=sourceShardId,proto3" json:"source_shard_id,omitempty"` + RegisteredWorkflows map[string]uint32 `protobuf:"bytes,2,rep,name=registered_workflows,json=registeredWorkflows,proto3" json:"registered_workflows,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"` + TotalActiveWorkflows uint32 `protobuf:"varint,3,opt,name=total_active_workflows,json=totalActiveWorkflows,proto3" json:"total_active_workflows,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ReportWorkflowTriggerRegistrationRequest) Reset() { + *x = ReportWorkflowTriggerRegistrationRequest{} + mi := &file_shard_orchestrator_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ReportWorkflowTriggerRegistrationRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReportWorkflowTriggerRegistrationRequest) ProtoMessage() {} + +func (x *ReportWorkflowTriggerRegistrationRequest) ProtoReflect() protoreflect.Message { + mi := &file_shard_orchestrator_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReportWorkflowTriggerRegistrationRequest.ProtoReflect.Descriptor instead. +func (*ReportWorkflowTriggerRegistrationRequest) Descriptor() ([]byte, []int) { + return file_shard_orchestrator_proto_rawDescGZIP(), []int{3} +} + +func (x *ReportWorkflowTriggerRegistrationRequest) GetSourceShardId() uint32 { + if x != nil { + return x.SourceShardId + } + return 0 +} + +func (x *ReportWorkflowTriggerRegistrationRequest) GetRegisteredWorkflows() map[string]uint32 { + if x != nil { + return x.RegisteredWorkflows + } + return nil +} + +func (x *ReportWorkflowTriggerRegistrationRequest) GetTotalActiveWorkflows() uint32 { + if x != nil { + return x.TotalActiveWorkflows + } + return 0 +} + +type ReportWorkflowTriggerRegistrationResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ReportWorkflowTriggerRegistrationResponse) Reset() { + *x = ReportWorkflowTriggerRegistrationResponse{} + mi := &file_shard_orchestrator_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ReportWorkflowTriggerRegistrationResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReportWorkflowTriggerRegistrationResponse) ProtoMessage() {} + +func (x *ReportWorkflowTriggerRegistrationResponse) ProtoReflect() protoreflect.Message { + mi := &file_shard_orchestrator_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReportWorkflowTriggerRegistrationResponse.ProtoReflect.Descriptor instead. +func (*ReportWorkflowTriggerRegistrationResponse) Descriptor() ([]byte, []int) { + return file_shard_orchestrator_proto_rawDescGZIP(), []int{4} +} + +func (x *ReportWorkflowTriggerRegistrationResponse) GetSuccess() bool { + if x != nil { + return x.Success + } + return false +} + +var File_shard_orchestrator_proto protoreflect.FileDescriptor + +const file_shard_orchestrator_proto_rawDesc = "" + + "\n" + + "\x18shard_orchestrator.proto\x12\x04ring\"C\n" + + "\x1eGetWorkflowShardMappingRequest\x12!\n" + + "\fworkflow_ids\x18\x01 \x03(\tR\vworkflowIds\"\x7f\n" + + "\x14WorkflowMappingState\x12 \n" + + "\fold_shard_id\x18\x01 \x01(\rR\n" + + "oldShardId\x12 \n" + + "\fnew_shard_id\x18\x02 \x01(\rR\n" + + "newShardId\x12#\n" + + "\rin_transition\x18\x03 \x01(\bR\finTransition\"\x97\x03\n" + + "\x1fGetWorkflowShardMappingResponse\x12O\n" + + "\bmappings\x18\x01 \x03(\v23.ring.GetWorkflowShardMappingResponse.MappingsEntryR\bmappings\x12_\n" + + "\x0emapping_states\x18\x02 \x03(\v28.ring.GetWorkflowShardMappingResponse.MappingStatesEntryR\rmappingStates\x12'\n" + + "\x0fmapping_version\x18\x03 \x01(\x04R\x0emappingVersion\x1a;\n" + + "\rMappingsEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\rR\x05value:\x028\x01\x1a\\\n" + + "\x12MappingStatesEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x120\n" + + "\x05value\x18\x02 \x01(\v2\x1a.ring.WorkflowMappingStateR\x05value:\x028\x01\"\xcc\x02\n" + + "(ReportWorkflowTriggerRegistrationRequest\x12&\n" + + "\x0fsource_shard_id\x18\x01 \x01(\rR\rsourceShardId\x12z\n" + + "\x14registered_workflows\x18\x02 \x03(\v2G.ring.ReportWorkflowTriggerRegistrationRequest.RegisteredWorkflowsEntryR\x13registeredWorkflows\x124\n" + + "\x16total_active_workflows\x18\x03 \x01(\rR\x14totalActiveWorkflows\x1aF\n" + + "\x18RegisteredWorkflowsEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\rR\x05value:\x028\x01\"E\n" + + ")ReportWorkflowTriggerRegistrationResponse\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess2\x89\x02\n" + + "\x18ShardOrchestratorService\x12f\n" + + "\x17GetWorkflowShardMapping\x12$.ring.GetWorkflowShardMappingRequest\x1a%.ring.GetWorkflowShardMappingResponse\x12\x84\x01\n" + + "!ReportWorkflowTriggerRegistration\x12..ring.ReportWorkflowTriggerRegistrationRequest\x1a/.ring.ReportWorkflowTriggerRegistrationResponseB;Z9github.com/smartcontractkit/chainlink-protos/ring/go;ringb\x06proto3" + +var ( + file_shard_orchestrator_proto_rawDescOnce sync.Once + file_shard_orchestrator_proto_rawDescData []byte +) + +func file_shard_orchestrator_proto_rawDescGZIP() []byte { + file_shard_orchestrator_proto_rawDescOnce.Do(func() { + file_shard_orchestrator_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_shard_orchestrator_proto_rawDesc), len(file_shard_orchestrator_proto_rawDesc))) + }) + return file_shard_orchestrator_proto_rawDescData +} + +var file_shard_orchestrator_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_shard_orchestrator_proto_goTypes = []any{ + (*GetWorkflowShardMappingRequest)(nil), // 0: ring.GetWorkflowShardMappingRequest + (*WorkflowMappingState)(nil), // 1: ring.WorkflowMappingState + (*GetWorkflowShardMappingResponse)(nil), // 2: ring.GetWorkflowShardMappingResponse + (*ReportWorkflowTriggerRegistrationRequest)(nil), // 3: ring.ReportWorkflowTriggerRegistrationRequest + (*ReportWorkflowTriggerRegistrationResponse)(nil), // 4: ring.ReportWorkflowTriggerRegistrationResponse + nil, // 5: ring.GetWorkflowShardMappingResponse.MappingsEntry + nil, // 6: ring.GetWorkflowShardMappingResponse.MappingStatesEntry + nil, // 7: ring.ReportWorkflowTriggerRegistrationRequest.RegisteredWorkflowsEntry +} +var file_shard_orchestrator_proto_depIdxs = []int32{ + 5, // 0: ring.GetWorkflowShardMappingResponse.mappings:type_name -> ring.GetWorkflowShardMappingResponse.MappingsEntry + 6, // 1: ring.GetWorkflowShardMappingResponse.mapping_states:type_name -> ring.GetWorkflowShardMappingResponse.MappingStatesEntry + 7, // 2: ring.ReportWorkflowTriggerRegistrationRequest.registered_workflows:type_name -> ring.ReportWorkflowTriggerRegistrationRequest.RegisteredWorkflowsEntry + 1, // 3: ring.GetWorkflowShardMappingResponse.MappingStatesEntry.value:type_name -> ring.WorkflowMappingState + 0, // 4: ring.ShardOrchestratorService.GetWorkflowShardMapping:input_type -> ring.GetWorkflowShardMappingRequest + 3, // 5: ring.ShardOrchestratorService.ReportWorkflowTriggerRegistration:input_type -> ring.ReportWorkflowTriggerRegistrationRequest + 2, // 6: ring.ShardOrchestratorService.GetWorkflowShardMapping:output_type -> ring.GetWorkflowShardMappingResponse + 4, // 7: ring.ShardOrchestratorService.ReportWorkflowTriggerRegistration:output_type -> ring.ReportWorkflowTriggerRegistrationResponse + 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 +} + +func init() { file_shard_orchestrator_proto_init() } +func file_shard_orchestrator_proto_init() { + if File_shard_orchestrator_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_shard_orchestrator_proto_rawDesc), len(file_shard_orchestrator_proto_rawDesc)), + NumEnums: 0, + NumMessages: 8, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_shard_orchestrator_proto_goTypes, + DependencyIndexes: file_shard_orchestrator_proto_depIdxs, + MessageInfos: file_shard_orchestrator_proto_msgTypes, + }.Build() + File_shard_orchestrator_proto = out.File + file_shard_orchestrator_proto_goTypes = nil + file_shard_orchestrator_proto_depIdxs = nil +} diff --git a/ring/go/shard_orchestrator_grpc.pb.go b/ring/go/shard_orchestrator_grpc.pb.go new file mode 100644 index 0000000..5ef86d7 --- /dev/null +++ b/ring/go/shard_orchestrator_grpc.pb.go @@ -0,0 +1,160 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc v5.29.3 +// source: shard_orchestrator.proto + +package ring + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + ShardOrchestratorService_GetWorkflowShardMapping_FullMethodName = "/ring.ShardOrchestratorService/GetWorkflowShardMapping" + ShardOrchestratorService_ReportWorkflowTriggerRegistration_FullMethodName = "/ring.ShardOrchestratorService/ReportWorkflowTriggerRegistration" +) + +// ShardOrchestratorServiceClient is the client API for ShardOrchestratorService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type ShardOrchestratorServiceClient interface { + GetWorkflowShardMapping(ctx context.Context, in *GetWorkflowShardMappingRequest, opts ...grpc.CallOption) (*GetWorkflowShardMappingResponse, error) + ReportWorkflowTriggerRegistration(ctx context.Context, in *ReportWorkflowTriggerRegistrationRequest, opts ...grpc.CallOption) (*ReportWorkflowTriggerRegistrationResponse, error) +} + +type shardOrchestratorServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewShardOrchestratorServiceClient(cc grpc.ClientConnInterface) ShardOrchestratorServiceClient { + return &shardOrchestratorServiceClient{cc} +} + +func (c *shardOrchestratorServiceClient) GetWorkflowShardMapping(ctx context.Context, in *GetWorkflowShardMappingRequest, opts ...grpc.CallOption) (*GetWorkflowShardMappingResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetWorkflowShardMappingResponse) + err := c.cc.Invoke(ctx, ShardOrchestratorService_GetWorkflowShardMapping_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *shardOrchestratorServiceClient) ReportWorkflowTriggerRegistration(ctx context.Context, in *ReportWorkflowTriggerRegistrationRequest, opts ...grpc.CallOption) (*ReportWorkflowTriggerRegistrationResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ReportWorkflowTriggerRegistrationResponse) + err := c.cc.Invoke(ctx, ShardOrchestratorService_ReportWorkflowTriggerRegistration_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ShardOrchestratorServiceServer is the server API for ShardOrchestratorService service. +// All implementations must embed UnimplementedShardOrchestratorServiceServer +// for forward compatibility. +type ShardOrchestratorServiceServer interface { + GetWorkflowShardMapping(context.Context, *GetWorkflowShardMappingRequest) (*GetWorkflowShardMappingResponse, error) + ReportWorkflowTriggerRegistration(context.Context, *ReportWorkflowTriggerRegistrationRequest) (*ReportWorkflowTriggerRegistrationResponse, error) + mustEmbedUnimplementedShardOrchestratorServiceServer() +} + +// UnimplementedShardOrchestratorServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedShardOrchestratorServiceServer struct{} + +func (UnimplementedShardOrchestratorServiceServer) GetWorkflowShardMapping(context.Context, *GetWorkflowShardMappingRequest) (*GetWorkflowShardMappingResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetWorkflowShardMapping not implemented") +} +func (UnimplementedShardOrchestratorServiceServer) ReportWorkflowTriggerRegistration(context.Context, *ReportWorkflowTriggerRegistrationRequest) (*ReportWorkflowTriggerRegistrationResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ReportWorkflowTriggerRegistration not implemented") +} +func (UnimplementedShardOrchestratorServiceServer) mustEmbedUnimplementedShardOrchestratorServiceServer() { +} +func (UnimplementedShardOrchestratorServiceServer) testEmbeddedByValue() {} + +// UnsafeShardOrchestratorServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ShardOrchestratorServiceServer will +// result in compilation errors. +type UnsafeShardOrchestratorServiceServer interface { + mustEmbedUnimplementedShardOrchestratorServiceServer() +} + +func RegisterShardOrchestratorServiceServer(s grpc.ServiceRegistrar, srv ShardOrchestratorServiceServer) { + // If the following call pancis, it indicates UnimplementedShardOrchestratorServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&ShardOrchestratorService_ServiceDesc, srv) +} + +func _ShardOrchestratorService_GetWorkflowShardMapping_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetWorkflowShardMappingRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ShardOrchestratorServiceServer).GetWorkflowShardMapping(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ShardOrchestratorService_GetWorkflowShardMapping_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ShardOrchestratorServiceServer).GetWorkflowShardMapping(ctx, req.(*GetWorkflowShardMappingRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ShardOrchestratorService_ReportWorkflowTriggerRegistration_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ReportWorkflowTriggerRegistrationRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ShardOrchestratorServiceServer).ReportWorkflowTriggerRegistration(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ShardOrchestratorService_ReportWorkflowTriggerRegistration_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ShardOrchestratorServiceServer).ReportWorkflowTriggerRegistration(ctx, req.(*ReportWorkflowTriggerRegistrationRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// ShardOrchestratorService_ServiceDesc is the grpc.ServiceDesc for ShardOrchestratorService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var ShardOrchestratorService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "ring.ShardOrchestratorService", + HandlerType: (*ShardOrchestratorServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetWorkflowShardMapping", + Handler: _ShardOrchestratorService_GetWorkflowShardMapping_Handler, + }, + { + MethodName: "ReportWorkflowTriggerRegistration", + Handler: _ShardOrchestratorService_ReportWorkflowTriggerRegistration_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "shard_orchestrator.proto", +} diff --git a/ring/go/shared.pb.go b/ring/go/shared.pb.go new file mode 100644 index 0000000..ea05141 --- /dev/null +++ b/ring/go/shared.pb.go @@ -0,0 +1,123 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc v5.29.3 +// source: shared.proto + +package ring + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ShardStatus struct { + state protoimpl.MessageState `protogen:"open.v1"` + IsHealthy bool `protobuf:"varint,1,opt,name=is_healthy,json=isHealthy,proto3" json:"is_healthy,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ShardStatus) Reset() { + *x = ShardStatus{} + mi := &file_shared_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ShardStatus) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ShardStatus) ProtoMessage() {} + +func (x *ShardStatus) ProtoReflect() protoreflect.Message { + mi := &file_shared_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ShardStatus.ProtoReflect.Descriptor instead. +func (*ShardStatus) Descriptor() ([]byte, []int) { + return file_shared_proto_rawDescGZIP(), []int{0} +} + +func (x *ShardStatus) GetIsHealthy() bool { + if x != nil { + return x.IsHealthy + } + return false +} + +var File_shared_proto protoreflect.FileDescriptor + +const file_shared_proto_rawDesc = "" + + "\n" + + "\fshared.proto\x12\x04ring\",\n" + + "\vShardStatus\x12\x1d\n" + + "\n" + + "is_healthy\x18\x01 \x01(\bR\tisHealthyB;Z9github.com/smartcontractkit/chainlink-protos/ring/go;ringb\x06proto3" + +var ( + file_shared_proto_rawDescOnce sync.Once + file_shared_proto_rawDescData []byte +) + +func file_shared_proto_rawDescGZIP() []byte { + file_shared_proto_rawDescOnce.Do(func() { + file_shared_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_shared_proto_rawDesc), len(file_shared_proto_rawDesc))) + }) + return file_shared_proto_rawDescData +} + +var file_shared_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_shared_proto_goTypes = []any{ + (*ShardStatus)(nil), // 0: ring.ShardStatus +} +var file_shared_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_shared_proto_init() } +func file_shared_proto_init() { + if File_shared_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_shared_proto_rawDesc), len(file_shared_proto_rawDesc)), + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_shared_proto_goTypes, + DependencyIndexes: file_shared_proto_depIdxs, + MessageInfos: file_shared_proto_msgTypes, + }.Build() + File_shared_proto = out.File + file_shared_proto_goTypes = nil + file_shared_proto_depIdxs = nil +} diff --git a/ring/pb/arbiter.proto b/ring/pb/arbiter.proto new file mode 100644 index 0000000..e7b89ae --- /dev/null +++ b/ring/pb/arbiter.proto @@ -0,0 +1,34 @@ +syntax = "proto3"; + +package ring; + +import "google/protobuf/empty.proto"; +import "shared.proto"; + +option go_package = "github.com/smartcontractkit/chainlink-protos/ring/go;ring"; + +message ShardStatusRequest { + map status = 1; // shard_id -> status +} + +message ArbiterResponse { + uint32 want_shards = 1; +} + +service Arbiter { + rpc GetDesiredReplicas(ShardStatusRequest) returns (ArbiterResponse); // called periodically by Scaler +} + +message ReplicaStatus { + uint32 want_shards = 1; + map status = 2; +} + +message ConsensusWantShardsRequest { + uint32 n_shards = 1; +} + +service ArbiterScaler { + rpc Status(google.protobuf.Empty) returns (ReplicaStatus); // called to collect current status of shards by Ring plugin + rpc ConsensusWantShards(ConsensusWantShardsRequest) returns (google.protobuf.Empty); // called at the end of the round with consensus shard count by Ring plugin +} diff --git a/ring/pb/consensus.proto b/ring/pb/consensus.proto new file mode 100644 index 0000000..3afe12b --- /dev/null +++ b/ring/pb/consensus.proto @@ -0,0 +1,38 @@ +syntax = "proto3"; + +package ring; + +import "google/protobuf/timestamp.proto"; +import "shared.proto"; + +option go_package = "github.com/smartcontractkit/chainlink-protos/ring/go;ring"; + +message Observation { + map shard_status = 1; // shard_id -> status + repeated string workflow_ids = 2; + google.protobuf.Timestamp now = 3; + uint32 want_shards = 4; // from ArbiterScaler.Status() +} + +message WorkflowRoute { + uint32 shard = 1; +} + +message Transition { + uint32 want_shards = 1; + uint32 last_stable_count = 2; + google.protobuf.Timestamp changes_safe_after = 3; +} + +message RoutingState { + uint64 id = 1; + oneof state { + Transition transition = 2; + uint32 routable_shards = 3; + } +} + +message Outcome { + RoutingState state = 1; // used internally for ring plugin + map routes = 2; // used by consumers to route requests to the appropriate shard +} diff --git a/ring/pb/shard_orchestrator.proto b/ring/pb/shard_orchestrator.proto new file mode 100644 index 0000000..87932d1 --- /dev/null +++ b/ring/pb/shard_orchestrator.proto @@ -0,0 +1,36 @@ +syntax = "proto3"; + +package ring; + +option go_package = "github.com/smartcontractkit/chainlink-protos/ring/go;ring"; + +message GetWorkflowShardMappingRequest { + repeated string workflow_ids = 1; +} + +message WorkflowMappingState { + uint32 old_shard_id = 1; + uint32 new_shard_id = 2; + bool in_transition = 3; +} + +message GetWorkflowShardMappingResponse { + map mappings = 1; + map mapping_states = 2; + uint64 mapping_version = 3; +} + +message ReportWorkflowTriggerRegistrationRequest { + uint32 source_shard_id = 1; + map registered_workflows = 2; + uint32 total_active_workflows = 3; +} + +message ReportWorkflowTriggerRegistrationResponse { + bool success = 1; +} + +service ShardOrchestratorService { + rpc GetWorkflowShardMapping(GetWorkflowShardMappingRequest) returns (GetWorkflowShardMappingResponse); // returns shard assignments for the specified workflows + rpc ReportWorkflowTriggerRegistration(ReportWorkflowTriggerRegistrationRequest) returns (ReportWorkflowTriggerRegistrationResponse); // called by shards to report their workflow trigger registrations +} diff --git a/ring/pb/shared.proto b/ring/pb/shared.proto new file mode 100644 index 0000000..bdeac10 --- /dev/null +++ b/ring/pb/shared.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package ring; + +option go_package = "github.com/smartcontractkit/chainlink-protos/ring/go;ring"; + +message ShardStatus { + bool is_healthy = 1; +} diff --git a/taskfile.yml b/taskfile.yml index 2ed9cdf..e1e883c 100644 --- a/taskfile.yml +++ b/taskfile.yml @@ -77,6 +77,11 @@ tasks: cmds: - cd billing && make generate + proto:gen:ring: + desc: "Generate Go code from protobuf files for ring" + cmds: + - cd ring && make generate + proto:gen:storage-service: desc: "Generate Go code from protobuf files for storage-service" cmds: