diff --git a/Makefile b/Makefile index ebc7163312..193a1bf231 100644 --- a/Makefile +++ b/Makefile @@ -463,4 +463,4 @@ run: ## Run the pyroscope binary (pass parameters with 'make run PARAMS=-myparam .PHONY: mockery mockery: $(BIN)/mockery - $(BIN)/mockery \ No newline at end of file + $(BIN)/mockery diff --git a/api/gen/proto/go/metastore/v1/metastorev1connect/operator.connect.go b/api/gen/proto/go/metastore/v1/metastorev1connect/operator.connect.go new file mode 100644 index 0000000000..b6b3d004a1 --- /dev/null +++ b/api/gen/proto/go/metastore/v1/metastorev1connect/operator.connect.go @@ -0,0 +1,112 @@ +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: metastore/v1/operator.proto + +package metastorev1connect + +import ( + connect "connectrpc.com/connect" + context "context" + errors "errors" + v1 "github.com/grafana/pyroscope/api/gen/proto/go/metastore/v1" + http "net/http" + strings "strings" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect.IsAtLeastVersion1_13_0 + +const ( + // OperatorServiceName is the fully-qualified name of the OperatorService service. + OperatorServiceName = "metastore.v1.OperatorService" +) + +// These constants are the fully-qualified names of the RPCs defined in this package. They're +// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. +// +// Note that these are different from the fully-qualified method names used by +// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to +// reflection-formatted method names, remove the leading slash and convert the remaining slash to a +// period. +const ( + // OperatorServiceInfoProcedure is the fully-qualified name of the OperatorService's Info RPC. + OperatorServiceInfoProcedure = "/metastore.v1.OperatorService/Info" +) + +// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. +var ( + operatorServiceServiceDescriptor = v1.File_metastore_v1_operator_proto.Services().ByName("OperatorService") + operatorServiceInfoMethodDescriptor = operatorServiceServiceDescriptor.Methods().ByName("Info") +) + +// OperatorServiceClient is a client for the metastore.v1.OperatorService service. +type OperatorServiceClient interface { + Info(context.Context, *connect.Request[v1.InfoRequest]) (*connect.Response[v1.InfoResponse], error) +} + +// NewOperatorServiceClient constructs a client for the metastore.v1.OperatorService service. By +// default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, +// and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the +// connect.WithGRPC() or connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewOperatorServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) OperatorServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &operatorServiceClient{ + info: connect.NewClient[v1.InfoRequest, v1.InfoResponse]( + httpClient, + baseURL+OperatorServiceInfoProcedure, + connect.WithSchema(operatorServiceInfoMethodDescriptor), + connect.WithClientOptions(opts...), + ), + } +} + +// operatorServiceClient implements OperatorServiceClient. +type operatorServiceClient struct { + info *connect.Client[v1.InfoRequest, v1.InfoResponse] +} + +// Info calls metastore.v1.OperatorService.Info. +func (c *operatorServiceClient) Info(ctx context.Context, req *connect.Request[v1.InfoRequest]) (*connect.Response[v1.InfoResponse], error) { + return c.info.CallUnary(ctx, req) +} + +// OperatorServiceHandler is an implementation of the metastore.v1.OperatorService service. +type OperatorServiceHandler interface { + Info(context.Context, *connect.Request[v1.InfoRequest]) (*connect.Response[v1.InfoResponse], error) +} + +// NewOperatorServiceHandler builds an HTTP handler from the service implementation. It returns the +// path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewOperatorServiceHandler(svc OperatorServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + operatorServiceInfoHandler := connect.NewUnaryHandler( + OperatorServiceInfoProcedure, + svc.Info, + connect.WithSchema(operatorServiceInfoMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + return "/metastore.v1.OperatorService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case OperatorServiceInfoProcedure: + operatorServiceInfoHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedOperatorServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedOperatorServiceHandler struct{} + +func (UnimplementedOperatorServiceHandler) Info(context.Context, *connect.Request[v1.InfoRequest]) (*connect.Response[v1.InfoResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("metastore.v1.OperatorService.Info is not implemented")) +} diff --git a/api/gen/proto/go/metastore/v1/metastorev1connect/operator.connect.mux.go b/api/gen/proto/go/metastore/v1/metastorev1connect/operator.connect.mux.go new file mode 100644 index 0000000000..e927d7b91c --- /dev/null +++ b/api/gen/proto/go/metastore/v1/metastorev1connect/operator.connect.mux.go @@ -0,0 +1,27 @@ +// Code generated by protoc-gen-connect-go-mux. DO NOT EDIT. +// +// Source: metastore/v1/operator.proto + +package metastorev1connect + +import ( + connect "connectrpc.com/connect" + mux "github.com/gorilla/mux" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect.IsAtLeastVersion0_1_0 + +// RegisterOperatorServiceHandler register an HTTP handler to a mux.Router from the service +// implementation. +func RegisterOperatorServiceHandler(mux *mux.Router, svc OperatorServiceHandler, opts ...connect.HandlerOption) { + mux.Handle("/metastore.v1.OperatorService/Info", connect.NewUnaryHandler( + "/metastore.v1.OperatorService/Info", + svc.Info, + opts..., + )) +} diff --git a/api/gen/proto/go/metastore/v1/operator.pb.go b/api/gen/proto/go/metastore/v1/operator.pb.go new file mode 100644 index 0000000000..f1ca941b4c --- /dev/null +++ b/api/gen/proto/go/metastore/v1/operator.pb.go @@ -0,0 +1,801 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.34.2 +// protoc (unknown) +// source: metastore/v1/operator.proto + +package metastorev1 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +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) +) + +// State values are chosen to match the Hashicorp Raft library states. See: +// https://github.com/hashicorp/raft/blob/42d34464b2d203e389e11ed6d43db698792c0604/state.go#L15-L27. +type State int32 + +const ( + State_Follower State = 0 + State_Candidate State = 1 + State_Leader State = 2 + State_Shutdown State = 3 +) + +// Enum value maps for State. +var ( + State_name = map[int32]string{ + 0: "Follower", + 1: "Candidate", + 2: "Leader", + 3: "Shutdown", + } + State_value = map[string]int32{ + "Follower": 0, + "Candidate": 1, + "Leader": 2, + "Shutdown": 3, + } +) + +func (x State) Enum() *State { + p := new(State) + *p = x + return p +} + +func (x State) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (State) Descriptor() protoreflect.EnumDescriptor { + return file_metastore_v1_operator_proto_enumTypes[0].Descriptor() +} + +func (State) Type() protoreflect.EnumType { + return &file_metastore_v1_operator_proto_enumTypes[0] +} + +func (x State) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use State.Descriptor instead. +func (State) EnumDescriptor() ([]byte, []int) { + return file_metastore_v1_operator_proto_rawDescGZIP(), []int{0} +} + +// Suffrage values are chosen to match the Hashicorp Raft library suffrage +// values. See: +// https://github.com/hashicorp/raft/blob/42d34464b2d203e389e11ed6d43db698792c0604/configuration.go#L12-L24. +type Suffrage int32 + +const ( + Suffrage_Voter Suffrage = 0 + Suffrage_NonVoter Suffrage = 1 + Suffrage_Staging Suffrage = 2 +) + +// Enum value maps for Suffrage. +var ( + Suffrage_name = map[int32]string{ + 0: "Voter", + 1: "NonVoter", + 2: "Staging", + } + Suffrage_value = map[string]int32{ + "Voter": 0, + "NonVoter": 1, + "Staging": 2, + } +) + +func (x Suffrage) Enum() *Suffrage { + p := new(Suffrage) + *p = x + return p +} + +func (x Suffrage) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Suffrage) Descriptor() protoreflect.EnumDescriptor { + return file_metastore_v1_operator_proto_enumTypes[1].Descriptor() +} + +func (Suffrage) Type() protoreflect.EnumType { + return &file_metastore_v1_operator_proto_enumTypes[1] +} + +func (x Suffrage) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Suffrage.Descriptor instead. +func (Suffrage) EnumDescriptor() ([]byte, []int) { + return file_metastore_v1_operator_proto_rawDescGZIP(), []int{1} +} + +type Log struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + CommitIndex uint64 `protobuf:"varint,1,opt,name=commit_index,json=commitIndex,proto3" json:"commit_index,omitempty"` + AppliedIndex uint64 `protobuf:"varint,2,opt,name=applied_index,json=appliedIndex,proto3" json:"applied_index,omitempty"` + LastIndex uint64 `protobuf:"varint,3,opt,name=last_index,json=lastIndex,proto3" json:"last_index,omitempty"` + FsmPendingLength uint64 `protobuf:"varint,4,opt,name=fsm_pending_length,json=fsmPendingLength,proto3" json:"fsm_pending_length,omitempty"` +} + +func (x *Log) Reset() { + *x = Log{} + if protoimpl.UnsafeEnabled { + mi := &file_metastore_v1_operator_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Log) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Log) ProtoMessage() {} + +func (x *Log) ProtoReflect() protoreflect.Message { + mi := &file_metastore_v1_operator_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Log.ProtoReflect.Descriptor instead. +func (*Log) Descriptor() ([]byte, []int) { + return file_metastore_v1_operator_proto_rawDescGZIP(), []int{0} +} + +func (x *Log) GetCommitIndex() uint64 { + if x != nil { + return x.CommitIndex + } + return 0 +} + +func (x *Log) GetAppliedIndex() uint64 { + if x != nil { + return x.AppliedIndex + } + return 0 +} + +func (x *Log) GetLastIndex() uint64 { + if x != nil { + return x.LastIndex + } + return 0 +} + +func (x *Log) GetFsmPendingLength() uint64 { + if x != nil { + return x.FsmPendingLength + } + return 0 +} + +type Snapshot struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + LastIndex uint64 `protobuf:"varint,1,opt,name=last_index,json=lastIndex,proto3" json:"last_index,omitempty"` + LastTerm uint64 `protobuf:"varint,2,opt,name=last_term,json=lastTerm,proto3" json:"last_term,omitempty"` +} + +func (x *Snapshot) Reset() { + *x = Snapshot{} + if protoimpl.UnsafeEnabled { + mi := &file_metastore_v1_operator_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Snapshot) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Snapshot) ProtoMessage() {} + +func (x *Snapshot) ProtoReflect() protoreflect.Message { + mi := &file_metastore_v1_operator_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Snapshot.ProtoReflect.Descriptor instead. +func (*Snapshot) Descriptor() ([]byte, []int) { + return file_metastore_v1_operator_proto_rawDescGZIP(), []int{1} +} + +func (x *Snapshot) GetLastIndex() uint64 { + if x != nil { + return x.LastIndex + } + return 0 +} + +func (x *Snapshot) GetLastTerm() uint64 { + if x != nil { + return x.LastTerm + } + return 0 +} + +type Protocol struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Version uint64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` + MinVersion uint64 `protobuf:"varint,2,opt,name=min_version,json=minVersion,proto3" json:"min_version,omitempty"` + MaxVersion uint64 `protobuf:"varint,3,opt,name=max_version,json=maxVersion,proto3" json:"max_version,omitempty"` + MinSnapshotVersion uint64 `protobuf:"varint,4,opt,name=min_snapshot_version,json=minSnapshotVersion,proto3" json:"min_snapshot_version,omitempty"` + MaxSnapshotVersion uint64 `protobuf:"varint,5,opt,name=max_snapshot_version,json=maxSnapshotVersion,proto3" json:"max_snapshot_version,omitempty"` +} + +func (x *Protocol) Reset() { + *x = Protocol{} + if protoimpl.UnsafeEnabled { + mi := &file_metastore_v1_operator_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Protocol) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Protocol) ProtoMessage() {} + +func (x *Protocol) ProtoReflect() protoreflect.Message { + mi := &file_metastore_v1_operator_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Protocol.ProtoReflect.Descriptor instead. +func (*Protocol) Descriptor() ([]byte, []int) { + return file_metastore_v1_operator_proto_rawDescGZIP(), []int{2} +} + +func (x *Protocol) GetVersion() uint64 { + if x != nil { + return x.Version + } + return 0 +} + +func (x *Protocol) GetMinVersion() uint64 { + if x != nil { + return x.MinVersion + } + return 0 +} + +func (x *Protocol) GetMaxVersion() uint64 { + if x != nil { + return x.MaxVersion + } + return 0 +} + +func (x *Protocol) GetMinSnapshotVersion() uint64 { + if x != nil { + return x.MinSnapshotVersion + } + return 0 +} + +func (x *Protocol) GetMaxSnapshotVersion() uint64 { + if x != nil { + return x.MaxSnapshotVersion + } + return 0 +} + +type Peer struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + Suffrage Suffrage `protobuf:"varint,3,opt,name=suffrage,proto3,enum=metastore.v1.Suffrage" json:"suffrage,omitempty"` +} + +func (x *Peer) Reset() { + *x = Peer{} + if protoimpl.UnsafeEnabled { + mi := &file_metastore_v1_operator_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Peer) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Peer) ProtoMessage() {} + +func (x *Peer) ProtoReflect() protoreflect.Message { + mi := &file_metastore_v1_operator_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Peer.ProtoReflect.Descriptor instead. +func (*Peer) Descriptor() ([]byte, []int) { + return file_metastore_v1_operator_proto_rawDescGZIP(), []int{3} +} + +func (x *Peer) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *Peer) GetAddress() string { + if x != nil { + return x.Address + } + return "" +} + +func (x *Peer) GetSuffrage() Suffrage { + if x != nil { + return x.Suffrage + } + return Suffrage_Voter +} + +type InfoRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *InfoRequest) Reset() { + *x = InfoRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_metastore_v1_operator_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *InfoRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InfoRequest) ProtoMessage() {} + +func (x *InfoRequest) ProtoReflect() protoreflect.Message { + mi := &file_metastore_v1_operator_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InfoRequest.ProtoReflect.Descriptor instead. +func (*InfoRequest) Descriptor() ([]byte, []int) { + return file_metastore_v1_operator_proto_rawDescGZIP(), []int{4} +} + +type InfoResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + State State `protobuf:"varint,2,opt,name=state,proto3,enum=metastore.v1.State" json:"state,omitempty"` + LeaderId string `protobuf:"bytes,3,opt,name=leader_id,json=leaderId,proto3" json:"leader_id,omitempty"` + // True if the state reported by this node matches the state the cluster + // reports. For example, if this node claims to be a leader, but the rest of + // the cluster disagrees, this value will be false. + IsStateVerified bool `protobuf:"varint,4,opt,name=is_state_verified,json=isStateVerified,proto3" json:"is_state_verified,omitempty"` + // Unix timestamp in milliseconds of when the leader last contacted this node. + LastLeaderContact int64 `protobuf:"varint,5,opt,name=last_leader_contact,json=lastLeaderContact,proto3" json:"last_leader_contact,omitempty"` + Term uint64 `protobuf:"varint,6,opt,name=term,proto3" json:"term,omitempty"` + Suffrage Suffrage `protobuf:"varint,7,opt,name=suffrage,proto3,enum=metastore.v1.Suffrage" json:"suffrage,omitempty"` + Log *Log `protobuf:"bytes,8,opt,name=log,proto3" json:"log,omitempty"` + Snapshot *Snapshot `protobuf:"bytes,9,opt,name=snapshot,proto3" json:"snapshot,omitempty"` + Protocol *Protocol `protobuf:"bytes,10,opt,name=protocol,proto3" json:"protocol,omitempty"` + Peers []*Peer `protobuf:"bytes,11,rep,name=peers,proto3" json:"peers,omitempty"` +} + +func (x *InfoResponse) Reset() { + *x = InfoResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_metastore_v1_operator_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *InfoResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InfoResponse) ProtoMessage() {} + +func (x *InfoResponse) ProtoReflect() protoreflect.Message { + mi := &file_metastore_v1_operator_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InfoResponse.ProtoReflect.Descriptor instead. +func (*InfoResponse) Descriptor() ([]byte, []int) { + return file_metastore_v1_operator_proto_rawDescGZIP(), []int{5} +} + +func (x *InfoResponse) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *InfoResponse) GetState() State { + if x != nil { + return x.State + } + return State_Follower +} + +func (x *InfoResponse) GetLeaderId() string { + if x != nil { + return x.LeaderId + } + return "" +} + +func (x *InfoResponse) GetIsStateVerified() bool { + if x != nil { + return x.IsStateVerified + } + return false +} + +func (x *InfoResponse) GetLastLeaderContact() int64 { + if x != nil { + return x.LastLeaderContact + } + return 0 +} + +func (x *InfoResponse) GetTerm() uint64 { + if x != nil { + return x.Term + } + return 0 +} + +func (x *InfoResponse) GetSuffrage() Suffrage { + if x != nil { + return x.Suffrage + } + return Suffrage_Voter +} + +func (x *InfoResponse) GetLog() *Log { + if x != nil { + return x.Log + } + return nil +} + +func (x *InfoResponse) GetSnapshot() *Snapshot { + if x != nil { + return x.Snapshot + } + return nil +} + +func (x *InfoResponse) GetProtocol() *Protocol { + if x != nil { + return x.Protocol + } + return nil +} + +func (x *InfoResponse) GetPeers() []*Peer { + if x != nil { + return x.Peers + } + return nil +} + +var File_metastore_v1_operator_proto protoreflect.FileDescriptor + +var file_metastore_v1_operator_proto_rawDesc = []byte{ + 0x0a, 0x1b, 0x6d, 0x65, 0x74, 0x61, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x6f, + 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, 0x6d, + 0x65, 0x74, 0x61, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x22, 0x9a, 0x01, 0x0a, 0x03, + 0x4c, 0x6f, 0x67, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x69, 0x6e, + 0x64, 0x65, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x63, 0x6f, 0x6d, 0x6d, 0x69, + 0x74, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x23, 0x0a, 0x0d, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x65, + 0x64, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0c, 0x61, + 0x70, 0x70, 0x6c, 0x69, 0x65, 0x64, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x1d, 0x0a, 0x0a, 0x6c, + 0x61, 0x73, 0x74, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x09, 0x6c, 0x61, 0x73, 0x74, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x2c, 0x0a, 0x12, 0x66, 0x73, + 0x6d, 0x5f, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x10, 0x66, 0x73, 0x6d, 0x50, 0x65, 0x6e, 0x64, 0x69, + 0x6e, 0x67, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x22, 0x46, 0x0a, 0x08, 0x53, 0x6e, 0x61, 0x70, + 0x73, 0x68, 0x6f, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x69, 0x6e, 0x64, + 0x65, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x6c, 0x61, 0x73, 0x74, 0x49, 0x6e, + 0x64, 0x65, 0x78, 0x12, 0x1b, 0x0a, 0x09, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x74, 0x65, 0x72, 0x6d, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x6c, 0x61, 0x73, 0x74, 0x54, 0x65, 0x72, 0x6d, + 0x22, 0xca, 0x01, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x18, 0x0a, + 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x6d, 0x69, 0x6e, 0x5f, 0x76, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x6d, 0x69, + 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x6d, 0x61, 0x78, 0x5f, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x6d, + 0x61, 0x78, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x30, 0x0a, 0x14, 0x6d, 0x69, 0x6e, + 0x5f, 0x73, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x12, 0x6d, 0x69, 0x6e, 0x53, 0x6e, 0x61, 0x70, + 0x73, 0x68, 0x6f, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x30, 0x0a, 0x14, 0x6d, + 0x61, 0x78, 0x5f, 0x73, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x5f, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x12, 0x6d, 0x61, 0x78, 0x53, 0x6e, + 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x64, 0x0a, + 0x04, 0x50, 0x65, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, + 0x32, 0x0a, 0x08, 0x73, 0x75, 0x66, 0x66, 0x72, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x16, 0x2e, 0x6d, 0x65, 0x74, 0x61, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, + 0x2e, 0x53, 0x75, 0x66, 0x66, 0x72, 0x61, 0x67, 0x65, 0x52, 0x08, 0x73, 0x75, 0x66, 0x66, 0x72, + 0x61, 0x67, 0x65, 0x22, 0x0d, 0x0a, 0x0b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x22, 0xc1, 0x03, 0x0a, 0x0c, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x02, 0x69, 0x64, 0x12, 0x29, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x13, 0x2e, 0x6d, 0x65, 0x74, 0x61, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, + 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x1b, + 0x0a, 0x09, 0x6c, 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x6c, 0x65, 0x61, 0x64, 0x65, 0x72, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x11, 0x69, + 0x73, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x64, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x69, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x56, + 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x64, 0x12, 0x2e, 0x0a, 0x13, 0x6c, 0x61, 0x73, 0x74, 0x5f, + 0x6c, 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x11, 0x6c, 0x61, 0x73, 0x74, 0x4c, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x72, 0x6d, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x74, 0x65, 0x72, 0x6d, 0x12, 0x32, 0x0a, 0x08, 0x73, + 0x75, 0x66, 0x66, 0x72, 0x61, 0x67, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x16, 0x2e, + 0x6d, 0x65, 0x74, 0x61, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x75, 0x66, + 0x66, 0x72, 0x61, 0x67, 0x65, 0x52, 0x08, 0x73, 0x75, 0x66, 0x66, 0x72, 0x61, 0x67, 0x65, 0x12, + 0x23, 0x0a, 0x03, 0x6c, 0x6f, 0x67, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x6d, + 0x65, 0x74, 0x61, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x6f, 0x67, 0x52, + 0x03, 0x6c, 0x6f, 0x67, 0x12, 0x32, 0x0a, 0x08, 0x73, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, + 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6d, 0x65, 0x74, 0x61, 0x73, 0x74, 0x6f, + 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x52, 0x08, + 0x73, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x12, 0x32, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6d, 0x65, 0x74, + 0x61, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, + 0x6f, 0x6c, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x28, 0x0a, 0x05, + 0x70, 0x65, 0x65, 0x72, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6d, 0x65, + 0x74, 0x61, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x52, + 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, 0x2a, 0x3e, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, + 0x0c, 0x0a, 0x08, 0x46, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x72, 0x10, 0x00, 0x12, 0x0d, 0x0a, + 0x09, 0x43, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, + 0x4c, 0x65, 0x61, 0x64, 0x65, 0x72, 0x10, 0x02, 0x12, 0x0c, 0x0a, 0x08, 0x53, 0x68, 0x75, 0x74, + 0x64, 0x6f, 0x77, 0x6e, 0x10, 0x03, 0x2a, 0x30, 0x0a, 0x08, 0x53, 0x75, 0x66, 0x66, 0x72, 0x61, + 0x67, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x56, 0x6f, 0x74, 0x65, 0x72, 0x10, 0x00, 0x12, 0x0c, 0x0a, + 0x08, 0x4e, 0x6f, 0x6e, 0x56, 0x6f, 0x74, 0x65, 0x72, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x53, + 0x74, 0x61, 0x67, 0x69, 0x6e, 0x67, 0x10, 0x02, 0x32, 0x52, 0x0a, 0x0f, 0x4f, 0x70, 0x65, 0x72, + 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3f, 0x0a, 0x04, 0x49, + 0x6e, 0x66, 0x6f, 0x12, 0x19, 0x2e, 0x6d, 0x65, 0x74, 0x61, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, + 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, + 0x2e, 0x6d, 0x65, 0x74, 0x61, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, + 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0xba, 0x01, 0x0a, + 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x6d, 0x65, 0x74, 0x61, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, + 0x31, 0x42, 0x0d, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x50, 0x01, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, + 0x72, 0x61, 0x66, 0x61, 0x6e, 0x61, 0x2f, 0x70, 0x79, 0x72, 0x6f, 0x73, 0x63, 0x6f, 0x70, 0x65, + 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, + 0x6f, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x6d, + 0x65, 0x74, 0x61, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x4d, 0x58, 0x58, + 0xaa, 0x02, 0x0c, 0x4d, 0x65, 0x74, 0x61, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x56, 0x31, 0xca, + 0x02, 0x0c, 0x4d, 0x65, 0x74, 0x61, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, + 0x18, 0x4d, 0x65, 0x74, 0x61, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, + 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0d, 0x4d, 0x65, 0x74, 0x61, + 0x73, 0x74, 0x6f, 0x72, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, +} + +var ( + file_metastore_v1_operator_proto_rawDescOnce sync.Once + file_metastore_v1_operator_proto_rawDescData = file_metastore_v1_operator_proto_rawDesc +) + +func file_metastore_v1_operator_proto_rawDescGZIP() []byte { + file_metastore_v1_operator_proto_rawDescOnce.Do(func() { + file_metastore_v1_operator_proto_rawDescData = protoimpl.X.CompressGZIP(file_metastore_v1_operator_proto_rawDescData) + }) + return file_metastore_v1_operator_proto_rawDescData +} + +var file_metastore_v1_operator_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_metastore_v1_operator_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_metastore_v1_operator_proto_goTypes = []any{ + (State)(0), // 0: metastore.v1.State + (Suffrage)(0), // 1: metastore.v1.Suffrage + (*Log)(nil), // 2: metastore.v1.Log + (*Snapshot)(nil), // 3: metastore.v1.Snapshot + (*Protocol)(nil), // 4: metastore.v1.Protocol + (*Peer)(nil), // 5: metastore.v1.Peer + (*InfoRequest)(nil), // 6: metastore.v1.InfoRequest + (*InfoResponse)(nil), // 7: metastore.v1.InfoResponse +} +var file_metastore_v1_operator_proto_depIdxs = []int32{ + 1, // 0: metastore.v1.Peer.suffrage:type_name -> metastore.v1.Suffrage + 0, // 1: metastore.v1.InfoResponse.state:type_name -> metastore.v1.State + 1, // 2: metastore.v1.InfoResponse.suffrage:type_name -> metastore.v1.Suffrage + 2, // 3: metastore.v1.InfoResponse.log:type_name -> metastore.v1.Log + 3, // 4: metastore.v1.InfoResponse.snapshot:type_name -> metastore.v1.Snapshot + 4, // 5: metastore.v1.InfoResponse.protocol:type_name -> metastore.v1.Protocol + 5, // 6: metastore.v1.InfoResponse.peers:type_name -> metastore.v1.Peer + 6, // 7: metastore.v1.OperatorService.Info:input_type -> metastore.v1.InfoRequest + 7, // 8: metastore.v1.OperatorService.Info:output_type -> metastore.v1.InfoResponse + 8, // [8:9] is the sub-list for method output_type + 7, // [7:8] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name +} + +func init() { file_metastore_v1_operator_proto_init() } +func file_metastore_v1_operator_proto_init() { + if File_metastore_v1_operator_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_metastore_v1_operator_proto_msgTypes[0].Exporter = func(v any, i int) any { + switch v := v.(*Log); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_metastore_v1_operator_proto_msgTypes[1].Exporter = func(v any, i int) any { + switch v := v.(*Snapshot); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_metastore_v1_operator_proto_msgTypes[2].Exporter = func(v any, i int) any { + switch v := v.(*Protocol); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_metastore_v1_operator_proto_msgTypes[3].Exporter = func(v any, i int) any { + switch v := v.(*Peer); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_metastore_v1_operator_proto_msgTypes[4].Exporter = func(v any, i int) any { + switch v := v.(*InfoRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_metastore_v1_operator_proto_msgTypes[5].Exporter = func(v any, i int) any { + switch v := v.(*InfoResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_metastore_v1_operator_proto_rawDesc, + NumEnums: 2, + NumMessages: 6, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_metastore_v1_operator_proto_goTypes, + DependencyIndexes: file_metastore_v1_operator_proto_depIdxs, + EnumInfos: file_metastore_v1_operator_proto_enumTypes, + MessageInfos: file_metastore_v1_operator_proto_msgTypes, + }.Build() + File_metastore_v1_operator_proto = out.File + file_metastore_v1_operator_proto_rawDesc = nil + file_metastore_v1_operator_proto_goTypes = nil + file_metastore_v1_operator_proto_depIdxs = nil +} diff --git a/api/gen/proto/go/metastore/v1/operator_vtproto.pb.go b/api/gen/proto/go/metastore/v1/operator_vtproto.pb.go new file mode 100644 index 0000000000..5c7cf990ec --- /dev/null +++ b/api/gen/proto/go/metastore/v1/operator_vtproto.pb.go @@ -0,0 +1,1832 @@ +// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. +// protoc-gen-go-vtproto version: v0.6.0 +// source: metastore/v1/operator.proto + +package metastorev1 + +import ( + context "context" + fmt "fmt" + protohelpers "github.com/planetscale/vtprotobuf/protohelpers" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + proto "google.golang.org/protobuf/proto" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" +) + +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) +) + +func (m *Log) CloneVT() *Log { + if m == nil { + return (*Log)(nil) + } + r := new(Log) + r.CommitIndex = m.CommitIndex + r.AppliedIndex = m.AppliedIndex + r.LastIndex = m.LastIndex + r.FsmPendingLength = m.FsmPendingLength + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *Log) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *Snapshot) CloneVT() *Snapshot { + if m == nil { + return (*Snapshot)(nil) + } + r := new(Snapshot) + r.LastIndex = m.LastIndex + r.LastTerm = m.LastTerm + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *Snapshot) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *Protocol) CloneVT() *Protocol { + if m == nil { + return (*Protocol)(nil) + } + r := new(Protocol) + r.Version = m.Version + r.MinVersion = m.MinVersion + r.MaxVersion = m.MaxVersion + r.MinSnapshotVersion = m.MinSnapshotVersion + r.MaxSnapshotVersion = m.MaxSnapshotVersion + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *Protocol) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *Peer) CloneVT() *Peer { + if m == nil { + return (*Peer)(nil) + } + r := new(Peer) + r.Id = m.Id + r.Address = m.Address + r.Suffrage = m.Suffrage + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *Peer) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *InfoRequest) CloneVT() *InfoRequest { + if m == nil { + return (*InfoRequest)(nil) + } + r := new(InfoRequest) + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *InfoRequest) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *InfoResponse) CloneVT() *InfoResponse { + if m == nil { + return (*InfoResponse)(nil) + } + r := new(InfoResponse) + r.Id = m.Id + r.State = m.State + r.LeaderId = m.LeaderId + r.IsStateVerified = m.IsStateVerified + r.LastLeaderContact = m.LastLeaderContact + r.Term = m.Term + r.Suffrage = m.Suffrage + r.Log = m.Log.CloneVT() + r.Snapshot = m.Snapshot.CloneVT() + r.Protocol = m.Protocol.CloneVT() + if rhs := m.Peers; rhs != nil { + tmpContainer := make([]*Peer, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.Peers = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *InfoResponse) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (this *Log) EqualVT(that *Log) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.CommitIndex != that.CommitIndex { + return false + } + if this.AppliedIndex != that.AppliedIndex { + return false + } + if this.LastIndex != that.LastIndex { + return false + } + if this.FsmPendingLength != that.FsmPendingLength { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Log) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*Log) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *Snapshot) EqualVT(that *Snapshot) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.LastIndex != that.LastIndex { + return false + } + if this.LastTerm != that.LastTerm { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Snapshot) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*Snapshot) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *Protocol) EqualVT(that *Protocol) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Version != that.Version { + return false + } + if this.MinVersion != that.MinVersion { + return false + } + if this.MaxVersion != that.MaxVersion { + return false + } + if this.MinSnapshotVersion != that.MinSnapshotVersion { + return false + } + if this.MaxSnapshotVersion != that.MaxSnapshotVersion { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Protocol) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*Protocol) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *Peer) EqualVT(that *Peer) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Id != that.Id { + return false + } + if this.Address != that.Address { + return false + } + if this.Suffrage != that.Suffrage { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Peer) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*Peer) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *InfoRequest) EqualVT(that *InfoRequest) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *InfoRequest) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*InfoRequest) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *InfoResponse) EqualVT(that *InfoResponse) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Id != that.Id { + return false + } + if this.State != that.State { + return false + } + if this.LeaderId != that.LeaderId { + return false + } + if this.IsStateVerified != that.IsStateVerified { + return false + } + if this.LastLeaderContact != that.LastLeaderContact { + return false + } + if this.Term != that.Term { + return false + } + if this.Suffrage != that.Suffrage { + return false + } + if !this.Log.EqualVT(that.Log) { + return false + } + if !this.Snapshot.EqualVT(that.Snapshot) { + return false + } + if !this.Protocol.EqualVT(that.Protocol) { + return false + } + if len(this.Peers) != len(that.Peers) { + return false + } + for i, vx := range this.Peers { + vy := that.Peers[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &Peer{} + } + if q == nil { + q = &Peer{} + } + if !p.EqualVT(q) { + return false + } + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *InfoResponse) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*InfoResponse) + if !ok { + return false + } + return this.EqualVT(that) +} + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// OperatorServiceClient is the client API for OperatorService 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 OperatorServiceClient interface { + Info(ctx context.Context, in *InfoRequest, opts ...grpc.CallOption) (*InfoResponse, error) +} + +type operatorServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewOperatorServiceClient(cc grpc.ClientConnInterface) OperatorServiceClient { + return &operatorServiceClient{cc} +} + +func (c *operatorServiceClient) Info(ctx context.Context, in *InfoRequest, opts ...grpc.CallOption) (*InfoResponse, error) { + out := new(InfoResponse) + err := c.cc.Invoke(ctx, "/metastore.v1.OperatorService/Info", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// OperatorServiceServer is the server API for OperatorService service. +// All implementations must embed UnimplementedOperatorServiceServer +// for forward compatibility +type OperatorServiceServer interface { + Info(context.Context, *InfoRequest) (*InfoResponse, error) + mustEmbedUnimplementedOperatorServiceServer() +} + +// UnimplementedOperatorServiceServer must be embedded to have forward compatible implementations. +type UnimplementedOperatorServiceServer struct { +} + +func (UnimplementedOperatorServiceServer) Info(context.Context, *InfoRequest) (*InfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Info not implemented") +} +func (UnimplementedOperatorServiceServer) mustEmbedUnimplementedOperatorServiceServer() {} + +// UnsafeOperatorServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to OperatorServiceServer will +// result in compilation errors. +type UnsafeOperatorServiceServer interface { + mustEmbedUnimplementedOperatorServiceServer() +} + +func RegisterOperatorServiceServer(s grpc.ServiceRegistrar, srv OperatorServiceServer) { + s.RegisterService(&OperatorService_ServiceDesc, srv) +} + +func _OperatorService_Info_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(InfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(OperatorServiceServer).Info(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/metastore.v1.OperatorService/Info", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(OperatorServiceServer).Info(ctx, req.(*InfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// OperatorService_ServiceDesc is the grpc.ServiceDesc for OperatorService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var OperatorService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "metastore.v1.OperatorService", + HandlerType: (*OperatorServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Info", + Handler: _OperatorService_Info_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "metastore/v1/operator.proto", +} + +func (m *Log) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Log) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Log) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.FsmPendingLength != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.FsmPendingLength)) + i-- + dAtA[i] = 0x20 + } + if m.LastIndex != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.LastIndex)) + i-- + dAtA[i] = 0x18 + } + if m.AppliedIndex != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.AppliedIndex)) + i-- + dAtA[i] = 0x10 + } + if m.CommitIndex != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.CommitIndex)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *Snapshot) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Snapshot) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Snapshot) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.LastTerm != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.LastTerm)) + i-- + dAtA[i] = 0x10 + } + if m.LastIndex != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.LastIndex)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *Protocol) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Protocol) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Protocol) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.MaxSnapshotVersion != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.MaxSnapshotVersion)) + i-- + dAtA[i] = 0x28 + } + if m.MinSnapshotVersion != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.MinSnapshotVersion)) + i-- + dAtA[i] = 0x20 + } + if m.MaxVersion != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.MaxVersion)) + i-- + dAtA[i] = 0x18 + } + if m.MinVersion != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.MinVersion)) + i-- + dAtA[i] = 0x10 + } + if m.Version != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Version)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *Peer) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Peer) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Peer) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Suffrage != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Suffrage)) + i-- + dAtA[i] = 0x18 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x12 + } + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *InfoRequest) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *InfoRequest) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *InfoRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + return len(dAtA) - i, nil +} + +func (m *InfoResponse) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *InfoResponse) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *InfoResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Peers) > 0 { + for iNdEx := len(m.Peers) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.Peers[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x5a + } + } + if m.Protocol != nil { + size, err := m.Protocol.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x52 + } + if m.Snapshot != nil { + size, err := m.Snapshot.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x4a + } + if m.Log != nil { + size, err := m.Log.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x42 + } + if m.Suffrage != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Suffrage)) + i-- + dAtA[i] = 0x38 + } + if m.Term != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Term)) + i-- + dAtA[i] = 0x30 + } + if m.LastLeaderContact != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.LastLeaderContact)) + i-- + dAtA[i] = 0x28 + } + if m.IsStateVerified { + i-- + if m.IsStateVerified { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } + if len(m.LeaderId) > 0 { + i -= len(m.LeaderId) + copy(dAtA[i:], m.LeaderId) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.LeaderId))) + i-- + dAtA[i] = 0x1a + } + if m.State != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.State)) + i-- + dAtA[i] = 0x10 + } + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Log) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CommitIndex != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.CommitIndex)) + } + if m.AppliedIndex != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.AppliedIndex)) + } + if m.LastIndex != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.LastIndex)) + } + if m.FsmPendingLength != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.FsmPendingLength)) + } + n += len(m.unknownFields) + return n +} + +func (m *Snapshot) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.LastIndex != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.LastIndex)) + } + if m.LastTerm != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.LastTerm)) + } + n += len(m.unknownFields) + return n +} + +func (m *Protocol) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Version != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Version)) + } + if m.MinVersion != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.MinVersion)) + } + if m.MaxVersion != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.MaxVersion)) + } + if m.MinSnapshotVersion != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.MinSnapshotVersion)) + } + if m.MaxSnapshotVersion != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.MaxSnapshotVersion)) + } + n += len(m.unknownFields) + return n +} + +func (m *Peer) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.Suffrage != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Suffrage)) + } + n += len(m.unknownFields) + return n +} + +func (m *InfoRequest) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += len(m.unknownFields) + return n +} + +func (m *InfoResponse) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.State != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.State)) + } + l = len(m.LeaderId) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.IsStateVerified { + n += 2 + } + if m.LastLeaderContact != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.LastLeaderContact)) + } + if m.Term != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Term)) + } + if m.Suffrage != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Suffrage)) + } + if m.Log != nil { + l = m.Log.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.Snapshot != nil { + l = m.Snapshot.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.Protocol != nil { + l = m.Protocol.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if len(m.Peers) > 0 { + for _, e := range m.Peers { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *Log) UnmarshalVT(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 protohelpers.ErrIntOverflow + } + 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: Log: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Log: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CommitIndex", wireType) + } + m.CommitIndex = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CommitIndex |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AppliedIndex", wireType) + } + m.AppliedIndex = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AppliedIndex |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LastIndex", wireType) + } + m.LastIndex = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LastIndex |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FsmPendingLength", wireType) + } + m.FsmPendingLength = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.FsmPendingLength |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Snapshot) UnmarshalVT(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 protohelpers.ErrIntOverflow + } + 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: Snapshot: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Snapshot: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LastIndex", wireType) + } + m.LastIndex = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LastIndex |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LastTerm", wireType) + } + m.LastTerm = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LastTerm |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Protocol) UnmarshalVT(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 protohelpers.ErrIntOverflow + } + 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: Protocol: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Protocol: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + m.Version = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Version |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinVersion", wireType) + } + m.MinVersion = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinVersion |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxVersion", wireType) + } + m.MaxVersion = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxVersion |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinSnapshotVersion", wireType) + } + m.MinSnapshotVersion = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinSnapshotVersion |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxSnapshotVersion", wireType) + } + m.MaxSnapshotVersion = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxSnapshotVersion |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Peer) UnmarshalVT(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 protohelpers.ErrIntOverflow + } + 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: Peer: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Peer: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + 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 protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + 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 protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Suffrage", wireType) + } + m.Suffrage = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Suffrage |= Suffrage(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *InfoRequest) UnmarshalVT(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 protohelpers.ErrIntOverflow + } + 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: InfoRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: InfoRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *InfoResponse) UnmarshalVT(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 protohelpers.ErrIntOverflow + } + 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: InfoResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: InfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + 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 protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field State", wireType) + } + m.State = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.State |= State(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LeaderId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + 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 protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.LeaderId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsStateVerified", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsStateVerified = bool(v != 0) + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LastLeaderContact", wireType) + } + m.LastLeaderContact = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LastLeaderContact |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Term", wireType) + } + m.Term = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Term |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Suffrage", wireType) + } + m.Suffrage = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Suffrage |= Suffrage(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Log", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Log == nil { + m.Log = &Log{} + } + if err := m.Log.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Snapshot", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Snapshot == nil { + m.Snapshot = &Snapshot{} + } + if err := m.Snapshot.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Protocol", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Protocol == nil { + m.Protocol = &Protocol{} + } + if err := m.Protocol.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Peers", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Peers = append(m.Peers, &Peer{}) + if err := m.Peers[len(m.Peers)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} diff --git a/api/metastore/v1/operator.proto b/api/metastore/v1/operator.proto new file mode 100644 index 0000000000..e229a98f88 --- /dev/null +++ b/api/metastore/v1/operator.proto @@ -0,0 +1,71 @@ +syntax = "proto3"; + +package metastore.v1; + +service OperatorService { + rpc Info(InfoRequest) returns (InfoResponse) {} +} + +// State values are chosen to match the Hashicorp Raft library states. See: +// https://github.com/hashicorp/raft/blob/42d34464b2d203e389e11ed6d43db698792c0604/state.go#L15-L27. +enum State { + Follower = 0; + Candidate = 1; + Leader = 2; + Shutdown = 3; +} + +// Suffrage values are chosen to match the Hashicorp Raft library suffrage +// values. See: +// https://github.com/hashicorp/raft/blob/42d34464b2d203e389e11ed6d43db698792c0604/configuration.go#L12-L24. +enum Suffrage { + Voter = 0; + NonVoter = 1; + Staging = 2; +} + +message Log { + uint64 commit_index = 1; + uint64 applied_index = 2; + uint64 last_index = 3; + uint64 fsm_pending_length = 4; +} + +message Snapshot { + uint64 last_index = 1; + uint64 last_term = 2; +} + +message Protocol { + uint64 version = 1; + uint64 min_version = 2; + uint64 max_version = 3; + uint64 min_snapshot_version = 4; + uint64 max_snapshot_version = 5; +} + +message Peer { + string id = 1; + string address = 2; + Suffrage suffrage = 3; +} + +message InfoRequest {} + +message InfoResponse { + string id = 1; + State state = 2; + string leader_id = 3; + // True if the state reported by this node matches the state the cluster + // reports. For example, if this node claims to be a leader, but the rest of + // the cluster disagrees, this value will be false. + bool is_state_verified = 4; + // Unix timestamp in milliseconds of when the leader last contacted this node. + int64 last_leader_contact = 5; + uint64 term = 6; + Suffrage suffrage = 7; + Log log = 8; + Snapshot snapshot = 9; + Protocol protocol = 10; + repeated Peer peers = 11; +} diff --git a/api/openapiv2/gen/phlare.swagger.json b/api/openapiv2/gen/phlare.swagger.json index fb8846ef46..7a14fd90c3 100644 --- a/api/openapiv2/gen/phlare.swagger.json +++ b/api/openapiv2/gen/phlare.swagger.json @@ -20,6 +20,9 @@ { "name": "IngesterService" }, + { + "name": "OperatorService" + }, { "name": "QuerierService" }, @@ -1121,6 +1124,52 @@ }, "title": "Hints are used to propagate information about querying" }, + "v1InfoResponse": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "state": { + "$ref": "#/definitions/v1State" + }, + "leaderId": { + "type": "string" + }, + "isStateVerified": { + "type": "boolean", + "description": "True if the state reported by this node matches the state the cluster\nreports. For example, if this node claims to be a leader, but the rest of\nthe cluster disagrees, this value will be false." + }, + "lastLeaderContact": { + "type": "string", + "format": "int64", + "description": "Unix timestamp in milliseconds of when the leader last contacted this node." + }, + "term": { + "type": "string", + "format": "uint64" + }, + "suffrage": { + "$ref": "#/definitions/v1Suffrage" + }, + "log": { + "$ref": "#/definitions/v1Log" + }, + "snapshot": { + "$ref": "#/definitions/v1Snapshot" + }, + "protocol": { + "$ref": "#/definitions/v1Protocol" + }, + "peers": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/v1Peer" + } + } + } + }, "v1InvokeOptions": { "type": "object", "description": "Query workers might not have access to the tenant\n overrides, therefore all the necessary options should\n be listed in the request explicitly." @@ -1252,6 +1301,27 @@ } } }, + "v1Log": { + "type": "object", + "properties": { + "commitIndex": { + "type": "string", + "format": "uint64" + }, + "appliedIndex": { + "type": "string", + "format": "uint64" + }, + "lastIndex": { + "type": "string", + "format": "uint64" + }, + "fsmPendingLength": { + "type": "string", + "format": "uint64" + } + } + }, "v1Mapping": { "type": "object", "properties": { @@ -1393,6 +1463,20 @@ } } }, + "v1Peer": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "address": { + "type": "string" + }, + "suffrage": { + "$ref": "#/definitions/v1Suffrage" + } + } + }, "v1Point": { "type": "object", "properties": { @@ -1500,6 +1584,31 @@ } } }, + "v1Protocol": { + "type": "object", + "properties": { + "version": { + "type": "string", + "format": "uint64" + }, + "minVersion": { + "type": "string", + "format": "uint64" + }, + "maxVersion": { + "type": "string", + "format": "uint64" + }, + "minSnapshotVersion": { + "type": "string", + "format": "uint64" + }, + "maxSnapshotVersion": { + "type": "string", + "format": "uint64" + } + } + }, "v1Query": { "type": "object", "properties": { @@ -1973,6 +2082,19 @@ } } }, + "v1Snapshot": { + "type": "object", + "properties": { + "lastIndex": { + "type": "string", + "format": "uint64" + }, + "lastTerm": { + "type": "string", + "format": "uint64" + } + } + }, "v1StackTraceSelector": { "type": "object", "properties": { @@ -2016,6 +2138,27 @@ ], "default": "MERGE_FORMAT_UNSPECIFIED" }, + "v1State": { + "type": "string", + "enum": [ + "Follower", + "Candidate", + "Leader", + "Shutdown" + ], + "default": "Follower", + "description": "State values are chosen to match the Hashicorp Raft library states. See:\nhttps://github.com/hashicorp/raft/blob/42d34464b2d203e389e11ed6d43db698792c0604/state.go#L15-L27." + }, + "v1Suffrage": { + "type": "string", + "enum": [ + "Voter", + "NonVoter", + "Staging" + ], + "default": "Voter", + "description": "Suffrage values are chosen to match the Hashicorp Raft library suffrage\nvalues. See:\nhttps://github.com/hashicorp/raft/blob/42d34464b2d203e389e11ed6d43db698792c0604/configuration.go#L12-L24." + }, "v1TimeSeriesAggregationType": { "type": "string", "enum": [ diff --git a/cmd/profilecli/main.go b/cmd/profilecli/main.go index f88f69424c..05ad4a4ba0 100644 --- a/cmd/profilecli/main.go +++ b/cmd/profilecli/main.go @@ -92,6 +92,10 @@ func main() { readyCmd := app.Command("ready", "Check Pyroscope health.") readyParams := addReadyParams(readyCmd) + raftCmd := adminCmd.Command("raft", "Operate on Raft cluster.") + raftInfoCmd := raftCmd.Command("info", "Print info about a Raft node.") + raftInfoParams := addRaftInfoParams(raftInfoCmd) + // parse command line arguments parsedCmd := kingpin.MustParse(app.Parse(os.Args[1:])) @@ -158,6 +162,10 @@ func main() { if err := ready(ctx, readyParams); err != nil { os.Exit(checkError(err)) } + case raftInfoCmd.FullCommand(): + if err := raftInfo(ctx, raftInfoParams); err != nil { + os.Exit(checkError(err)) + } default: level.Error(logger).Log("msg", "unknown command", "cmd", parsedCmd) } diff --git a/cmd/profilecli/raft.go b/cmd/profilecli/raft.go new file mode 100644 index 0000000000..e87845db2b --- /dev/null +++ b/cmd/profilecli/raft.go @@ -0,0 +1,158 @@ +package main + +import ( + "context" + "fmt" + "strings" + "time" + + "connectrpc.com/connect" + "google.golang.org/protobuf/encoding/protojson" + + metastorev1 "github.com/grafana/pyroscope/api/gen/proto/go/metastore/v1" + "github.com/grafana/pyroscope/api/gen/proto/go/metastore/v1/metastorev1connect" + connectapi "github.com/grafana/pyroscope/pkg/api/connect" +) + +func (c *phlareClient) metadataOperatorClient() metastorev1connect.OperatorServiceClient { + return metastorev1connect.NewOperatorServiceClient( + c.httpClient(), + c.URL, + append( + connectapi.DefaultClientOptions(), + c.protocolOption(), + )..., + ) +} + +type raftInfoParams struct { + *phlareClient + + HumanFormat bool +} + +func addRaftInfoParams(cmd commander) *raftInfoParams { + params := &raftInfoParams{} + params.phlareClient = addPhlareClient(cmd) + + cmd.Flag("human", "Human readable output").Short('H').BoolVar(¶ms.HumanFormat) + + return params +} + +func raftInfo(ctx context.Context, params *raftInfoParams) error { + client := params.phlareClient.metadataOperatorClient() + + res, err := client.Info(ctx, connect.NewRequest(&metastorev1.InfoRequest{})) + if err != nil { + return err + } + + var s string + switch { + case params.HumanFormat: + s = formatHumanRaftInfo(res.Msg) + default: + s, err = formatJSONRaftInfo(res.Msg) + if err != nil { + return err + } + } + + fmt.Println(s) + return nil +} + +func formatHumanRaftInfo(res *metastorev1.InfoResponse) string { + maxKeyPadding := func(keys []string) int { + max := 0 + for _, k := range keys { + if len(k) > max { + max = len(k) + } + } + return max + } + + appendPairs := func(sb *strings.Builder, pairs [][]string) { + keys := make([]string, 0, len(pairs)) + for _, pair := range pairs { + keys = append(keys, pair[0]) + } + + keyPadding := maxKeyPadding(keys) + for _, pair := range pairs { + key, value := pair[0], pair[1] + sb.WriteString(fmt.Sprintf("%s:", key)) + sb.WriteString(strings.Repeat(" ", keyPadding-len(key)+1)) + sb.WriteString(fmt.Sprintf("%s\n", value)) + } + } + + lastLeaderContact := "never" + if res.LastLeaderContact != 0 { + lastLeaderContact = time.UnixMilli(res.LastLeaderContact).Format(time.RFC3339) + } + + var sb strings.Builder + appendPairs(&sb, [][]string{ + {"ID", res.Id}, + {"State", res.State.String()}, + {"State verified", fmt.Sprint(res.IsStateVerified)}, + {"Leader ID", res.LeaderId}, + {"Last leader contact", lastLeaderContact}, + {"Term", fmt.Sprint(res.Term)}, + {"Suffrage", res.Suffrage.String()}, + }) + + sb.WriteString("Log:\n") + appendPairs(&sb, [][]string{ + {" Commit index", fmt.Sprint(res.Log.CommitIndex)}, + {" Applied index", fmt.Sprint(res.Log.AppliedIndex)}, + {" Last index", fmt.Sprint(res.Log.LastIndex)}, + {" FSM pending length", fmt.Sprint(res.Log.FsmPendingLength)}, + }) + + sb.WriteString("Snapshot:\n") + appendPairs(&sb, [][]string{ + {" Last index", fmt.Sprint(res.Snapshot.LastIndex)}, + {" Last term", fmt.Sprint(res.Snapshot.LastTerm)}, + }) + + sb.WriteString("Protocol:\n") + appendPairs(&sb, [][]string{ + {" Version", fmt.Sprint(res.Protocol.Version)}, + {" Min version", fmt.Sprint(res.Protocol.MinVersion)}, + {" Max version", fmt.Sprint(res.Protocol.MaxVersion)}, + {" Min snapshot version", fmt.Sprint(res.Protocol.MinSnapshotVersion)}, + {" Max snapshot version", fmt.Sprint(res.Protocol.MaxSnapshotVersion)}, + }) + + sb.WriteString("Peers:\n") + for _, peer := range res.Peers { + appendPairs(&sb, [][]string{ + {" ID", peer.Id}, + {" Address", peer.Address}, + {" Suffrage", peer.Suffrage.String()}, + }) + sb.WriteString("\n") // Give some space between entries. + } + + return strings.TrimSpace(sb.String()) +} + +func formatJSONRaftInfo(msg *metastorev1.InfoResponse) (string, error) { + // Pretty print the protobuf json and don't omit default values. + opts := protojson.MarshalOptions{ + Multiline: true, + Indent: " ", + EmitUnpopulated: true, + } + + bytes, err := opts.Marshal(msg.CloneMessageVT()) + if err != nil { + return "", err + } + + return string(bytes), nil +} diff --git a/pkg/api/api_experimental.go b/pkg/api/api_experimental.go index aa03eb6edb..7e52792a41 100644 --- a/pkg/api/api_experimental.go +++ b/pkg/api/api_experimental.go @@ -5,6 +5,7 @@ import ( compactorv1 "github.com/grafana/pyroscope/api/gen/proto/go/compactor/v1" metastorev1 "github.com/grafana/pyroscope/api/gen/proto/go/metastore/v1" + "github.com/grafana/pyroscope/api/gen/proto/go/metastore/v1/metastorev1connect" queryv1 "github.com/grafana/pyroscope/api/gen/proto/go/query/v1" segmentwriterv1 "github.com/grafana/pyroscope/api/gen/proto/go/segmentwriter/v1" segmentwriter "github.com/grafana/pyroscope/pkg/experiment/ingester" @@ -28,6 +29,7 @@ func (a *API) RegisterSegmentWriterRing(r http.Handler) { func (a *API) RegisterMetastore(svc *metastore.Metastore) { metastorev1.RegisterMetastoreServiceServer(a.server.GRPC, svc) + metastorev1connect.RegisterOperatorServiceHandler(a.server.HTTP, svc) compactorv1.RegisterCompactionPlannerServer(a.server.GRPC, svc) } diff --git a/pkg/experiment/metastore/client/client.go b/pkg/experiment/metastore/client/client.go index de2a7b7b44..5b8f83f6b8 100644 --- a/pkg/experiment/metastore/client/client.go +++ b/pkg/experiment/metastore/client/client.go @@ -7,7 +7,7 @@ import ( "github.com/grafana/dskit/grpcclient" "github.com/grafana/dskit/services" - "github.com/opentracing-contrib/go-grpc" + otgrpc "github.com/opentracing-contrib/go-grpc" "github.com/opentracing/opentracing-go" "google.golang.org/grpc" diff --git a/pkg/experiment/metastore/metastore.go b/pkg/experiment/metastore/metastore.go index 4665ab8c80..df5427ca7a 100644 --- a/pkg/experiment/metastore/metastore.go +++ b/pkg/experiment/metastore/metastore.go @@ -24,7 +24,7 @@ import ( compactorv1 "github.com/grafana/pyroscope/api/gen/proto/go/compactor/v1" metastorev1 "github.com/grafana/pyroscope/api/gen/proto/go/metastore/v1" - "github.com/grafana/pyroscope/pkg/experiment/metastore/client" + metastoreclient "github.com/grafana/pyroscope/pkg/experiment/metastore/client" "github.com/grafana/pyroscope/pkg/experiment/metastore/raftleader" "github.com/grafana/pyroscope/pkg/util/health" ) @@ -100,6 +100,7 @@ func (cfg *RaftConfig) Validate() error { type Metastore struct { service services.Service metastorev1.MetastoreServiceServer + metastorev1.OperatorServiceServer compactorv1.CompactionPlannerServer config Config diff --git a/pkg/experiment/metastore/metastore_operator.go b/pkg/experiment/metastore/metastore_operator.go new file mode 100644 index 0000000000..e0618b72c1 --- /dev/null +++ b/pkg/experiment/metastore/metastore_operator.go @@ -0,0 +1,97 @@ +package metastore + +import ( + "context" + "strconv" + + "connectrpc.com/connect" + "github.com/hashicorp/raft" + + metastorev1 "github.com/grafana/pyroscope/api/gen/proto/go/metastore/v1" +) + +func (m *Metastore) Info(_ context.Context, _ *connect.Request[metastorev1.InfoRequest]) (*connect.Response[metastorev1.InfoResponse], error) { + cfgFuture := m.raft.GetConfiguration() + err := cfgFuture.Error() + if err != nil { + return nil, err + } + + cfg := cfgFuture.Configuration() + _, leaderID := m.raft.LeaderWithID() + stats := m.raft.Stats() + + res := &metastorev1.InfoResponse{ + Id: m.config.Raft.ServerID, + State: metastorev1.State(m.raft.State()), + LeaderId: string(leaderID), + Term: getUint64(stats, "term"), + Log: &metastorev1.Log{ + CommitIndex: m.raft.CommitIndex(), + AppliedIndex: m.raft.AppliedIndex(), + LastIndex: m.raft.LastIndex(), + FsmPendingLength: getUint64(stats, "fsm_pending"), + }, + Snapshot: &metastorev1.Snapshot{ + LastIndex: getUint64(stats, "snapshot_last_index"), + LastTerm: getUint64(stats, "last_snapshot_term"), + }, + Protocol: &metastorev1.Protocol{ + Version: getUint64(stats, "protocol_version"), + MinVersion: getUint64(stats, "protocol_max_version"), + MaxVersion: getUint64(stats, "protocol_min_version"), + MinSnapshotVersion: getUint64(stats, "snapshot_version_max"), + MaxSnapshotVersion: getUint64(stats, "snapshot_version_min"), + }, + } + + // Perform a more reliable leader check to verify if this node is indeed a + // leader. A node may report itself as a leader, but not be a leader by + // consensus of the cluster. + leaderErr := m.raft.VerifyLeader().Error() + + switch m.raft.State() { + case raft.Leader: + res.LastLeaderContact = 0 + res.IsStateVerified = leaderErr == nil + default: + res.LastLeaderContact = m.raft.LastContact().UnixMilli() + res.IsStateVerified = leaderErr == raft.ErrNotLeader + } + + if len(cfg.Servers) > 1 { + res.Peers = make([]*metastorev1.Peer, 0, len(cfg.Servers)-1) + for _, server := range cfg.Servers { + if string(server.ID) == m.config.Raft.ServerID || string(server.Address) == m.config.Raft.ServerID { + res.Suffrage = metastorev1.Suffrage(server.Suffrage) + continue + } + + res.Peers = append(res.Peers, &metastorev1.Peer{ + Id: string(server.ID), + Address: string(server.Address), + Suffrage: metastorev1.Suffrage(server.Suffrage), + }) + } + } else { + res.Peers = []*metastorev1.Peer{} + } + + return connect.NewResponse(res), nil +} + +// getUint64 tries to get a uint64 value from a map. If the key does not exist +// or the value is not a valid uint64, it returns 0. +func getUint64(m map[string]string, key string) uint64 { + value, ok := m[key] + if !ok { + return 0 + } + + u, err := strconv.ParseUint(value, 10, 64) + if err != nil { + return 0 + } + + return u +} diff --git a/tools/dev/experiment/values-micro-services-experiment.yaml b/tools/dev/experiment/values-micro-services-experiment.yaml index 6c4649886f..63e3668d6a 100644 --- a/tools/dev/experiment/values-micro-services-experiment.yaml +++ b/tools/dev/experiment/values-micro-services-experiment.yaml @@ -67,5 +67,11 @@ pyroscope: mountPath: /data-compaction-worker subPath: compaction-worker + # TODO(bryan) Remove this once we eliminate the need for the query + # scheduler in v2. + query-scheduler: + kind: Deployment + replicaCount: 1 + minio: enabled: true