diff --git a/cmd/common.go b/cmd/common.go index 381cbc81..843a3299 100644 --- a/cmd/common.go +++ b/cmd/common.go @@ -157,6 +157,7 @@ func setupDragonboatLogger(logger *zap.Logger) { var secretConfigs = []string{ "maintenance.token", + "tables.token", } func viperConfigReader() map[string]any { diff --git a/cmd/flags.go b/cmd/flags.go index 04423e8e..b9b3a678 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -19,6 +19,7 @@ var ( memberlistFlagSet = pflag.NewFlagSet("memberlist", pflag.ContinueOnError) storageFlagSet = pflag.NewFlagSet("storage", pflag.ContinueOnError) maintenanceFlagSet = pflag.NewFlagSet("maintenance", pflag.ContinueOnError) + tablesFlagSet = pflag.NewFlagSet("tables", pflag.ContinueOnError) experimentalFlagSet = pflag.NewFlagSet("experimental", pflag.ContinueOnError) ) @@ -106,6 +107,10 @@ All nodes of the cluster MUST set this to the same value. If changing it is advi // Maintenance flags maintenanceFlagSet.Bool("maintenance.enabled", true, "Whether maintenance API is enabled.") maintenanceFlagSet.String("maintenance.token", "", "Token to check for maintenance API access, if left empty (default) no token is checked.") + + // Tables flags + tablesFlagSet.Bool("tables.enabled", true, "Whether tables API is enabled.") + tablesFlagSet.String("tables.token", "", "Token to check for tables API access, if left empty (default) no token is checked.") } func initConfig(set *pflag.FlagSet) { diff --git a/cmd/follower.go b/cmd/follower.go index 57d37533..0d4ab93c 100644 --- a/cmd/follower.go +++ b/cmd/follower.go @@ -39,6 +39,7 @@ func init() { followerCmd.PersistentFlags().AddFlagSet(memberlistFlagSet) followerCmd.PersistentFlags().AddFlagSet(storageFlagSet) followerCmd.PersistentFlags().AddFlagSet(maintenanceFlagSet) + followerCmd.PersistentFlags().AddFlagSet(tablesFlagSet) followerCmd.PersistentFlags().AddFlagSet(experimentalFlagSet) // Replication flags @@ -203,6 +204,9 @@ func follower(_ *cobra.Command, _ []string) error { if viper.GetBool("maintenance.enabled") { regattapb.RegisterMaintenanceServer(regatta, ®attaserver.ResetServer{Tables: engine, AuthFunc: authFunc(viper.GetString("maintenance.token"))}) } + if viper.GetBool("tables.enabled") { + regattapb.RegisterTablesServer(regatta, ®attaserver.ReadonlyTablesServer{TablesServer: regattaserver.TablesServer{Tables: engine, AuthFunc: authFunc(viper.GetString("tables.token"))}}) + } // Start server go func() { if err := regatta.ListenAndServe(); err != nil { diff --git a/cmd/leader.go b/cmd/leader.go index faabbe2e..73c27310 100644 --- a/cmd/leader.go +++ b/cmd/leader.go @@ -39,11 +39,14 @@ func init() { leaderCmd.PersistentFlags().AddFlagSet(memberlistFlagSet) leaderCmd.PersistentFlags().AddFlagSet(storageFlagSet) leaderCmd.PersistentFlags().AddFlagSet(maintenanceFlagSet) + leaderCmd.PersistentFlags().AddFlagSet(tablesFlagSet) leaderCmd.PersistentFlags().AddFlagSet(experimentalFlagSet) // Tables flags leaderCmd.PersistentFlags().StringSlice("tables.names", nil, "Create Regatta tables with given names.") leaderCmd.PersistentFlags().StringSlice("tables.delete", nil, "Delete Regatta tables with given names.") + _ = leaderCmd.PersistentFlags().MarkHidden("tables.names") + _ = leaderCmd.PersistentFlags().MarkHidden("tables.delete") // Replication flags leaderCmd.PersistentFlags().Bool("replication.enabled", true, "Whether replication API is enabled.") @@ -161,7 +164,7 @@ func leader(_ *cobra.Command, _ []string) error { tNames := viper.GetStringSlice("tables.names") for _, table := range tNames { log.Debugf("creating table %s", table) - if err := engine.CreateTable(table); err != nil { + if _, err := engine.CreateTable(table); err != nil { if errors.Is(err, serrors.ErrTableExists) { log.Infof("table %s already exist, skipping creation", table) } else { @@ -194,6 +197,9 @@ func leader(_ *cobra.Command, _ []string) error { Cluster: engine, Config: viperConfigReader, }) + if viper.GetBool("tables.enabled") { + regattapb.RegisterTablesServer(regatta, ®attaserver.TablesServer{Tables: engine, AuthFunc: authFunc(viper.GetString("tables.token"))}) + } if viper.GetBool("maintenance.enabled") { regattapb.RegisterMaintenanceServer(regatta, ®attaserver.BackupServer{Tables: engine, AuthFunc: authFunc(viper.GetString("maintenance.token"))}) } @@ -213,7 +219,7 @@ func leader(_ *cobra.Command, _ []string) error { return fmt.Errorf("failed to create Replication server: %w", err) } ls := regattaserver.NewLogServer( - engine.Manager, + engine, engine.LogReader, logger, viper.GetUint64("replication.max-send-message-size-bytes"), diff --git a/docs/api.md b/docs/api.md index 2ad0e3cd..e34b16cd 100644 --- a/docs/api.md +++ b/docs/api.md @@ -444,6 +444,57 @@ and generates events with the same revision for every completed request. It is allowed to modify the same key several times within one txn (the result will be the last Op that modified the key). +# Tables {#regattav1tables} +API for managing tables. +## Create +> **rpc** Create([CreateTableRequest](#createtablerequest)) + [CreateTableResponse](#createtableresponse) + +Create a table. All followers will automatically replicate the table. +This procedure is available only in the leader cluster. + +## Delete +> **rpc** Delete([DeleteTableRequest](#deletetablerequest)) + [DeleteTableResponse](#deletetableresponse) + +Delete a table. All followers will automatically delete the table. +This procedure is available only in the leader cluster. + +## List +> **rpc** List([ListTablesRequest](#listtablesrequest)) + [ListTablesResponse](#listtablesresponse) + +Get names of all the tables present in the cluster. +This procedure is available in both leader and follower clusters. + + + + + + +### CreateTableRequest +CreateTableRequest describes the table to be created. + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| name | [string](#string) | | Name of the table to be created. | +| config | [google.protobuf.Struct](#google-protobuf-Struct) | | config the table configuration values. | + + + + + + + +### CreateTableResponse +CreateTableResponse describes the newly created table. + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| id | [string](#string) | | id the created table. | + + + @@ -479,6 +530,48 @@ It is allowed to modify the same key several times within one txn (the result wi + +### DeleteTableRequest +DeleteTableRequest describes the table to be deleted. + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| name | [string](#string) | | name of the table to be deleted. | + + + + + + + +### DeleteTableResponse +DeleteTableResponse when the table was successfully deleted. + + + + + + +### ListTablesRequest +ListTablesRequest requests the list of currently registered tables. + + + + + + +### ListTablesResponse +FollowerGetTablesResponse contains information about tables stored in the cluster. + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| tables | [TableInfo](#regatta-v1-TableInfo) | repeated | | + + + + + + ### Member @@ -648,6 +741,21 @@ It is allowed to modify the same key several times within one txn (the result wi + +### TableInfo +TableInfo describes a single table. + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| name | [string](#string) | | name of the table. | +| id | [string](#string) | | id of the table. | +| config | [google.protobuf.Struct](#google-protobuf-Struct) | | config the table configuration values. | + + + + + + ### TableStatus diff --git a/docs/operations_guide/cli/regatta_follower.md b/docs/operations_guide/cli/regatta_follower.md index 6e043c34..fcfd439a 100644 --- a/docs/operations_guide/cli/regatta_follower.md +++ b/docs/operations_guide/cli/regatta_follower.md @@ -88,6 +88,8 @@ regatta follower [flags] --rest.read-timeout duration Maximum duration for reading the entire request. (default 5s) --storage.block-cache-size int Shared block cache size in bytes, the cache is used to hold uncompressed blocks of data in memory. (default 16777216) --storage.table-cache-size int Shared table cache size, the cache is used to hold handles to open SSTs. (default 1024) + --tables.enabled Whether tables API is enabled. (default true) + --tables.token string Token to check for tables API access, if left empty (default) no token is checked. ``` ### SEE ALSO diff --git a/docs/operations_guide/cli/regatta_leader.md b/docs/operations_guide/cli/regatta_leader.md index 084bbe00..43a1c525 100644 --- a/docs/operations_guide/cli/regatta_leader.md +++ b/docs/operations_guide/cli/regatta_leader.md @@ -82,8 +82,8 @@ regatta leader [flags] --rest.read-timeout duration Maximum duration for reading the entire request. (default 5s) --storage.block-cache-size int Shared block cache size in bytes, the cache is used to hold uncompressed blocks of data in memory. (default 16777216) --storage.table-cache-size int Shared table cache size, the cache is used to hold handles to open SSTs. (default 1024) - --tables.delete strings Delete Regatta tables with given names. - --tables.names strings Create Regatta tables with given names. + --tables.enabled Whether tables API is enabled. (default true) + --tables.token string Token to check for tables API access, if left empty (default) no token is checked. ``` ### SEE ALSO diff --git a/proto/regatta.proto b/proto/regatta.proto index 1cc5ddb1..8fe024e6 100644 --- a/proto/regatta.proto +++ b/proto/regatta.proto @@ -197,7 +197,6 @@ service Cluster { // Status gets the status of the member. rpc Status(StatusRequest) returns (StatusResponse); - } message MemberListRequest {} @@ -254,3 +253,62 @@ message StatusResponse { // errors contains alarm/health information and status. repeated string errors = 8; } + + +// API for managing tables. +service Tables { + // Create a table. All followers will automatically replicate the table. + // This procedure is available only in the leader cluster. + rpc Create(CreateTableRequest) returns (CreateTableResponse); + + // Delete a table. All followers will automatically delete the table. + // This procedure is available only in the leader cluster. + rpc Delete(DeleteTableRequest) returns (DeleteTableResponse); + + // Get names of all the tables present in the cluster. + // This procedure is available in both leader and follower clusters. + rpc List(ListTablesRequest) returns (ListTablesResponse); +} + +// CreateTableRequest describes the table to be created. +message CreateTableRequest { + // Name of the table to be created. + string name = 1; + // config the table configuration values. + google.protobuf.Struct config = 5; +} + +// CreateTableResponse describes the newly created table. +message CreateTableResponse { + // id the created table. + string id = 1; +} + +// DeleteTableRequest describes the table to be deleted. +message DeleteTableRequest { + // name of the table to be deleted. + string name = 1; +} + +// DeleteTableResponse when the table was successfully deleted. +message DeleteTableResponse {} + +// ListTablesRequest requests the list of currently registered tables. +message ListTablesRequest {} + +// TableInfo describes a single table. +message TableInfo { + // name of the table. + string name = 1; + + // id of the table. + string id = 2; + + // config the table configuration values. + google.protobuf.Struct config = 5; +} + +// FollowerGetTablesResponse contains information about tables stored in the cluster. +message ListTablesResponse { + repeated TableInfo tables = 1; +} diff --git a/regattapb/regatta.pb.go b/regattapb/regatta.pb.go index 9050430a..9cdc1cf4 100644 --- a/regattapb/regatta.pb.go +++ b/regattapb/regatta.pb.go @@ -1188,6 +1188,355 @@ func (x *StatusResponse) GetErrors() []string { return nil } +// CreateTableRequest describes the table to be created. +type CreateTableRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Name of the table to be created. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // config the table configuration values. + Config *structpb.Struct `protobuf:"bytes,5,opt,name=config,proto3" json:"config,omitempty"` +} + +func (x *CreateTableRequest) Reset() { + *x = CreateTableRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_regatta_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateTableRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateTableRequest) ProtoMessage() {} + +func (x *CreateTableRequest) ProtoReflect() protoreflect.Message { + mi := &file_regatta_proto_msgTypes[15] + 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 CreateTableRequest.ProtoReflect.Descriptor instead. +func (*CreateTableRequest) Descriptor() ([]byte, []int) { + return file_regatta_proto_rawDescGZIP(), []int{15} +} + +func (x *CreateTableRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *CreateTableRequest) GetConfig() *structpb.Struct { + if x != nil { + return x.Config + } + return nil +} + +// CreateTableResponse describes the newly created table. +type CreateTableResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // id the created table. + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *CreateTableResponse) Reset() { + *x = CreateTableResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_regatta_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateTableResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateTableResponse) ProtoMessage() {} + +func (x *CreateTableResponse) ProtoReflect() protoreflect.Message { + mi := &file_regatta_proto_msgTypes[16] + 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 CreateTableResponse.ProtoReflect.Descriptor instead. +func (*CreateTableResponse) Descriptor() ([]byte, []int) { + return file_regatta_proto_rawDescGZIP(), []int{16} +} + +func (x *CreateTableResponse) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +// DeleteTableRequest describes the table to be deleted. +type DeleteTableRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // name of the table to be deleted. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *DeleteTableRequest) Reset() { + *x = DeleteTableRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_regatta_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteTableRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteTableRequest) ProtoMessage() {} + +func (x *DeleteTableRequest) ProtoReflect() protoreflect.Message { + mi := &file_regatta_proto_msgTypes[17] + 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 DeleteTableRequest.ProtoReflect.Descriptor instead. +func (*DeleteTableRequest) Descriptor() ([]byte, []int) { + return file_regatta_proto_rawDescGZIP(), []int{17} +} + +func (x *DeleteTableRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +// DeleteTableResponse when the table was successfully deleted. +type DeleteTableResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *DeleteTableResponse) Reset() { + *x = DeleteTableResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_regatta_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteTableResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteTableResponse) ProtoMessage() {} + +func (x *DeleteTableResponse) ProtoReflect() protoreflect.Message { + mi := &file_regatta_proto_msgTypes[18] + 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 DeleteTableResponse.ProtoReflect.Descriptor instead. +func (*DeleteTableResponse) Descriptor() ([]byte, []int) { + return file_regatta_proto_rawDescGZIP(), []int{18} +} + +// ListTablesRequest requests the list of currently registered tables. +type ListTablesRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ListTablesRequest) Reset() { + *x = ListTablesRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_regatta_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListTablesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListTablesRequest) ProtoMessage() {} + +func (x *ListTablesRequest) ProtoReflect() protoreflect.Message { + mi := &file_regatta_proto_msgTypes[19] + 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 ListTablesRequest.ProtoReflect.Descriptor instead. +func (*ListTablesRequest) Descriptor() ([]byte, []int) { + return file_regatta_proto_rawDescGZIP(), []int{19} +} + +// TableInfo describes a single table. +type TableInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // name of the table. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // id of the table. + Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` + // config the table configuration values. + Config *structpb.Struct `protobuf:"bytes,5,opt,name=config,proto3" json:"config,omitempty"` +} + +func (x *TableInfo) Reset() { + *x = TableInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_regatta_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TableInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TableInfo) ProtoMessage() {} + +func (x *TableInfo) ProtoReflect() protoreflect.Message { + mi := &file_regatta_proto_msgTypes[20] + 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 TableInfo.ProtoReflect.Descriptor instead. +func (*TableInfo) Descriptor() ([]byte, []int) { + return file_regatta_proto_rawDescGZIP(), []int{20} +} + +func (x *TableInfo) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *TableInfo) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *TableInfo) GetConfig() *structpb.Struct { + if x != nil { + return x.Config + } + return nil +} + +// FollowerGetTablesResponse contains information about tables stored in the cluster. +type ListTablesResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Tables []*TableInfo `protobuf:"bytes,1,rep,name=tables,proto3" json:"tables,omitempty"` +} + +func (x *ListTablesResponse) Reset() { + *x = ListTablesResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_regatta_proto_msgTypes[21] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListTablesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListTablesResponse) ProtoMessage() {} + +func (x *ListTablesResponse) ProtoReflect() protoreflect.Message { + mi := &file_regatta_proto_msgTypes[21] + 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 ListTablesResponse.ProtoReflect.Descriptor instead. +func (*ListTablesResponse) Descriptor() ([]byte, []int) { + return file_regatta_proto_rawDescGZIP(), []int{21} +} + +func (x *ListTablesResponse) GetTables() []*TableInfo { + if x != nil { + return x.Tables + } + return nil +} + var File_regatta_proto protoreflect.FileDescriptor var file_regatta_proto_rawDesc = []byte{ @@ -1337,39 +1686,78 @@ var file_regatta_proto_rawDesc = []byte{ 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2d, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x72, 0x65, 0x67, 0x61, 0x74, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x32, - 0xc9, 0x02, 0x0a, 0x02, 0x4b, 0x56, 0x12, 0x3c, 0x0a, 0x05, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x12, - 0x18, 0x2e, 0x72, 0x65, 0x67, 0x61, 0x74, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x61, 0x6e, - 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x65, 0x67, 0x61, - 0x74, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x45, 0x0a, 0x0c, 0x49, 0x74, 0x65, 0x72, 0x61, 0x74, 0x65, 0x52, - 0x61, 0x6e, 0x67, 0x65, 0x12, 0x18, 0x2e, 0x72, 0x65, 0x67, 0x61, 0x74, 0x74, 0x61, 0x2e, 0x76, - 0x31, 0x2e, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, + 0x61, 0x74, 0x75, 0x73, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, + 0x59, 0x0a, 0x12, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2f, 0x0a, 0x06, 0x63, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, + 0x63, 0x74, 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0x25, 0x0a, 0x13, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, + 0x64, 0x22, 0x28, 0x0a, 0x12, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x62, 0x6c, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x15, 0x0a, 0x13, 0x44, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x13, 0x0a, 0x11, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x60, 0x0a, 0x09, 0x54, 0x61, 0x62, 0x6c, 0x65, + 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x2f, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, + 0x74, 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0x43, 0x0a, 0x12, 0x4c, 0x69, 0x73, + 0x74, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x2d, 0x0a, 0x06, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x15, 0x2e, 0x72, 0x65, 0x67, 0x61, 0x74, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x61, 0x62, + 0x6c, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x06, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x32, 0xc9, + 0x02, 0x0a, 0x02, 0x4b, 0x56, 0x12, 0x3c, 0x0a, 0x05, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x18, 0x2e, 0x72, 0x65, 0x67, 0x61, 0x74, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x61, 0x6e, 0x67, - 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x36, 0x0a, 0x03, 0x50, - 0x75, 0x74, 0x12, 0x16, 0x2e, 0x72, 0x65, 0x67, 0x61, 0x74, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, - 0x50, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x65, 0x67, - 0x61, 0x74, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x4e, 0x0a, 0x0b, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x61, 0x6e, - 0x67, 0x65, 0x12, 0x1e, 0x2e, 0x72, 0x65, 0x67, 0x61, 0x74, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, - 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x72, 0x65, 0x67, 0x61, 0x74, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, - 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x36, 0x0a, 0x03, 0x54, 0x78, 0x6e, 0x12, 0x16, 0x2e, 0x72, 0x65, 0x67, - 0x61, 0x74, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x78, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x65, 0x67, 0x61, 0x74, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, - 0x54, 0x78, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x97, 0x01, 0x0a, 0x07, - 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x12, 0x4b, 0x0a, 0x0a, 0x4d, 0x65, 0x6d, 0x62, 0x65, - 0x72, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1d, 0x2e, 0x72, 0x65, 0x67, 0x61, 0x74, 0x74, 0x61, 0x2e, - 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x72, 0x65, 0x67, 0x61, 0x74, 0x74, 0x61, 0x2e, 0x76, - 0x31, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3f, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x19, - 0x2e, 0x72, 0x65, 0x67, 0x61, 0x74, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x65, 0x67, 0x61, - 0x74, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0d, 0x5a, 0x0b, 0x2e, 0x2f, 0x72, 0x65, 0x67, 0x61, 0x74, - 0x74, 0x61, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x65, 0x67, 0x61, 0x74, + 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x45, 0x0a, 0x0c, 0x49, 0x74, 0x65, 0x72, 0x61, 0x74, 0x65, 0x52, 0x61, + 0x6e, 0x67, 0x65, 0x12, 0x18, 0x2e, 0x72, 0x65, 0x67, 0x61, 0x74, 0x74, 0x61, 0x2e, 0x76, 0x31, + 0x2e, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, + 0x72, 0x65, 0x67, 0x61, 0x74, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x61, 0x6e, 0x67, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x36, 0x0a, 0x03, 0x50, 0x75, + 0x74, 0x12, 0x16, 0x2e, 0x72, 0x65, 0x67, 0x61, 0x74, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x50, + 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x65, 0x67, 0x61, + 0x74, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x4e, 0x0a, 0x0b, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x61, 0x6e, 0x67, + 0x65, 0x12, 0x1e, 0x2e, 0x72, 0x65, 0x67, 0x61, 0x74, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x44, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x1f, 0x2e, 0x72, 0x65, 0x67, 0x61, 0x74, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x44, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x36, 0x0a, 0x03, 0x54, 0x78, 0x6e, 0x12, 0x16, 0x2e, 0x72, 0x65, 0x67, 0x61, + 0x74, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x78, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x65, 0x67, 0x61, 0x74, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x54, + 0x78, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x97, 0x01, 0x0a, 0x07, 0x43, + 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x12, 0x4b, 0x0a, 0x0a, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, + 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1d, 0x2e, 0x72, 0x65, 0x67, 0x61, 0x74, 0x74, 0x61, 0x2e, 0x76, + 0x31, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x72, 0x65, 0x67, 0x61, 0x74, 0x74, 0x61, 0x2e, 0x76, 0x31, + 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x3f, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x19, 0x2e, + 0x72, 0x65, 0x67, 0x61, 0x74, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x65, 0x67, 0x61, 0x74, + 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xe5, 0x01, 0x0a, 0x06, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x12, + 0x49, 0x0a, 0x06, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x1e, 0x2e, 0x72, 0x65, 0x67, 0x61, + 0x74, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x61, 0x62, + 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x72, 0x65, 0x67, 0x61, + 0x74, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x61, 0x62, + 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x49, 0x0a, 0x06, 0x44, 0x65, + 0x6c, 0x65, 0x74, 0x65, 0x12, 0x1e, 0x2e, 0x72, 0x65, 0x67, 0x61, 0x74, 0x74, 0x61, 0x2e, 0x76, + 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x72, 0x65, 0x67, 0x61, 0x74, 0x74, 0x61, 0x2e, 0x76, + 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x45, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1d, 0x2e, + 0x72, 0x65, 0x67, 0x61, 0x74, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, + 0x61, 0x62, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x72, + 0x65, 0x67, 0x61, 0x74, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x61, + 0x62, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0d, 0x5a, 0x0b, + 0x2e, 0x2f, 0x72, 0x65, 0x67, 0x61, 0x74, 0x74, 0x61, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -1384,7 +1772,7 @@ func file_regatta_proto_rawDescGZIP() []byte { return file_regatta_proto_rawDescData } -var file_regatta_proto_msgTypes = make([]protoimpl.MessageInfo, 16) +var file_regatta_proto_msgTypes = make([]protoimpl.MessageInfo, 23) var file_regatta_proto_goTypes = []interface{}{ (*ResponseHeader)(nil), // 0: regatta.v1.ResponseHeader (*RangeRequest)(nil), // 1: regatta.v1.RangeRequest @@ -1401,48 +1789,64 @@ var file_regatta_proto_goTypes = []interface{}{ (*TableStatus)(nil), // 12: regatta.v1.TableStatus (*StatusRequest)(nil), // 13: regatta.v1.StatusRequest (*StatusResponse)(nil), // 14: regatta.v1.StatusResponse - nil, // 15: regatta.v1.StatusResponse.TablesEntry - (*KeyValue)(nil), // 16: mvcc.v1.KeyValue - (*Compare)(nil), // 17: mvcc.v1.Compare - (*RequestOp)(nil), // 18: mvcc.v1.RequestOp - (*ResponseOp)(nil), // 19: mvcc.v1.ResponseOp - (*structpb.Struct)(nil), // 20: google.protobuf.Struct + (*CreateTableRequest)(nil), // 15: regatta.v1.CreateTableRequest + (*CreateTableResponse)(nil), // 16: regatta.v1.CreateTableResponse + (*DeleteTableRequest)(nil), // 17: regatta.v1.DeleteTableRequest + (*DeleteTableResponse)(nil), // 18: regatta.v1.DeleteTableResponse + (*ListTablesRequest)(nil), // 19: regatta.v1.ListTablesRequest + (*TableInfo)(nil), // 20: regatta.v1.TableInfo + (*ListTablesResponse)(nil), // 21: regatta.v1.ListTablesResponse + nil, // 22: regatta.v1.StatusResponse.TablesEntry + (*KeyValue)(nil), // 23: mvcc.v1.KeyValue + (*Compare)(nil), // 24: mvcc.v1.Compare + (*RequestOp)(nil), // 25: mvcc.v1.RequestOp + (*ResponseOp)(nil), // 26: mvcc.v1.ResponseOp + (*structpb.Struct)(nil), // 27: google.protobuf.Struct } var file_regatta_proto_depIdxs = []int32{ 0, // 0: regatta.v1.RangeResponse.header:type_name -> regatta.v1.ResponseHeader - 16, // 1: regatta.v1.RangeResponse.kvs:type_name -> mvcc.v1.KeyValue + 23, // 1: regatta.v1.RangeResponse.kvs:type_name -> mvcc.v1.KeyValue 0, // 2: regatta.v1.PutResponse.header:type_name -> regatta.v1.ResponseHeader - 16, // 3: regatta.v1.PutResponse.prev_kv:type_name -> mvcc.v1.KeyValue + 23, // 3: regatta.v1.PutResponse.prev_kv:type_name -> mvcc.v1.KeyValue 0, // 4: regatta.v1.DeleteRangeResponse.header:type_name -> regatta.v1.ResponseHeader - 16, // 5: regatta.v1.DeleteRangeResponse.prev_kvs:type_name -> mvcc.v1.KeyValue - 17, // 6: regatta.v1.TxnRequest.compare:type_name -> mvcc.v1.Compare - 18, // 7: regatta.v1.TxnRequest.success:type_name -> mvcc.v1.RequestOp - 18, // 8: regatta.v1.TxnRequest.failure:type_name -> mvcc.v1.RequestOp + 23, // 5: regatta.v1.DeleteRangeResponse.prev_kvs:type_name -> mvcc.v1.KeyValue + 24, // 6: regatta.v1.TxnRequest.compare:type_name -> mvcc.v1.Compare + 25, // 7: regatta.v1.TxnRequest.success:type_name -> mvcc.v1.RequestOp + 25, // 8: regatta.v1.TxnRequest.failure:type_name -> mvcc.v1.RequestOp 0, // 9: regatta.v1.TxnResponse.header:type_name -> regatta.v1.ResponseHeader - 19, // 10: regatta.v1.TxnResponse.responses:type_name -> mvcc.v1.ResponseOp + 26, // 10: regatta.v1.TxnResponse.responses:type_name -> mvcc.v1.ResponseOp 11, // 11: regatta.v1.MemberListResponse.members:type_name -> regatta.v1.Member - 15, // 12: regatta.v1.StatusResponse.tables:type_name -> regatta.v1.StatusResponse.TablesEntry - 20, // 13: regatta.v1.StatusResponse.config:type_name -> google.protobuf.Struct - 12, // 14: regatta.v1.StatusResponse.TablesEntry.value:type_name -> regatta.v1.TableStatus - 1, // 15: regatta.v1.KV.Range:input_type -> regatta.v1.RangeRequest - 1, // 16: regatta.v1.KV.IterateRange:input_type -> regatta.v1.RangeRequest - 3, // 17: regatta.v1.KV.Put:input_type -> regatta.v1.PutRequest - 5, // 18: regatta.v1.KV.DeleteRange:input_type -> regatta.v1.DeleteRangeRequest - 7, // 19: regatta.v1.KV.Txn:input_type -> regatta.v1.TxnRequest - 9, // 20: regatta.v1.Cluster.MemberList:input_type -> regatta.v1.MemberListRequest - 13, // 21: regatta.v1.Cluster.Status:input_type -> regatta.v1.StatusRequest - 2, // 22: regatta.v1.KV.Range:output_type -> regatta.v1.RangeResponse - 2, // 23: regatta.v1.KV.IterateRange:output_type -> regatta.v1.RangeResponse - 4, // 24: regatta.v1.KV.Put:output_type -> regatta.v1.PutResponse - 6, // 25: regatta.v1.KV.DeleteRange:output_type -> regatta.v1.DeleteRangeResponse - 8, // 26: regatta.v1.KV.Txn:output_type -> regatta.v1.TxnResponse - 10, // 27: regatta.v1.Cluster.MemberList:output_type -> regatta.v1.MemberListResponse - 14, // 28: regatta.v1.Cluster.Status:output_type -> regatta.v1.StatusResponse - 22, // [22:29] is the sub-list for method output_type - 15, // [15:22] is the sub-list for method input_type - 15, // [15:15] is the sub-list for extension type_name - 15, // [15:15] is the sub-list for extension extendee - 0, // [0:15] is the sub-list for field type_name + 22, // 12: regatta.v1.StatusResponse.tables:type_name -> regatta.v1.StatusResponse.TablesEntry + 27, // 13: regatta.v1.StatusResponse.config:type_name -> google.protobuf.Struct + 27, // 14: regatta.v1.CreateTableRequest.config:type_name -> google.protobuf.Struct + 27, // 15: regatta.v1.TableInfo.config:type_name -> google.protobuf.Struct + 20, // 16: regatta.v1.ListTablesResponse.tables:type_name -> regatta.v1.TableInfo + 12, // 17: regatta.v1.StatusResponse.TablesEntry.value:type_name -> regatta.v1.TableStatus + 1, // 18: regatta.v1.KV.Range:input_type -> regatta.v1.RangeRequest + 1, // 19: regatta.v1.KV.IterateRange:input_type -> regatta.v1.RangeRequest + 3, // 20: regatta.v1.KV.Put:input_type -> regatta.v1.PutRequest + 5, // 21: regatta.v1.KV.DeleteRange:input_type -> regatta.v1.DeleteRangeRequest + 7, // 22: regatta.v1.KV.Txn:input_type -> regatta.v1.TxnRequest + 9, // 23: regatta.v1.Cluster.MemberList:input_type -> regatta.v1.MemberListRequest + 13, // 24: regatta.v1.Cluster.Status:input_type -> regatta.v1.StatusRequest + 15, // 25: regatta.v1.Tables.Create:input_type -> regatta.v1.CreateTableRequest + 17, // 26: regatta.v1.Tables.Delete:input_type -> regatta.v1.DeleteTableRequest + 19, // 27: regatta.v1.Tables.List:input_type -> regatta.v1.ListTablesRequest + 2, // 28: regatta.v1.KV.Range:output_type -> regatta.v1.RangeResponse + 2, // 29: regatta.v1.KV.IterateRange:output_type -> regatta.v1.RangeResponse + 4, // 30: regatta.v1.KV.Put:output_type -> regatta.v1.PutResponse + 6, // 31: regatta.v1.KV.DeleteRange:output_type -> regatta.v1.DeleteRangeResponse + 8, // 32: regatta.v1.KV.Txn:output_type -> regatta.v1.TxnResponse + 10, // 33: regatta.v1.Cluster.MemberList:output_type -> regatta.v1.MemberListResponse + 14, // 34: regatta.v1.Cluster.Status:output_type -> regatta.v1.StatusResponse + 16, // 35: regatta.v1.Tables.Create:output_type -> regatta.v1.CreateTableResponse + 18, // 36: regatta.v1.Tables.Delete:output_type -> regatta.v1.DeleteTableResponse + 21, // 37: regatta.v1.Tables.List:output_type -> regatta.v1.ListTablesResponse + 28, // [28:38] is the sub-list for method output_type + 18, // [18:28] is the sub-list for method input_type + 18, // [18:18] is the sub-list for extension type_name + 18, // [18:18] is the sub-list for extension extendee + 0, // [0:18] is the sub-list for field type_name } func init() { file_regatta_proto_init() } @@ -1632,6 +2036,90 @@ func file_regatta_proto_init() { return nil } } + file_regatta_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateTableRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_regatta_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateTableResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_regatta_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteTableRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_regatta_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteTableResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_regatta_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListTablesRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_regatta_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TableInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_regatta_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListTablesResponse); 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{ @@ -1639,9 +2127,9 @@ func file_regatta_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_regatta_proto_rawDesc, NumEnums: 0, - NumMessages: 16, + NumMessages: 23, NumExtensions: 0, - NumServices: 2, + NumServices: 3, }, GoTypes: file_regatta_proto_goTypes, DependencyIndexes: file_regatta_proto_depIdxs, diff --git a/regattapb/regatta_grpc.pb.go b/regattapb/regatta_grpc.pb.go index 07fa81fa..651cf072 100644 --- a/regattapb/regatta_grpc.pb.go +++ b/regattapb/regatta_grpc.pb.go @@ -436,3 +436,179 @@ var Cluster_ServiceDesc = grpc.ServiceDesc{ Streams: []grpc.StreamDesc{}, Metadata: "regatta.proto", } + +const ( + Tables_Create_FullMethodName = "/regatta.v1.Tables/Create" + Tables_Delete_FullMethodName = "/regatta.v1.Tables/Delete" + Tables_List_FullMethodName = "/regatta.v1.Tables/List" +) + +// TablesClient is the client API for Tables 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 TablesClient interface { + // Create a table. All followers will automatically replicate the table. + // This procedure is available only in the leader cluster. + Create(ctx context.Context, in *CreateTableRequest, opts ...grpc.CallOption) (*CreateTableResponse, error) + // Delete a table. All followers will automatically delete the table. + // This procedure is available only in the leader cluster. + Delete(ctx context.Context, in *DeleteTableRequest, opts ...grpc.CallOption) (*DeleteTableResponse, error) + // Get names of all the tables present in the cluster. + // This procedure is available in both leader and follower clusters. + List(ctx context.Context, in *ListTablesRequest, opts ...grpc.CallOption) (*ListTablesResponse, error) +} + +type tablesClient struct { + cc grpc.ClientConnInterface +} + +func NewTablesClient(cc grpc.ClientConnInterface) TablesClient { + return &tablesClient{cc} +} + +func (c *tablesClient) Create(ctx context.Context, in *CreateTableRequest, opts ...grpc.CallOption) (*CreateTableResponse, error) { + out := new(CreateTableResponse) + err := c.cc.Invoke(ctx, Tables_Create_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *tablesClient) Delete(ctx context.Context, in *DeleteTableRequest, opts ...grpc.CallOption) (*DeleteTableResponse, error) { + out := new(DeleteTableResponse) + err := c.cc.Invoke(ctx, Tables_Delete_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *tablesClient) List(ctx context.Context, in *ListTablesRequest, opts ...grpc.CallOption) (*ListTablesResponse, error) { + out := new(ListTablesResponse) + err := c.cc.Invoke(ctx, Tables_List_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// TablesServer is the server API for Tables service. +// All implementations must embed UnimplementedTablesServer +// for forward compatibility +type TablesServer interface { + // Create a table. All followers will automatically replicate the table. + // This procedure is available only in the leader cluster. + Create(context.Context, *CreateTableRequest) (*CreateTableResponse, error) + // Delete a table. All followers will automatically delete the table. + // This procedure is available only in the leader cluster. + Delete(context.Context, *DeleteTableRequest) (*DeleteTableResponse, error) + // Get names of all the tables present in the cluster. + // This procedure is available in both leader and follower clusters. + List(context.Context, *ListTablesRequest) (*ListTablesResponse, error) + mustEmbedUnimplementedTablesServer() +} + +// UnimplementedTablesServer must be embedded to have forward compatible implementations. +type UnimplementedTablesServer struct { +} + +func (UnimplementedTablesServer) Create(context.Context, *CreateTableRequest) (*CreateTableResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") +} +func (UnimplementedTablesServer) Delete(context.Context, *DeleteTableRequest) (*DeleteTableResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented") +} +func (UnimplementedTablesServer) List(context.Context, *ListTablesRequest) (*ListTablesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method List not implemented") +} +func (UnimplementedTablesServer) mustEmbedUnimplementedTablesServer() {} + +// UnsafeTablesServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to TablesServer will +// result in compilation errors. +type UnsafeTablesServer interface { + mustEmbedUnimplementedTablesServer() +} + +func RegisterTablesServer(s grpc.ServiceRegistrar, srv TablesServer) { + s.RegisterService(&Tables_ServiceDesc, srv) +} + +func _Tables_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateTableRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TablesServer).Create(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Tables_Create_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TablesServer).Create(ctx, req.(*CreateTableRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Tables_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteTableRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TablesServer).Delete(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Tables_Delete_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TablesServer).Delete(ctx, req.(*DeleteTableRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Tables_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListTablesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TablesServer).List(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Tables_List_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TablesServer).List(ctx, req.(*ListTablesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Tables_ServiceDesc is the grpc.ServiceDesc for Tables service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Tables_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "regatta.v1.Tables", + HandlerType: (*TablesServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Create", + Handler: _Tables_Create_Handler, + }, + { + MethodName: "Delete", + Handler: _Tables_Delete_Handler, + }, + { + MethodName: "List", + Handler: _Tables_List_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "regatta.proto", +} diff --git a/regattapb/regatta_vtproto.pb.go b/regattapb/regatta_vtproto.pb.go index 3427f600..851e97d8 100644 --- a/regattapb/regatta_vtproto.pb.go +++ b/regattapb/regatta_vtproto.pb.go @@ -1013,361 +1013,683 @@ func (m *StatusResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *ResponseHeader) SizeVT() (n int) { +func (m *CreateTableRequest) MarshalVT() (dAtA []byte, err error) { if m == nil { - return 0 - } - var l int - _ = l - if m.ShardId != 0 { - n += 1 + sov(uint64(m.ShardId)) - } - if m.ReplicaId != 0 { - n += 1 + sov(uint64(m.ReplicaId)) - } - if m.Revision != 0 { - n += 1 + sov(uint64(m.Revision)) - } - if m.RaftTerm != 0 { - n += 1 + sov(uint64(m.RaftTerm)) + return nil, nil } - if m.RaftLeaderId != 0 { - n += 1 + sov(uint64(m.RaftLeaderId)) + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err } - n += len(m.unknownFields) - return n + return dAtA[:n], nil } -func (m *RangeRequest) SizeVT() (n int) { +func (m *CreateTableRequest) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CreateTableRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { if m == nil { - return 0 + return 0, nil } + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Table) - if l > 0 { - n += 1 + l + sov(uint64(l)) - } - l = len(m.Key) - if l > 0 { - n += 1 + l + sov(uint64(l)) - } - l = len(m.RangeEnd) - if l > 0 { - n += 1 + l + sov(uint64(l)) - } - if m.Limit != 0 { - n += 1 + sov(uint64(m.Limit)) - } - if m.Linearizable { - n += 2 - } - if m.KeysOnly { - n += 2 - } - if m.CountOnly { - n += 2 + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) } - if m.MinModRevision != 0 { - n += 1 + sov(uint64(m.MinModRevision)) + if m.Config != nil { + if vtmsg, ok := interface{}(m.Config).(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.Config) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = encodeVarint(dAtA, i, uint64(len(encoded))) + } + i-- + dAtA[i] = 0x2a } - if m.MaxModRevision != 0 { - n += 1 + sov(uint64(m.MaxModRevision)) + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarint(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa } - if m.MinCreateRevision != 0 { - n += 1 + sov(uint64(m.MinCreateRevision)) + return len(dAtA) - i, nil +} + +func (m *CreateTableResponse) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil } - if m.MaxCreateRevision != 0 { - n += 1 + sov(uint64(m.MaxCreateRevision)) + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err } - n += len(m.unknownFields) - return n + return dAtA[:n], nil } -func (m *RangeResponse) SizeVT() (n int) { +func (m *CreateTableResponse) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CreateTableResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { if m == nil { - return 0 + return 0, nil } + i := len(dAtA) + _ = i var l int _ = l - if m.Header != nil { - l = m.Header.SizeVT() - n += 1 + l + sov(uint64(l)) + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) } - if len(m.Kvs) > 0 { - for _, e := range m.Kvs { - l = e.SizeVT() - n += 1 + l + sov(uint64(l)) - } + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarint(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa } - if m.More { - n += 2 + return len(dAtA) - i, nil +} + +func (m *DeleteTableRequest) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil } - if m.Count != 0 { - n += 1 + sov(uint64(m.Count)) + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err } - n += len(m.unknownFields) - return n + return dAtA[:n], nil } -func (m *PutRequest) SizeVT() (n int) { +func (m *DeleteTableRequest) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DeleteTableRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { if m == nil { - return 0 + return 0, nil } + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Table) - if l > 0 { - n += 1 + l + sov(uint64(l)) - } - l = len(m.Key) - if l > 0 { - n += 1 + l + sov(uint64(l)) - } - l = len(m.Value) - if l > 0 { - n += 1 + l + sov(uint64(l)) + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) } - if m.PrevKv { - n += 2 + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarint(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa } - n += len(m.unknownFields) - return n + return len(dAtA) - i, nil } -func (m *PutResponse) SizeVT() (n int) { +func (m *DeleteTableResponse) MarshalVT() (dAtA []byte, err error) { if m == nil { - return 0 - } - var l int - _ = l - if m.Header != nil { - l = m.Header.SizeVT() - n += 1 + l + sov(uint64(l)) + return nil, nil } - if m.PrevKv != nil { - l = m.PrevKv.SizeVT() - n += 1 + l + sov(uint64(l)) + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err } - n += len(m.unknownFields) - return n + return dAtA[:n], nil } -func (m *DeleteRangeRequest) SizeVT() (n int) { +func (m *DeleteTableResponse) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DeleteTableResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { if m == nil { - return 0 + return 0, nil } + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Table) - if l > 0 { - n += 1 + l + sov(uint64(l)) - } - l = len(m.Key) - if l > 0 { - n += 1 + l + sov(uint64(l)) - } - l = len(m.RangeEnd) - if l > 0 { - n += 1 + l + sov(uint64(l)) + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) } - if m.PrevKv { - n += 2 + return len(dAtA) - i, nil +} + +func (m *ListTablesRequest) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil } - if m.Count { - n += 2 + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err } - n += len(m.unknownFields) - return n + return dAtA[:n], nil } -func (m *DeleteRangeResponse) SizeVT() (n int) { +func (m *ListTablesRequest) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *ListTablesRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { if m == nil { - return 0 + return 0, nil } + i := len(dAtA) + _ = i var l int _ = l - if m.Header != nil { - l = m.Header.SizeVT() - n += 1 + l + sov(uint64(l)) + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) } - if m.Deleted != 0 { - n += 1 + sov(uint64(m.Deleted)) + return len(dAtA) - i, nil +} + +func (m *TableInfo) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil } - if len(m.PrevKvs) > 0 { - for _, e := range m.PrevKvs { - l = e.SizeVT() - n += 1 + l + sov(uint64(l)) - } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err } - n += len(m.unknownFields) - return n + return dAtA[:n], nil } -func (m *TxnRequest) SizeVT() (n int) { +func (m *TableInfo) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *TableInfo) MarshalToSizedBufferVT(dAtA []byte) (int, error) { if m == nil { - return 0 + return 0, nil } + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Table) - if l > 0 { - n += 1 + l + sov(uint64(l)) + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) } - if len(m.Compare) > 0 { - for _, e := range m.Compare { - l = e.SizeVT() - n += 1 + l + sov(uint64(l)) + if m.Config != nil { + if vtmsg, ok := interface{}(m.Config).(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.Config) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = encodeVarint(dAtA, i, uint64(len(encoded))) } + i-- + dAtA[i] = 0x2a } - if len(m.Success) > 0 { - for _, e := range m.Success { - l = e.SizeVT() - n += 1 + l + sov(uint64(l)) - } + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarint(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0x12 } - if len(m.Failure) > 0 { - for _, e := range m.Failure { - l = e.SizeVT() - n += 1 + l + sov(uint64(l)) - } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarint(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa } - n += len(m.unknownFields) - return n + return len(dAtA) - i, nil } -func (m *TxnResponse) SizeVT() (n int) { +func (m *ListTablesResponse) MarshalVT() (dAtA []byte, err error) { if m == nil { - return 0 + 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 *ListTablesResponse) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *ListTablesResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil } + i := len(dAtA) + _ = i var l int _ = l - if m.Header != nil { - l = m.Header.SizeVT() - n += 1 + l + sov(uint64(l)) - } - if m.Succeeded { - n += 2 + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) } - if len(m.Responses) > 0 { - for _, e := range m.Responses { - l = e.SizeVT() - n += 1 + l + sov(uint64(l)) + if len(m.Tables) > 0 { + for iNdEx := len(m.Tables) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.Tables[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa } } - n += len(m.unknownFields) - return n + return len(dAtA) - i, nil } -func (m *MemberListRequest) SizeVT() (n int) { +func (m *ResponseHeader) SizeVT() (n int) { if m == nil { return 0 } var l int _ = l + if m.ShardId != 0 { + n += 1 + sov(uint64(m.ShardId)) + } + if m.ReplicaId != 0 { + n += 1 + sov(uint64(m.ReplicaId)) + } + if m.Revision != 0 { + n += 1 + sov(uint64(m.Revision)) + } + if m.RaftTerm != 0 { + n += 1 + sov(uint64(m.RaftTerm)) + } + if m.RaftLeaderId != 0 { + n += 1 + sov(uint64(m.RaftLeaderId)) + } n += len(m.unknownFields) return n } -func (m *MemberListResponse) SizeVT() (n int) { +func (m *RangeRequest) SizeVT() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.Cluster) + l = len(m.Table) if l > 0 { n += 1 + l + sov(uint64(l)) } - if len(m.Members) > 0 { - for _, e := range m.Members { - l = e.SizeVT() - n += 1 + l + sov(uint64(l)) - } + l = len(m.Key) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + l = len(m.RangeEnd) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + if m.Limit != 0 { + n += 1 + sov(uint64(m.Limit)) + } + if m.Linearizable { + n += 2 + } + if m.KeysOnly { + n += 2 + } + if m.CountOnly { + n += 2 + } + if m.MinModRevision != 0 { + n += 1 + sov(uint64(m.MinModRevision)) + } + if m.MaxModRevision != 0 { + n += 1 + sov(uint64(m.MaxModRevision)) + } + if m.MinCreateRevision != 0 { + n += 1 + sov(uint64(m.MinCreateRevision)) + } + if m.MaxCreateRevision != 0 { + n += 1 + sov(uint64(m.MaxCreateRevision)) } n += len(m.unknownFields) return n } -func (m *Member) SizeVT() (n int) { +func (m *RangeResponse) SizeVT() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.Id) - if l > 0 { - n += 1 + l + sov(uint64(l)) - } - l = len(m.Name) - if l > 0 { + if m.Header != nil { + l = m.Header.SizeVT() n += 1 + l + sov(uint64(l)) } - if len(m.PeerURLs) > 0 { - for _, s := range m.PeerURLs { - l = len(s) + if len(m.Kvs) > 0 { + for _, e := range m.Kvs { + l = e.SizeVT() n += 1 + l + sov(uint64(l)) } } - if len(m.ClientURLs) > 0 { - for _, s := range m.ClientURLs { - l = len(s) - n += 1 + l + sov(uint64(l)) - } + if m.More { + n += 2 + } + if m.Count != 0 { + n += 1 + sov(uint64(m.Count)) } n += len(m.unknownFields) return n } -func (m *TableStatus) SizeVT() (n int) { +func (m *PutRequest) SizeVT() (n int) { if m == nil { return 0 } var l int _ = l - if m.LogSize != 0 { - n += 1 + sov(uint64(m.LogSize)) - } - if m.DbSize != 0 { - n += 1 + sov(uint64(m.DbSize)) - } - l = len(m.Leader) + l = len(m.Table) if l > 0 { n += 1 + l + sov(uint64(l)) } - if m.RaftIndex != 0 { - n += 1 + sov(uint64(m.RaftIndex)) + l = len(m.Key) + if l > 0 { + n += 1 + l + sov(uint64(l)) } - if m.RaftTerm != 0 { - n += 1 + sov(uint64(m.RaftTerm)) + l = len(m.Value) + if l > 0 { + n += 1 + l + sov(uint64(l)) } - if m.RaftAppliedIndex != 0 { - n += 1 + sov(uint64(m.RaftAppliedIndex)) + if m.PrevKv { + n += 2 } n += len(m.unknownFields) return n } -func (m *StatusRequest) SizeVT() (n int) { +func (m *PutResponse) SizeVT() (n int) { if m == nil { return 0 } var l int _ = l - if m.Config { - n += 2 + if m.Header != nil { + l = m.Header.SizeVT() + n += 1 + l + sov(uint64(l)) + } + if m.PrevKv != nil { + l = m.PrevKv.SizeVT() + n += 1 + l + sov(uint64(l)) } n += len(m.unknownFields) return n } -func (m *StatusResponse) SizeVT() (n int) { +func (m *DeleteRangeRequest) SizeVT() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.Id) + l = len(m.Table) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + l = len(m.Key) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + l = len(m.RangeEnd) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + if m.PrevKv { + n += 2 + } + if m.Count { + n += 2 + } + n += len(m.unknownFields) + return n +} + +func (m *DeleteRangeResponse) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Header != nil { + l = m.Header.SizeVT() + n += 1 + l + sov(uint64(l)) + } + if m.Deleted != 0 { + n += 1 + sov(uint64(m.Deleted)) + } + if len(m.PrevKvs) > 0 { + for _, e := range m.PrevKvs { + l = e.SizeVT() + n += 1 + l + sov(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *TxnRequest) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Table) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + if len(m.Compare) > 0 { + for _, e := range m.Compare { + l = e.SizeVT() + n += 1 + l + sov(uint64(l)) + } + } + if len(m.Success) > 0 { + for _, e := range m.Success { + l = e.SizeVT() + n += 1 + l + sov(uint64(l)) + } + } + if len(m.Failure) > 0 { + for _, e := range m.Failure { + l = e.SizeVT() + n += 1 + l + sov(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *TxnResponse) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Header != nil { + l = m.Header.SizeVT() + n += 1 + l + sov(uint64(l)) + } + if m.Succeeded { + n += 2 + } + if len(m.Responses) > 0 { + for _, e := range m.Responses { + l = e.SizeVT() + n += 1 + l + sov(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *MemberListRequest) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += len(m.unknownFields) + return n +} + +func (m *MemberListResponse) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Cluster) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + if len(m.Members) > 0 { + for _, e := range m.Members { + l = e.SizeVT() + n += 1 + l + sov(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *Member) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + if len(m.PeerURLs) > 0 { + for _, s := range m.PeerURLs { + l = len(s) + n += 1 + l + sov(uint64(l)) + } + } + if len(m.ClientURLs) > 0 { + for _, s := range m.ClientURLs { + l = len(s) + n += 1 + l + sov(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *TableStatus) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.LogSize != 0 { + n += 1 + sov(uint64(m.LogSize)) + } + if m.DbSize != 0 { + n += 1 + sov(uint64(m.DbSize)) + } + l = len(m.Leader) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + if m.RaftIndex != 0 { + n += 1 + sov(uint64(m.RaftIndex)) + } + if m.RaftTerm != 0 { + n += 1 + sov(uint64(m.RaftTerm)) + } + if m.RaftAppliedIndex != 0 { + n += 1 + sov(uint64(m.RaftAppliedIndex)) + } + n += len(m.unknownFields) + return n +} + +func (m *StatusRequest) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Config { + n += 2 + } + n += len(m.unknownFields) + return n +} + +func (m *StatusResponse) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) if l > 0 { n += 1 + l + sov(uint64(l)) } @@ -1387,32 +1709,762 @@ func (m *StatusResponse) SizeVT() (n int) { if v != nil { l = v.SizeVT() } - l += 1 + sov(uint64(l)) - mapEntrySize := 1 + len(k) + sov(uint64(len(k))) + l - n += mapEntrySize + 1 + sov(uint64(mapEntrySize)) - } - } - if m.Config != nil { - if size, ok := interface{}(m.Config).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(m.Config) + l += 1 + sov(uint64(l)) + mapEntrySize := 1 + len(k) + sov(uint64(len(k))) + l + n += mapEntrySize + 1 + sov(uint64(mapEntrySize)) + } + } + if m.Config != nil { + if size, ok := interface{}(m.Config).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(m.Config) + } + n += 1 + l + sov(uint64(l)) + } + if len(m.Errors) > 0 { + for _, s := range m.Errors { + l = len(s) + n += 1 + l + sov(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *CreateTableRequest) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + if m.Config != nil { + if size, ok := interface{}(m.Config).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(m.Config) + } + n += 1 + l + sov(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *CreateTableResponse) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *DeleteTableRequest) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *DeleteTableResponse) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += len(m.unknownFields) + return n +} + +func (m *ListTablesRequest) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += len(m.unknownFields) + return n +} + +func (m *TableInfo) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + l = len(m.Id) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + if m.Config != nil { + if size, ok := interface{}(m.Config).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(m.Config) + } + n += 1 + l + sov(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *ListTablesResponse) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Tables) > 0 { + for _, e := range m.Tables { + l = e.SizeVT() + n += 1 + l + sov(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *ResponseHeader) 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 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: ResponseHeader: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ResponseHeader: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ShardId", wireType) + } + m.ShardId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ShardId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ReplicaId", wireType) + } + m.ReplicaId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ReplicaId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Revision", wireType) + } + m.Revision = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Revision |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RaftTerm", wireType) + } + m.RaftTerm = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RaftTerm |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RaftLeaderId", wireType) + } + m.RaftLeaderId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RaftLeaderId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return 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 *RangeRequest) 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 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: RangeRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RangeRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Table", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Table = append(m.Table[:0], dAtA[iNdEx:postIndex]...) + if m.Table == nil { + m.Table = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RangeEnd", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RangeEnd = append(m.RangeEnd[:0], dAtA[iNdEx:postIndex]...) + if m.RangeEnd == nil { + m.RangeEnd = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Limit", wireType) + } + m.Limit = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Limit |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Linearizable", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Linearizable = bool(v != 0) + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field KeysOnly", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.KeysOnly = bool(v != 0) + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CountOnly", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.CountOnly = bool(v != 0) + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinModRevision", wireType) + } + m.MinModRevision = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinModRevision |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxModRevision", wireType) + } + m.MaxModRevision = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxModRevision |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinCreateRevision", wireType) + } + m.MinCreateRevision = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinCreateRevision |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxCreateRevision", wireType) + } + m.MaxCreateRevision = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxCreateRevision |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return 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 *RangeResponse) 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 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: RangeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RangeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Header == nil { + m.Header = &ResponseHeader{} + } + if err := m.Header.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Kvs", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Kvs = append(m.Kvs, &KeyValue{}) + if err := m.Kvs[len(m.Kvs)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field More", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.More = bool(v != 0) + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Count", wireType) + } + m.Count = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Count |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy } - n += 1 + l + sov(uint64(l)) } - if len(m.Errors) > 0 { - for _, s := range m.Errors { - l = len(s) - n += 1 + l + sov(uint64(l)) - } + + if iNdEx > l { + return io.ErrUnexpectedEOF } - n += len(m.unknownFields) - return n + return nil } - -func (m *ResponseHeader) UnmarshalVT(dAtA []byte) error { +func (m *PutRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1435,17 +2487,17 @@ func (m *ResponseHeader) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ResponseHeader: wiretype end group for non-group") + return fmt.Errorf("proto: PutRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ResponseHeader: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: PutRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ShardId", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Table", wireType) } - m.ShardId = 0 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -1455,16 +2507,31 @@ func (m *ResponseHeader) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ShardId |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } + if byteLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Table = append(m.Table[:0], dAtA[iNdEx:postIndex]...) + if m.Table == nil { + m.Table = []byte{} + } + iNdEx = postIndex case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ReplicaId", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) } - m.ReplicaId = 0 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -1474,16 +2541,136 @@ func (m *ResponseHeader) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ReplicaId |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } + if byteLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) + if m.Value == nil { + m.Value = []byte{} + } + iNdEx = postIndex + case 4: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Revision", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PrevKv", wireType) } - m.Revision = 0 + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.PrevKv = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return 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 *PutResponse) 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 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: PutResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PutResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) + } + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -1493,35 +2680,33 @@ func (m *ResponseHeader) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Revision |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field RaftTerm", wireType) + if msglen < 0 { + return ErrInvalidLength } - m.RaftTerm = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.RaftTerm |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength } - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field RaftLeaderId", wireType) + if postIndex > l { + return io.ErrUnexpectedEOF } - m.RaftLeaderId = 0 + if m.Header == nil { + m.Header = &ResponseHeader{} + } + if err := m.Header.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrevKv", wireType) + } + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -1531,11 +2716,28 @@ func (m *ResponseHeader) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.RaftLeaderId |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.PrevKv == nil { + m.PrevKv = &KeyValue{} + } + if err := m.PrevKv.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skip(dAtA[iNdEx:]) @@ -1558,7 +2760,7 @@ func (m *ResponseHeader) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *RangeRequest) UnmarshalVT(dAtA []byte) error { +func (m *DeleteRangeRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1581,10 +2783,10 @@ func (m *RangeRequest) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: RangeRequest: wiretype end group for non-group") + return fmt.Errorf("proto: DeleteRangeRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: RangeRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: DeleteRangeRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1691,46 +2893,7 @@ func (m *RangeRequest) UnmarshalVT(dAtA []byte) error { iNdEx = postIndex case 4: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Limit", wireType) - } - m.Limit = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Limit |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Linearizable", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Linearizable = bool(v != 0) - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field KeysOnly", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PrevKv", wireType) } var v int for shift := uint(0); ; shift += 7 { @@ -1747,10 +2910,10 @@ func (m *RangeRequest) UnmarshalVT(dAtA []byte) error { break } } - m.KeysOnly = bool(v != 0) - case 7: + m.PrevKv = bool(v != 0) + case 5: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CountOnly", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Count", wireType) } var v int for shift := uint(0); ; shift += 7 { @@ -1767,83 +2930,7 @@ func (m *RangeRequest) UnmarshalVT(dAtA []byte) error { break } } - m.CountOnly = bool(v != 0) - case 8: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MinModRevision", wireType) - } - m.MinModRevision = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MinModRevision |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 9: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxModRevision", wireType) - } - m.MaxModRevision = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MaxModRevision |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 10: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MinCreateRevision", wireType) - } - m.MinCreateRevision = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MinCreateRevision |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 11: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxCreateRevision", wireType) - } - m.MaxCreateRevision = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MaxCreateRevision |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } + m.Count = bool(v != 0) default: iNdEx = preIndex skippy, err := skip(dAtA[iNdEx:]) @@ -1866,7 +2953,7 @@ func (m *RangeRequest) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *RangeResponse) UnmarshalVT(dAtA []byte) error { +func (m *DeleteRangeResponse) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1889,10 +2976,10 @@ func (m *RangeResponse) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: RangeResponse: wiretype end group for non-group") + return fmt.Errorf("proto: DeleteRangeResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: RangeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: DeleteRangeResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1931,11 +3018,11 @@ func (m *RangeResponse) UnmarshalVT(dAtA []byte) error { return err } iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Kvs", wireType) + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Deleted", wireType) } - var msglen int + m.Deleted = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -1945,31 +3032,16 @@ func (m *RangeResponse) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.Deleted |= int64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Kvs = append(m.Kvs, &KeyValue{}) - if err := m.Kvs[len(m.Kvs)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field More", wireType) + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrevKvs", wireType) } - var v int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -1979,31 +3051,26 @@ func (m *RangeResponse) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - v |= int(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - m.More = bool(v != 0) - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Count", wireType) + if msglen < 0 { + return ErrInvalidLength } - m.Count = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Count |= int64(b&0x7F) << shift - if b < 0x80 { - break - } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PrevKvs = append(m.PrevKvs, &KeyValue{}) + if err := m.PrevKvs[len(m.PrevKvs)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skip(dAtA[iNdEx:]) @@ -2026,7 +3093,7 @@ func (m *RangeResponse) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *PutRequest) UnmarshalVT(dAtA []byte) error { +func (m *TxnRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2049,10 +3116,10 @@ func (m *PutRequest) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: PutRequest: wiretype end group for non-group") + return fmt.Errorf("proto: TxnRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: PutRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: TxnRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2091,9 +3158,9 @@ func (m *PutRequest) UnmarshalVT(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Compare", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -2103,31 +3170,31 @@ func (m *PutRequest) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + if msglen < 0 { return ErrInvalidLength } - postIndex := iNdEx + byteLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLength } if postIndex > l { return io.ErrUnexpectedEOF } - m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) - if m.Key == nil { - m.Key = []byte{} + m.Compare = append(m.Compare, &Compare{}) + if err := m.Compare[len(m.Compare)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Success", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -2137,31 +3204,31 @@ func (m *PutRequest) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + if msglen < 0 { return ErrInvalidLength } - postIndex := iNdEx + byteLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLength } if postIndex > l { return io.ErrUnexpectedEOF } - m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) - if m.Value == nil { - m.Value = []byte{} + m.Success = append(m.Success, &RequestOp{}) + if err := m.Success[len(m.Success)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PrevKv", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Failure", wireType) } - var v int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -2171,12 +3238,26 @@ func (m *PutRequest) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - v |= int(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - m.PrevKv = bool(v != 0) + if msglen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Failure = append(m.Failure, &RequestOp{}) + if err := m.Failure[len(m.Failure)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skip(dAtA[iNdEx:]) @@ -2199,7 +3280,7 @@ func (m *PutRequest) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *PutResponse) UnmarshalVT(dAtA []byte) error { +func (m *TxnResponse) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2222,10 +3303,10 @@ func (m *PutResponse) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: PutResponse: wiretype end group for non-group") + return fmt.Errorf("proto: TxnResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: PutResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: TxnResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2265,8 +3346,28 @@ func (m *PutResponse) UnmarshalVT(dAtA []byte) error { } iNdEx = postIndex case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Succeeded", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Succeeded = bool(v != 0) + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PrevKv", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Responses", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2293,10 +3394,8 @@ func (m *PutResponse) UnmarshalVT(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.PrevKv == nil { - m.PrevKv = &KeyValue{} - } - if err := m.PrevKv.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + m.Responses = append(m.Responses, &ResponseOp{}) + if err := m.Responses[len(m.Responses)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2322,7 +3421,7 @@ func (m *PutResponse) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *DeleteRangeRequest) UnmarshalVT(dAtA []byte) error { +func (m *MemberListRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2345,154 +3444,12 @@ func (m *DeleteRangeRequest) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: DeleteRangeRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DeleteRangeRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Table", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Table = append(m.Table[:0], dAtA[iNdEx:postIndex]...) - if m.Table == nil { - m.Table = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) - if m.Key == nil { - m.Key = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RangeEnd", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RangeEnd = append(m.RangeEnd[:0], dAtA[iNdEx:postIndex]...) - if m.RangeEnd == nil { - m.RangeEnd = []byte{} - } - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PrevKv", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.PrevKv = bool(v != 0) - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Count", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Count = bool(v != 0) + return fmt.Errorf("proto: MemberListRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MemberListRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { default: iNdEx = preIndex skippy, err := skip(dAtA[iNdEx:]) @@ -2515,7 +3472,7 @@ func (m *DeleteRangeRequest) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *DeleteRangeResponse) UnmarshalVT(dAtA []byte) error { +func (m *MemberListResponse) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2538,17 +3495,17 @@ func (m *DeleteRangeResponse) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: DeleteRangeResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MemberListResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: DeleteRangeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MemberListResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Cluster", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -2558,50 +3515,27 @@ func (m *DeleteRangeResponse) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLength } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLength } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Header == nil { - m.Header = &ResponseHeader{} - } - if err := m.Header.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Cluster = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Deleted", wireType) - } - m.Deleted = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Deleted |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PrevKvs", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Members", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2628,8 +3562,8 @@ func (m *DeleteRangeResponse) UnmarshalVT(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.PrevKvs = append(m.PrevKvs, &KeyValue{}) - if err := m.PrevKvs[len(m.PrevKvs)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + m.Members = append(m.Members, &Member{}) + if err := m.Members[len(m.Members)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2655,7 +3589,7 @@ func (m *DeleteRangeResponse) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *TxnRequest) UnmarshalVT(dAtA []byte) error { +func (m *Member) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2678,17 +3612,17 @@ func (m *TxnRequest) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: TxnRequest: wiretype end group for non-group") + return fmt.Errorf("proto: Member: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: TxnRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Member: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Table", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -2698,31 +3632,29 @@ func (m *TxnRequest) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLength } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLength } if postIndex > l { return io.ErrUnexpectedEOF } - m.Table = append(m.Table[:0], dAtA[iNdEx:postIndex]...) - if m.Table == nil { - m.Table = []byte{} - } + m.Id = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Compare", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -2732,31 +3664,29 @@ func (m *TxnRequest) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLength } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLength } if postIndex > l { return io.ErrUnexpectedEOF } - m.Compare = append(m.Compare, &Compare{}) - if err := m.Compare[len(m.Compare)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Success", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PeerURLs", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -2766,31 +3696,29 @@ func (m *TxnRequest) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLength } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLength } if postIndex > l { return io.ErrUnexpectedEOF } - m.Success = append(m.Success, &RequestOp{}) - if err := m.Success[len(m.Success)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.PeerURLs = append(m.PeerURLs, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Failure", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ClientURLs", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -2800,25 +3728,23 @@ func (m *TxnRequest) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLength } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLength } if postIndex > l { return io.ErrUnexpectedEOF } - m.Failure = append(m.Failure, &RequestOp{}) - if err := m.Failure[len(m.Failure)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.ClientURLs = append(m.ClientURLs, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex default: iNdEx = preIndex @@ -2842,7 +3768,7 @@ func (m *TxnRequest) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *TxnResponse) UnmarshalVT(dAtA []byte) error { +func (m *TableStatus) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2865,17 +3791,55 @@ func (m *TxnResponse) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: TxnResponse: wiretype end group for non-group") + return fmt.Errorf("proto: TableStatus: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: TxnResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: TableStatus: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LogSize", wireType) + } + m.LogSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LogSize |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DbSize", wireType) + } + m.DbSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.DbSize |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Leader", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -2885,33 +3849,29 @@ func (m *TxnResponse) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLength } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLength } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Header == nil { - m.Header = &ResponseHeader{} - } - if err := m.Header.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Leader = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 5: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Succeeded", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field RaftIndex", wireType) } - var v int + m.RaftIndex = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -2921,17 +3881,16 @@ func (m *TxnResponse) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - v |= int(b&0x7F) << shift + m.RaftIndex |= uint64(b&0x7F) << shift if b < 0x80 { break } } - m.Succeeded = bool(v != 0) - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Responses", wireType) + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RaftTerm", wireType) } - var msglen int + m.RaftTerm = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -2941,26 +3900,30 @@ func (m *TxnResponse) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.RaftTerm |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RaftAppliedIndex", wireType) } - m.Responses = append(m.Responses, &ResponseOp{}) - if err := m.Responses[len(m.Responses)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err + m.RaftAppliedIndex = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RaftAppliedIndex |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skip(dAtA[iNdEx:]) @@ -2983,7 +3946,7 @@ func (m *TxnResponse) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *MemberListRequest) UnmarshalVT(dAtA []byte) error { +func (m *StatusRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3006,12 +3969,32 @@ func (m *MemberListRequest) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MemberListRequest: wiretype end group for non-group") + return fmt.Errorf("proto: StatusRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MemberListRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: StatusRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Config", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Config = bool(v != 0) default: iNdEx = preIndex skippy, err := skip(dAtA[iNdEx:]) @@ -3034,7 +4017,7 @@ func (m *MemberListRequest) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *MemberListResponse) UnmarshalVT(dAtA []byte) error { +func (m *StatusResponse) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3057,15 +4040,15 @@ func (m *MemberListResponse) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MemberListResponse: wiretype end group for non-group") + return fmt.Errorf("proto: StatusResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MemberListResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: StatusResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Cluster", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3093,11 +4076,204 @@ func (m *MemberListResponse) UnmarshalVT(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Cluster = string(dAtA[iNdEx:postIndex]) + m.Id = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Members", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 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 ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Version = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Info", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 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 ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Info = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Tables", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Tables == nil { + m.Tables = make(map[string]*TableStatus) + } + var mapkey string + var mapvalue *TableStatus + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLength + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLength + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLength + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLength + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &TableStatus{} + if err := mapvalue.UnmarshalVT(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Tables[mapkey] = mapvalue + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Config", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3117,17 +4293,59 @@ func (m *MemberListResponse) UnmarshalVT(dAtA []byte) error { if msglen < 0 { return ErrInvalidLength } - postIndex := iNdEx + msglen + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Config == nil { + m.Config = &structpb.Struct{} + } + if unmarshal, ok := interface{}(m.Config).(interface { + UnmarshalVT([]byte) error + }); ok { + if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.Config); err != nil { + return err + } + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Errors", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 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 ErrInvalidLength + } + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLength } if postIndex > l { return io.ErrUnexpectedEOF } - m.Members = append(m.Members, &Member{}) - if err := m.Members[len(m.Members)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Errors = append(m.Errors, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex default: iNdEx = preIndex @@ -3151,7 +4369,7 @@ func (m *MemberListResponse) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *Member) UnmarshalVT(dAtA []byte) error { +func (m *CreateTableRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3174,15 +4392,15 @@ func (m *Member) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Member: wiretype end group for non-group") + return fmt.Errorf("proto: CreateTableRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Member: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: CreateTableRequest: 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) + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3210,13 +4428,13 @@ func (m *Member) UnmarshalVT(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Id = string(dAtA[iNdEx:postIndex]) + m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Config", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -3226,59 +4444,90 @@ func (m *Member) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLength } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLength } if postIndex > l { return io.ErrUnexpectedEOF } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PeerURLs", wireType) + if m.Config == nil { + m.Config = &structpb.Struct{} } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF + if unmarshal, ok := interface{}(m.Config).(interface { + UnmarshalVT([]byte) error + }); ok { + if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break + } else { + if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.Config); err != nil { + return err } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLength + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err } - postIndex := iNdEx + intStringLen - if postIndex < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLength } - if postIndex > l { + if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } - m.PeerURLs = append(m.PeerURLs, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 4: + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CreateTableResponse) 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 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: CreateTableResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CreateTableResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ClientURLs", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3306,7 +4555,7 @@ func (m *Member) UnmarshalVT(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ClientURLs = append(m.ClientURLs, string(dAtA[iNdEx:postIndex])) + m.Id = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -3330,7 +4579,7 @@ func (m *Member) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *TableStatus) UnmarshalVT(dAtA []byte) error { +func (m *DeleteTableRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3353,53 +4602,15 @@ func (m *TableStatus) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: TableStatus: wiretype end group for non-group") + return fmt.Errorf("proto: DeleteTableRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: TableStatus: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: DeleteTableRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LogSize", wireType) - } - m.LogSize = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.LogSize |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field DbSize", wireType) - } - m.DbSize = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.DbSize |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Leader", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3427,65 +4638,59 @@ func (m *TableStatus) UnmarshalVT(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Leader = string(dAtA[iNdEx:postIndex]) + m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field RaftIndex", wireType) + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err } - m.RaftIndex = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.RaftIndex |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength } - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field RaftTerm", wireType) + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF } - m.RaftTerm = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.RaftTerm |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DeleteTableResponse) 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 ErrIntOverflow } - case 7: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field RaftAppliedIndex", wireType) + if iNdEx >= l { + return io.ErrUnexpectedEOF } - m.RaftAppliedIndex = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.RaftAppliedIndex |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + 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: DeleteTableResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DeleteTableResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { default: iNdEx = preIndex skippy, err := skip(dAtA[iNdEx:]) @@ -3508,7 +4713,7 @@ func (m *TableStatus) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *StatusRequest) UnmarshalVT(dAtA []byte) error { +func (m *ListTablesRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3531,32 +4736,12 @@ func (m *StatusRequest) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: StatusRequest: wiretype end group for non-group") + return fmt.Errorf("proto: ListTablesRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: StatusRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ListTablesRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Config", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Config = bool(v != 0) default: iNdEx = preIndex skippy, err := skip(dAtA[iNdEx:]) @@ -3579,7 +4764,7 @@ func (m *StatusRequest) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *StatusResponse) UnmarshalVT(dAtA []byte) error { +func (m *TableInfo) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3602,15 +4787,15 @@ func (m *StatusResponse) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: StatusResponse: wiretype end group for non-group") + return fmt.Errorf("proto: TableInfo: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: StatusResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: TableInfo: 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) + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3638,43 +4823,11 @@ func (m *StatusResponse) UnmarshalVT(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Id = string(dAtA[iNdEx:postIndex]) + m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 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 ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Version = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Info", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3702,136 +4855,7 @@ func (m *StatusResponse) UnmarshalVT(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Info = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Tables", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Tables == nil { - m.Tables = make(map[string]*TableStatus) - } - var mapkey string - var mapvalue *TableStatus - for iNdEx < postIndex { - entryPreIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLength - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return ErrInvalidLength - } - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var mapmsglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapmsglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if mapmsglen < 0 { - return ErrInvalidLength - } - postmsgIndex := iNdEx + mapmsglen - if postmsgIndex < 0 { - return ErrInvalidLength - } - if postmsgIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue = &TableStatus{} - if err := mapvalue.UnmarshalVT(dAtA[iNdEx:postmsgIndex]); err != nil { - return err - } - iNdEx = postmsgIndex - } else { - iNdEx = entryPreIndex - skippy, err := skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLength - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - m.Tables[mapkey] = mapvalue + m.Id = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 5: if wireType != 2 { @@ -3877,11 +4901,62 @@ func (m *StatusResponse) UnmarshalVT(dAtA []byte) error { } } iNdEx = postIndex - case 8: + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return 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 *ListTablesResponse) 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 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: ListTablesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ListTablesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Errors", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Tables", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -3891,23 +4966,25 @@ func (m *StatusResponse) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLength } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLength } if postIndex > l { return io.ErrUnexpectedEOF } - m.Errors = append(m.Errors, string(dAtA[iNdEx:postIndex])) + m.Tables = append(m.Tables, &TableInfo{}) + if err := m.Tables[len(m.Tables)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex diff --git a/regattaserver/regattaserver.go b/regattaserver/regattaserver.go index 9d73c5a4..f78b9200 100644 --- a/regattaserver/regattaserver.go +++ b/regattaserver/regattaserver.go @@ -29,6 +29,8 @@ type TableService interface { GetTables() ([]table.Table, error) GetTable(name string) (table.ActiveTable, error) Restore(name string, reader io.Reader) error + CreateTable(name string) (table.Table, error) + DeleteTable(name string) error } type ClusterService interface { diff --git a/regattaserver/regattaserver_test.go b/regattaserver/regattaserver_test.go index fb87ddb4..410776ab 100644 --- a/regattaserver/regattaserver_test.go +++ b/regattaserver/regattaserver_test.go @@ -4,8 +4,17 @@ package regattaserver import ( "io" + "net" + "testing" + "time" + pvfs "github.com/cockroachdb/pebble/vfs" + "github.com/google/uuid" + "github.com/jamf/regatta/storage" "github.com/jamf/regatta/storage/table" + "github.com/lni/vfs" + "github.com/stretchr/testify/require" + "go.uber.org/zap/zaptest" ) type MockTableService struct { @@ -13,6 +22,14 @@ type MockTableService struct { error error } +func (t MockTableService) CreateTable(name string) error { + return nil +} + +func (t MockTableService) DeleteTable(name string) error { + return nil +} + func (t MockTableService) GetTables() ([]table.Table, error) { return t.tables, t.error } @@ -24,3 +41,69 @@ func (t MockTableService) GetTable(name string) (table.ActiveTable, error) { func (t MockTableService) Restore(name string, reader io.Reader) error { return t.error } + +func newInMemTestEngine(t *testing.T, tables ...string) *storage.Engine { + testAddr := func() string { + l, err := net.Listen("tcp4", "127.0.0.1:0") + if err != nil { + panic(err) + } + defer l.Close() + return l.Addr().String() + } + + raftAddr := testAddr() + gossipAddr := testAddr() + + e, err := storage.New(storage.Config{ + ClientAddress: raftAddr, + NodeID: 1, + InitialMembers: map[uint64]string{1: raftAddr}, + NodeHostDir: "/nh", + RTTMillisecond: 10, + RaftAddress: raftAddr, + EnableMetrics: false, + Gossip: storage.GossipConfig{ + ClusterName: uuid.New().String(), + BindAddress: gossipAddr, + InitialMembers: []string{gossipAddr}, + }, + Table: storage.TableConfig{ + ElectionRTT: 10, + HeartbeatRTT: 1, + SnapshotEntries: 10, + CompactionOverhead: 5, + MaxInMemLogSize: 1024, + FS: pvfs.NewMem(), + DataDir: "/data", + BlockCacheSize: 1024, + TableCacheSize: 64, + RecoveryType: table.RecoveryTypeCheckpoint, + }, + Meta: storage.MetaConfig{ + ElectionRTT: 10, + HeartbeatRTT: 1, + SnapshotEntries: 10, + CompactionOverhead: 5, + MaxInMemLogSize: 1024, + }, + LogDBImplementation: storage.Tan, + FS: vfs.NewMem(), + Log: zaptest.NewLogger(t).Sugar(), + }) + require.NoError(t, err) + require.NoError(t, e.Start()) + require.NoError(t, e.WaitUntilReady()) + for _, tableName := range tables { + at, err := e.CreateTable(tableName) + require.NoError(t, err) + require.Eventually(t, func() bool { + _, _, ok, _ := e.GetLeaderID(at.ClusterID) + return ok + }, 10*time.Second, 5*time.Millisecond, "table did not start in time") + } + t.Cleanup(func() { + _ = e.Close() + }) + return e +} diff --git a/regattaserver/replication.go b/regattaserver/replication.go index 2b8496f1..a5d3f70c 100644 --- a/regattaserver/replication.go +++ b/regattaserver/replication.go @@ -4,10 +4,12 @@ package regattaserver import ( "bufio" + "cmp" "context" "errors" "io" "os" + "slices" "time" "github.com/jamf/regatta/regattapb" @@ -42,6 +44,9 @@ func (m *MetadataServer) Get(context.Context, *regattapb.MetadataRequest) (*rega Type: regattapb.Table_REPLICATED, Name: tab.Name, }) + slices.SortFunc(resp.Tables, func(a, b *regattapb.Table) int { + return cmp.Compare(a.Name, b.Name) + }) } return resp, nil } diff --git a/regattaserver/replication_test.go b/regattaserver/replication_test.go index f4457bef..c2337ce6 100644 --- a/regattaserver/replication_test.go +++ b/regattaserver/replication_test.go @@ -4,19 +4,20 @@ package regattaserver import ( "context" + "fmt" "testing" + "time" "github.com/jamf/regatta/regattapb" - "github.com/jamf/regatta/storage/table" "github.com/lni/dragonboat/v4/raftpb" "github.com/stretchr/testify/require" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" + "go.uber.org/zap/zaptest" + "google.golang.org/grpc" ) func TestMetadataServer_Get(t *testing.T) { type fields struct { - TableManager TableService + Tables []string } tests := []struct { name string @@ -26,23 +27,12 @@ func TestMetadataServer_Get(t *testing.T) { }{ { name: "Get metadata - no tables", - fields: fields{ - TableManager: MockTableService{ - tables: []table.Table{}, - }, - }, want: ®attapb.MetadataResponse{Tables: nil}, }, { name: "Get metadata - single table", fields: fields{ - TableManager: MockTableService{ - tables: []table.Table{ - { - Name: "foo", - }, - }, - }, + Tables: []string{"foo"}, }, want: ®attapb.MetadataResponse{Tables: []*regattapb.Table{ { @@ -54,43 +44,25 @@ func TestMetadataServer_Get(t *testing.T) { { name: "Get metadata - multiple tables", fields: fields{ - TableManager: MockTableService{ - tables: []table.Table{ - { - Name: "foo", - }, - { - Name: "bar", - }, - }, - }, + Tables: []string{"foo", "bar"}, }, want: ®attapb.MetadataResponse{Tables: []*regattapb.Table{ { - Name: "foo", + Name: "bar", Type: regattapb.Table_REPLICATED, }, { - Name: "bar", + Name: "foo", Type: regattapb.Table_REPLICATED, }, }}, }, - { - name: "Get metadata - deadline exceeded", - fields: fields{ - TableManager: MockTableService{ - error: context.DeadlineExceeded, - }, - }, - wantErr: status.Errorf(codes.Unavailable, "unknown err %v", context.DeadlineExceeded), - }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { r := require.New(t) m := &MetadataServer{ - Tables: tt.fields.TableManager, + Tables: newInMemTestEngine(t, tt.fields.Tables...), } got, err := m.Get(context.TODO(), ®attapb.MetadataRequest{}) if tt.wantErr != nil { @@ -155,3 +127,119 @@ func TestEntryToCommand(t *testing.T) { }) } } + +type captureSnapshotStream struct { + grpc.ServerStream + chunks []*regattapb.SnapshotChunk +} + +func (c *captureSnapshotStream) Context() context.Context { + return context.TODO() +} + +func (c *captureSnapshotStream) Send(chunk *regattapb.SnapshotChunk) error { + c.chunks = append(c.chunks, chunk) + return nil +} + +func TestSnapshotServer_Stream(t *testing.T) { + type fields struct { + Tables []string + } + type args struct { + req *regattapb.SnapshotRequest + } + tests := []struct { + name string + fields fields + args args + wantErr require.ErrorAssertionFunc + wantChunksCount int + }{ + { + name: "table not exist", + args: args{req: ®attapb.SnapshotRequest{Table: table1Name}}, + wantErr: require.Error, + }, + { + name: "snapshot", + fields: fields{Tables: []string{string(table1Name)}}, + args: args{req: ®attapb.SnapshotRequest{Table: table1Name}}, + wantErr: require.NoError, + wantChunksCount: 2, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + s := &SnapshotServer{ + Tables: newInMemTestEngine(t, tt.fields.Tables...), + } + capture := &captureSnapshotStream{} + tt.wantErr(t, s.Stream(tt.args.req, capture), fmt.Sprintf("Stream(%v)", tt.args.req)) + require.Equal(t, tt.wantChunksCount, len(capture.chunks)) + }) + } +} + +type captureLogStream struct { + grpc.ServerStream + ctx context.Context + stream []*regattapb.ReplicateResponse +} + +func (c *captureLogStream) Context() context.Context { + return c.ctx +} + +func (c *captureLogStream) Send(r *regattapb.ReplicateResponse) error { + c.stream = append(c.stream, r) + return nil +} + +func TestLogServer_Replicate(t *testing.T) { + type fields struct { + Tables []string + maxMessageSize uint64 + } + type args struct { + req *regattapb.ReplicateRequest + } + tests := []struct { + name string + fields fields + args args + wantErr require.ErrorAssertionFunc + }{ + { + name: "table not exist", + args: args{req: ®attapb.ReplicateRequest{Table: table1Name}}, + wantErr: require.Error, + }, + { + name: "zero index", + args: args{req: ®attapb.ReplicateRequest{Table: table1Name}}, + wantErr: require.Error, + }, + { + name: "stream", + fields: fields{Tables: []string{string(table1Name)}}, + args: args{req: ®attapb.ReplicateRequest{Table: table1Name, LeaderIndex: 1}}, + wantErr: require.NoError, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + te := newInMemTestEngine(t, tt.fields.Tables...) + l := &LogServer{ + Tables: te, + LogReader: te.LogReader, + Log: zaptest.NewLogger(t).Sugar(), + maxMessageSize: tt.fields.maxMessageSize, + } + ctx, cancel := context.WithTimeout(context.TODO(), time.Second) + defer cancel() + stream := &captureLogStream{ctx: ctx} + tt.wantErr(t, l.Replicate(tt.args.req, stream), fmt.Sprintf("Replicate(%v)", tt.args.req)) + }) + } +} diff --git a/regattaserver/tables.go b/regattaserver/tables.go new file mode 100644 index 00000000..71480cf2 --- /dev/null +++ b/regattaserver/tables.go @@ -0,0 +1,94 @@ +// Copyright JAMF Software, LLC + +package regattaserver + +import ( + "cmp" + "context" + "errors" + "slices" + "strconv" + + "github.com/jamf/regatta/regattapb" + serrors "github.com/jamf/regatta/storage/errors" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +type TablesServer struct { + regattapb.UnimplementedTablesServer + Tables TableService + AuthFunc func(ctx context.Context) (context.Context, error) +} + +func (t *TablesServer) Create(ctx context.Context, req *regattapb.CreateTableRequest) (*regattapb.CreateTableResponse, error) { + _, err := t.AuthFunc(ctx) + if err != nil { + return nil, err + } + if len(req.Name) == 0 { + return nil, status.Errorf(codes.InvalidArgument, "name must be set") + } + table, err := t.Tables.CreateTable(req.Name) + if err != nil { + if errors.Is(err, serrors.ErrTableExists) { + return nil, status.Errorf(codes.InvalidArgument, err.Error()) + } + return nil, status.Errorf(codes.FailedPrecondition, err.Error()) + } + return ®attapb.CreateTableResponse{Id: strconv.FormatUint(table.ClusterID, 10)}, nil +} + +func (t *TablesServer) Delete(ctx context.Context, req *regattapb.DeleteTableRequest) (*regattapb.DeleteTableResponse, error) { + _, err := t.AuthFunc(ctx) + if err != nil { + return nil, err + } + if len(req.Name) == 0 { + return nil, status.Errorf(codes.InvalidArgument, "name must be set") + } + if err := t.Tables.DeleteTable(req.Name); err != nil { + if errors.Is(err, serrors.ErrTableNotFound) { + return nil, status.Errorf(codes.InvalidArgument, err.Error()) + } + return nil, status.Errorf(codes.FailedPrecondition, err.Error()) + } + return ®attapb.DeleteTableResponse{}, nil +} + +func (t *TablesServer) List(ctx context.Context, _ *regattapb.ListTablesRequest) (*regattapb.ListTablesResponse, error) { + _, err := t.AuthFunc(ctx) + if err != nil { + return nil, err + } + ts, err := t.Tables.GetTables() + if err != nil { + if serrors.IsSafeToRetry(err) { + return nil, status.Errorf(codes.Unavailable, err.Error()) + } + return nil, status.Errorf(codes.FailedPrecondition, err.Error()) + } + resp := ®attapb.ListTablesResponse{Tables: make([]*regattapb.TableInfo, len(ts))} + for i, table := range ts { + resp.Tables[i] = ®attapb.TableInfo{ + Name: table.Name, + Id: strconv.FormatUint(table.ClusterID, 10), + } + } + slices.SortFunc(resp.Tables, func(a, b *regattapb.TableInfo) int { + return cmp.Compare(a.Name, b.Name) + }) + return resp, nil +} + +type ReadonlyTablesServer struct { + TablesServer +} + +func (t *ReadonlyTablesServer) Create(context.Context, *regattapb.CreateTableRequest) (*regattapb.CreateTableResponse, error) { + return nil, status.Error(codes.Unimplemented, "method Create not implemented for follower") +} + +func (t *ReadonlyTablesServer) Delete(context.Context, *regattapb.DeleteTableRequest) (*regattapb.DeleteTableResponse, error) { + return nil, status.Error(codes.Unimplemented, "method Delete not implemented for follower") +} diff --git a/regattaserver/tables_test.go b/regattaserver/tables_test.go new file mode 100644 index 00000000..fc9ad512 --- /dev/null +++ b/regattaserver/tables_test.go @@ -0,0 +1,192 @@ +// Copyright JAMF Software, LLC + +package regattaserver + +import ( + "context" + "errors" + "fmt" + "testing" + + "github.com/jamf/regatta/regattapb" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func TestTablesServer_Create(t *testing.T) { + type fields struct { + Tables []string + AuthFunc func(ctx context.Context) (context.Context, error) + } + type args struct { + req *regattapb.CreateTableRequest + } + tests := []struct { + name string + fields fields + args args + want *regattapb.CreateTableResponse + wantErr require.ErrorAssertionFunc + }{ + { + name: "allow all - missing table name", + fields: fields{AuthFunc: allowAll}, + args: args{req: ®attapb.CreateTableRequest{}}, + wantErr: require.Error, + }, + { + name: "allow all - not existing table", + fields: fields{AuthFunc: allowAll}, + args: args{req: ®attapb.CreateTableRequest{Name: "new"}}, + wantErr: require.NoError, + want: ®attapb.CreateTableResponse{Id: "10001"}, + }, + { + name: "allow all - existing table", + fields: fields{AuthFunc: allowAll, Tables: []string{"exists"}}, + args: args{req: ®attapb.CreateTableRequest{Name: "exists"}}, + wantErr: require.Error, + }, + { + name: "deny all", + fields: fields{AuthFunc: denyAll}, + args: args{req: ®attapb.CreateTableRequest{}}, + wantErr: require.Error, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + ts := &TablesServer{ + Tables: newInMemTestEngine(t, tt.fields.Tables...), + AuthFunc: tt.fields.AuthFunc, + } + got, err := ts.Create(context.TODO(), tt.args.req) + tt.wantErr(t, err, fmt.Sprintf("Create(%v, %v)", context.TODO(), tt.args.req)) + require.Equalf(t, tt.want, got, "Create(%v, %v)", context.TODO(), tt.args.req) + }) + } +} + +func TestTablesServer_Delete(t *testing.T) { + type fields struct { + Tables []string + AuthFunc func(ctx context.Context) (context.Context, error) + } + type args struct { + req *regattapb.DeleteTableRequest + } + tests := []struct { + name string + fields fields + args args + want *regattapb.DeleteTableResponse + wantErr require.ErrorAssertionFunc + }{ + { + name: "allow all - missing table name", + fields: fields{AuthFunc: allowAll}, + args: args{req: ®attapb.DeleteTableRequest{}}, + wantErr: require.Error, + }, + { + name: "allow all - not existing table", + fields: fields{AuthFunc: allowAll}, + args: args{req: ®attapb.DeleteTableRequest{Name: "nonexistent"}}, + wantErr: require.Error, + }, + { + name: "allow all - existing table", + fields: fields{AuthFunc: allowAll, Tables: []string{"exists"}}, + args: args{req: ®attapb.DeleteTableRequest{Name: "exists"}}, + wantErr: require.NoError, + want: ®attapb.DeleteTableResponse{}, + }, + { + name: "deny all", + fields: fields{AuthFunc: denyAll}, + args: args{req: ®attapb.DeleteTableRequest{}}, + wantErr: require.Error, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + ts := &TablesServer{ + Tables: newInMemTestEngine(t, tt.fields.Tables...), + AuthFunc: tt.fields.AuthFunc, + } + got, err := ts.Delete(context.TODO(), tt.args.req) + tt.wantErr(t, err, fmt.Sprintf("Delete(%v, %v)", context.TODO(), tt.args.req)) + require.Equalf(t, tt.want, got, "Delete(%v, %v)", context.TODO(), tt.args.req) + }) + } +} + +func TestTablesServer_List(t *testing.T) { + type fields struct { + Tables []string + AuthFunc func(ctx context.Context) (context.Context, error) + } + tests := []struct { + name string + fields fields + want *regattapb.ListTablesResponse + wantErr require.ErrorAssertionFunc + }{ + { + name: "allow all", + fields: fields{AuthFunc: allowAll}, + wantErr: require.NoError, + }, + { + name: "allow all multiple tables", + fields: fields{AuthFunc: allowAll, Tables: []string{"table1", "table2"}}, + wantErr: require.NoError, + want: ®attapb.ListTablesResponse{Tables: []*regattapb.TableInfo{ + { + Name: "table1", + Id: "10001", + }, + { + Name: "table2", + Id: "10002", + }, + }}, + }, + { + name: "deny all", + fields: fields{AuthFunc: denyAll}, + wantErr: require.Error, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + ts := &TablesServer{ + Tables: newInMemTestEngine(t, tt.fields.Tables...), + AuthFunc: tt.fields.AuthFunc, + } + _, err := ts.List(context.TODO(), ®attapb.ListTablesRequest{}) + tt.wantErr(t, err, fmt.Sprintf("List(%v, %v)", context.TODO(), ®attapb.ListTablesRequest{})) + }) + } +} + +func TestReadonlyTablesServer_Create(t *testing.T) { + ts := &ReadonlyTablesServer{} + _, err := ts.Create(context.TODO(), ®attapb.CreateTableRequest{}) + require.ErrorIs(t, err, status.Error(codes.Unimplemented, "method Create not implemented for follower")) +} + +func TestReadonlyTablesServer_Delete(t *testing.T) { + ts := &ReadonlyTablesServer{} + _, err := ts.Delete(context.TODO(), ®attapb.DeleteTableRequest{}) + require.ErrorIs(t, err, status.Error(codes.Unimplemented, "method Delete not implemented for follower")) +} + +func denyAll(ctx context.Context) (context.Context, error) { + return nil, errors.New("denied") +} + +func allowAll(ctx context.Context) (context.Context, error) { + return ctx, nil +} diff --git a/replication/backup/backup_test.go b/replication/backup/backup_test.go index 5e1e4817..58b58536 100644 --- a/replication/backup/backup_test.go +++ b/replication/backup/backup_test.go @@ -149,7 +149,8 @@ func TestBackup_Backup(t *testing.T) { defer e.Close() for name, data := range tt.tableData { - r.NoError(e.CreateTable(name)) + _, err := e.CreateTable(name) + r.NoError(err) time.Sleep(1 * time.Second) for _, req := range data { tbl, err := e.GetTable(name) diff --git a/replication/replication.go b/replication/replication.go index c8ffece3..18511eba 100644 --- a/replication/replication.go +++ b/replication/replication.go @@ -5,6 +5,7 @@ package replication import ( "context" "errors" + "slices" "sync" "time" @@ -55,6 +56,7 @@ func NewManager(tm *table.Manager, nh *dragonboat.NodeHost, conn *grpc.ClientCon tm: tm, metadataClient: regattapb.NewMetadataClient(conn), factory: &workerFactory{ + reconcileInterval: cfg.ReconcileInterval, pollInterval: cfg.Workers.PollInterval, leaseInterval: cfg.Workers.LeaseInterval, logTimeout: cfg.Workers.LogRPCTimeout, @@ -73,7 +75,6 @@ func NewManager(tm *table.Manager, nh *dragonboat.NodeHost, conn *grpc.ClientCon }, workers: struct { registry map[string]*worker - mtx sync.RWMutex wg sync.WaitGroup }{ registry: make(map[string]*worker), @@ -91,7 +92,6 @@ type Manager struct { factory *workerFactory workers struct { registry map[string]*worker - mtx sync.RWMutex wg sync.WaitGroup } log *zap.SugaredLogger @@ -119,18 +119,19 @@ func (m *Manager) Start() { t := time.NewTicker(m.reconcileInterval) defer t.Stop() for { + select { + case <-t.C: + case <-m.closer: + m.log.Info("replication stopped") + return + } if err := m.reconcileTables(); err != nil { m.log.Errorf("failed to reconcile tables: %v", err) + continue } if err := m.reconcileWorkers(); err != nil { m.log.Errorf("failed to reconcile replication workers: %v", err) - } - select { - case <-t.C: continue - case <-m.closer: - m.log.Info("replication stopped") - return } } }() @@ -143,8 +144,37 @@ func (m *Manager) reconcileTables() error { if err != nil { return err } - for _, tabs := range response.GetTables() { - if err := m.tm.CreateTable(tabs.Name); err != nil && !errors.Is(err, serrors.ErrTableExists) { + leaderTables := response.GetTables() + followerTables, err := m.tm.GetTables() + if err != nil { + return err + } + var toCreate, toDelete []string + + for _, ft := range followerTables { + if !slices.ContainsFunc(leaderTables, func(lt *regattapb.Table) bool { + return ft.Name == lt.Name + }) { + toDelete = append(toDelete, ft.Name) + } + } + + for _, ft := range leaderTables { + if !slices.ContainsFunc(followerTables, func(lt table.Table) bool { + return ft.Name == lt.Name + }) { + toCreate = append(toCreate, ft.Name) + } + } + + for _, name := range toDelete { + if err := m.tm.DeleteTable(name); err != nil && !errors.Is(err, serrors.ErrTableNotFound) { + return err + } + } + + for _, name := range toCreate { + if _, err := m.tm.CreateTable(name); err != nil && !errors.Is(err, serrors.ErrTableExists) { return err } } @@ -163,20 +193,19 @@ func (m *Manager) reconcileWorkers() error { } } - m.workers.mtx.RLock() - defer m.workers.mtx.RUnlock() - for name, worker := range m.workers.registry { - found := false - for _, tbl := range tbs { - if tbl.Name == name { - found = true - break - } - } - if !found { - m.stopWorker(worker) + var toStop []*worker + + for name, w := range m.workers.registry { + if !slices.ContainsFunc(tbs, func(t table.Table) bool { + return t.Name == name + }) { + toStop = append(toStop, w) } } + + for _, w := range toStop { + m.stopWorker(w) + } return nil } @@ -190,16 +219,11 @@ func (m *Manager) Close() { } func (m *Manager) hasWorker(name string) bool { - m.workers.mtx.RLock() - defer m.workers.mtx.RUnlock() _, ok := m.workers.registry[name] return ok } func (m *Manager) startWorker(worker *worker) { - m.workers.mtx.Lock() - defer m.workers.mtx.Unlock() - m.log.Infof("launching replication for table %s", worker.table) m.workers.registry[worker.table] = worker m.workers.wg.Add(1) @@ -207,9 +231,6 @@ func (m *Manager) startWorker(worker *worker) { } func (m *Manager) stopWorker(worker *worker) { - m.workers.mtx.Lock() - defer m.workers.mtx.Unlock() - m.log.Infof("stopping replication for table %s", worker.table) worker.Close() m.workers.wg.Done() diff --git a/replication/replication_test.go b/replication/replication_test.go index 130d4e9c..5dcd0d53 100644 --- a/replication/replication_test.go +++ b/replication/replication_test.go @@ -136,7 +136,8 @@ func TestManager_reconcileTables(t *testing.T) { m := NewManager(followerTM, followerNH, conn, Config{}) t.Log("create table") - r.NoError(leaderTM.CreateTable("test")) + _, err = leaderTM.CreateTable("test") + r.NoError(err) r.NoError(m.reconcileTables()) r.Eventually(func() bool { _, err := followerTM.GetTable("test") @@ -144,7 +145,8 @@ func TestManager_reconcileTables(t *testing.T) { }, 10*time.Second, 200*time.Millisecond, "table not created in time") t.Log("create another table") - r.NoError(leaderTM.CreateTable("test2")) + _, err = leaderTM.CreateTable("test2") + r.NoError(err) r.NoError(m.reconcileTables()) r.Eventually(func() bool { _, err := followerTM.GetTable("test2") diff --git a/replication/worker.go b/replication/worker.go index 59537341..3c3d3486 100644 --- a/replication/worker.go +++ b/replication/worker.go @@ -15,6 +15,7 @@ import ( "github.com/jamf/regatta/regattapb" "github.com/jamf/regatta/replication/snapshot" + serrors "github.com/jamf/regatta/storage/errors" "github.com/jamf/regatta/storage/table" "github.com/lni/dragonboat/v4" "github.com/lni/dragonboat/v4/client" @@ -23,6 +24,8 @@ import ( "golang.org/x/sync/semaphore" "golang.org/x/time/rate" "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" ) // TODO make configurable. @@ -36,9 +39,11 @@ const ( resultLeaderAhead resultFollowerLagging resultFollowerTailing + resultTableNotExists ) type workerFactory struct { + reconcileInterval time.Duration pollInterval time.Duration leaseInterval time.Duration logTimeout time.Duration @@ -144,6 +149,10 @@ func (w *worker) Start() { t.Reset(w.pollInterval) idx, sess, err := w.tableState() if err != nil { + if errors.Is(err, serrors.ErrTableNotFound) { + w.log.Debugf("table not found: %v", err) + continue + } w.log.Errorf("cannot query leader index: %v", err) continue } @@ -153,17 +162,15 @@ func (w *worker) Start() { continue } result, err := w.do(idx, sess) - if err != nil { - if errors.Is(err, context.DeadlineExceeded) { - w.log.Warnf("unable to read leader log in time: %v", err) - } else { - w.log.Warnf("unknown worker error: %v", err) - } - continue - } switch result { + case resultTableNotExists: + w.log.Infof("the leader table dissapeared ... backing off") + // Give reconciler time to clean up the table. + t.Reset(2 * w.reconcileInterval) case resultLeaderBehind: w.log.Errorf("the leader log is behind ... backing off") + // Give leader time to catch up. + t.Reset(10 * w.pollInterval) case resultLeaderAhead: if w.recoverySemaphore.TryAcquire(1) { func() { @@ -181,6 +188,17 @@ func (w *worker) Start() { case resultFollowerLagging: // Trigger next loop immediately. t.Reset(50 * time.Millisecond) + case resultFollowerTailing: + continue + case resultUnknown: + if err != nil { + if errors.Is(err, context.DeadlineExceeded) { + w.log.Warnf("unable to read leader log in time: %v", err) + } else { + w.log.Warnf("unknown worker error: %v", err) + } + continue + } } case <-w.closer: return @@ -212,6 +230,9 @@ func (w *worker) do(leaderIndex uint64, session *client.Session) (replicateResul defer cancel() stream, err := w.logClient.Replicate(ctx, replicateRequest, grpc.WaitForReady(true)) if err != nil { + if c, ok := status.FromError(err); ok && c.Code() == codes.Unavailable { + return resultTableNotExists, fmt.Errorf("could not open log stream: %w", err) + } return resultUnknown, fmt.Errorf("could not open log stream: %w", err) } var applied uint64 @@ -221,6 +242,9 @@ func (w *worker) do(leaderIndex uint64, session *client.Session) (replicateResul return resultUnknown, nil } if err != nil { + if c, ok := status.FromError(err); ok && c.Code() == codes.Unavailable { + return resultTableNotExists, fmt.Errorf("error reading replication stream: %w", err) + } return resultUnknown, fmt.Errorf("error reading replication stream: %w", err) } diff --git a/replication/worker_test.go b/replication/worker_test.go index fc44b603..fad90052 100644 --- a/replication/worker_test.go +++ b/replication/worker_test.go @@ -27,11 +27,12 @@ func Test_worker_do(t *testing.T) { defer srv.Shutdown() t.Log("create tables") - r.NoError(leaderTM.CreateTable("test")) - r.NoError(followerTM.CreateTable("test")) + _, err := leaderTM.CreateTable("test") + r.NoError(err) + _, err = followerTM.CreateTable("test") + r.NoError(err) var at table.ActiveTable - var err error t.Log("load some data") r.Eventually(func() bool { at, err = leaderTM.GetTable("test") @@ -117,7 +118,8 @@ func Test_worker_do(t *testing.T) { err = leaderTM.DeleteTable("test") r.NoError(err) t.Log("create empty table test") - r.NoError(leaderTM.CreateTable("test")) + _, err = leaderTM.CreateTable("test") + r.NoError(err) t.Log("load some data") r.Eventually(func() bool { @@ -166,8 +168,10 @@ func Test_worker_recover(t *testing.T) { defer srv.Shutdown() t.Log("create tables") - r.NoError(leaderTM.CreateTable("test")) - r.NoError(leaderTM.CreateTable("test2")) + _, err := leaderTM.CreateTable("test") + r.NoError(err) + _, err = leaderTM.CreateTable("test2") + r.NoError(err) var at table.ActiveTable t.Log("load some data") @@ -178,7 +182,7 @@ func Test_worker_recover(t *testing.T) { }, 5*time.Second, 500*time.Millisecond, "table not created in time") ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() - _, err := at.Put(ctx, ®attapb.PutRequest{ + _, err = at.Put(ctx, ®attapb.PutRequest{ Key: []byte("foo"), Value: []byte("bar"), }) diff --git a/storage/engine.go b/storage/engine.go index 3a0279de..0de06efc 100644 --- a/storage/engine.go +++ b/storage/engine.go @@ -24,11 +24,11 @@ const defaultQueryTimeout = 5 * time.Second func New(cfg Config) (*Engine, error) { e := &Engine{ - cfg: cfg, - log: cfg.Log, - eventsCh: make(chan any, 1), - stop: make(chan struct{}), + cfg: cfg, + log: cfg.Log, + stop: make(chan struct{}), } + e.events = &events{eventsCh: make(chan any, 1), engine: e} nh, err := createNodeHost(e) if err != nil { @@ -70,7 +70,7 @@ type Engine struct { *table.Manager cfg Config log *zap.SugaredLogger - eventsCh chan any + events *events stop chan struct{} LogReader logreader.Interface Cluster *cluster.Cluster @@ -82,7 +82,7 @@ func (e *Engine) Start() error { if err := e.Manager.Start(); err != nil { return err } - go e.dispatchEvents() + go e.events.dispatchEvents() return nil } @@ -254,8 +254,8 @@ func createNodeHost(e *Engine) (*dragonboat.NodeHost, error) { EnableMetrics: true, MaxReceiveQueueSize: e.cfg.MaxReceiveQueueSize, MaxSendQueueSize: e.cfg.MaxSendQueueSize, - SystemEventListener: e, - RaftEventListener: e, + SystemEventListener: e.events, + RaftEventListener: e.events, } if e.cfg.LogDBImplementation == Tan { diff --git a/storage/engine_events.go b/storage/engine_events.go index eb03b476..2367f959 100644 --- a/storage/engine_events.go +++ b/storage/engine_events.go @@ -6,32 +6,34 @@ import ( "github.com/lni/dragonboat/v4/raftio" ) -func (e *Engine) dispatchEvents() { - for { - select { - case <-e.stop: +type events struct { + eventsCh chan any + engine *Engine +} + +func (e *events) dispatchEvents() { + for evt := range e.eventsCh { + e.engine.log.Infof("raft: %T %+v", evt, evt) + switch ev := evt.(type) { + case nodeHostShuttingDown: return - case evt := <-e.eventsCh: - e.log.Infof("raft: %T %+v", evt, evt) - switch ev := evt.(type) { - case leaderUpdated, nodeUnloaded, membershipChanged, nodeHostShuttingDown: - e.Cluster.Notify() - case nodeReady: - if ev.ReplicaID == e.cfg.NodeID && e.LogCache != nil { - e.LogCache.NodeReady(ev.ShardID) - } - e.Cluster.Notify() - case nodeDeleted: - if ev.ReplicaID == e.cfg.NodeID && e.LogCache != nil { - e.LogCache.NodeDeleted(ev.ShardID) - } - e.Cluster.Notify() - case logCompacted: - if ev.ReplicaID == e.cfg.NodeID && e.LogCache != nil { - e.LogCache.LogCompacted(ev.ShardID) - } - e.Cluster.Notify() + case leaderUpdated, nodeUnloaded, membershipChanged: + e.engine.Cluster.Notify() + case nodeReady: + if ev.ReplicaID == e.engine.cfg.NodeID && e.engine.LogCache != nil { + e.engine.LogCache.NodeReady(ev.ShardID) + } + e.engine.Cluster.Notify() + case nodeDeleted: + if ev.ReplicaID == e.engine.cfg.NodeID && e.engine.LogCache != nil { + e.engine.LogCache.NodeDeleted(ev.ShardID) + } + e.engine.Cluster.Notify() + case logCompacted: + if ev.ReplicaID == e.engine.cfg.NodeID && e.engine.LogCache != nil { + e.engine.LogCache.LogCompacted(ev.ShardID) } + e.engine.Cluster.Notify() } } } @@ -43,7 +45,7 @@ type leaderUpdated struct { LeaderID uint64 } -func (e *Engine) LeaderUpdated(info raftio.LeaderInfo) { +func (e *events) LeaderUpdated(info raftio.LeaderInfo) { e.eventsCh <- leaderUpdated{ ShardID: info.ShardID, ReplicaID: info.ReplicaID, @@ -54,7 +56,7 @@ func (e *Engine) LeaderUpdated(info raftio.LeaderInfo) { type nodeHostShuttingDown struct{} -func (e *Engine) NodeHostShuttingDown() { +func (e *events) NodeHostShuttingDown() { e.eventsCh <- nodeHostShuttingDown{} } @@ -63,7 +65,7 @@ type nodeUnloaded struct { ReplicaID uint64 } -func (e *Engine) NodeUnloaded(info raftio.NodeInfo) { +func (e *events) NodeUnloaded(info raftio.NodeInfo) { e.eventsCh <- nodeUnloaded{ ShardID: info.ShardID, ReplicaID: info.ReplicaID, @@ -75,7 +77,7 @@ type nodeDeleted struct { ReplicaID uint64 } -func (e *Engine) NodeDeleted(info raftio.NodeInfo) { +func (e *events) NodeDeleted(info raftio.NodeInfo) { e.eventsCh <- nodeDeleted{ ShardID: info.ShardID, ReplicaID: info.ReplicaID, @@ -87,7 +89,7 @@ type nodeReady struct { ReplicaID uint64 } -func (e *Engine) NodeReady(info raftio.NodeInfo) { +func (e *events) NodeReady(info raftio.NodeInfo) { e.eventsCh <- nodeReady{ ShardID: info.ShardID, ReplicaID: info.ReplicaID, @@ -99,7 +101,7 @@ type membershipChanged struct { ReplicaID uint64 } -func (e *Engine) MembershipChanged(info raftio.NodeInfo) { +func (e *events) MembershipChanged(info raftio.NodeInfo) { e.eventsCh <- membershipChanged{ ShardID: info.ShardID, ReplicaID: info.ReplicaID, @@ -111,7 +113,7 @@ type connectionEstablished struct { SnapshotConnection bool } -func (e *Engine) ConnectionEstablished(info raftio.ConnectionInfo) { +func (e *events) ConnectionEstablished(info raftio.ConnectionInfo) { e.eventsCh <- connectionEstablished{ Address: info.Address, SnapshotConnection: info.SnapshotConnection, @@ -123,7 +125,7 @@ type connectionFailed struct { SnapshotConnection bool } -func (e *Engine) ConnectionFailed(info raftio.ConnectionInfo) { +func (e *events) ConnectionFailed(info raftio.ConnectionInfo) { e.eventsCh <- connectionFailed{ Address: info.Address, SnapshotConnection: info.SnapshotConnection, @@ -137,7 +139,7 @@ type sendSnapshotStarted struct { Index uint64 } -func (e *Engine) SendSnapshotStarted(info raftio.SnapshotInfo) { +func (e *events) SendSnapshotStarted(info raftio.SnapshotInfo) { e.eventsCh <- sendSnapshotStarted{ ShardID: info.ShardID, ReplicaID: info.ReplicaID, @@ -153,7 +155,7 @@ type sendSnapshotCompleted struct { Index uint64 } -func (e *Engine) SendSnapshotCompleted(info raftio.SnapshotInfo) { +func (e *events) SendSnapshotCompleted(info raftio.SnapshotInfo) { e.eventsCh <- sendSnapshotCompleted{ ShardID: info.ShardID, ReplicaID: info.ReplicaID, @@ -169,7 +171,7 @@ type sendSnapshotAborted struct { Index uint64 } -func (e *Engine) SendSnapshotAborted(info raftio.SnapshotInfo) { +func (e *events) SendSnapshotAborted(info raftio.SnapshotInfo) { e.eventsCh <- sendSnapshotAborted{ ShardID: info.ShardID, ReplicaID: info.ReplicaID, @@ -185,7 +187,7 @@ type snapshotReceived struct { Index uint64 } -func (e *Engine) SnapshotReceived(info raftio.SnapshotInfo) { +func (e *events) SnapshotReceived(info raftio.SnapshotInfo) { e.eventsCh <- snapshotReceived{ ShardID: info.ShardID, ReplicaID: info.ReplicaID, @@ -201,7 +203,7 @@ type snapshotRecovered struct { Index uint64 } -func (e *Engine) SnapshotRecovered(info raftio.SnapshotInfo) { +func (e *events) SnapshotRecovered(info raftio.SnapshotInfo) { e.eventsCh <- snapshotRecovered{ ShardID: info.ShardID, ReplicaID: info.ReplicaID, @@ -217,7 +219,7 @@ type snapshotCreated struct { Index uint64 } -func (e *Engine) SnapshotCreated(info raftio.SnapshotInfo) { +func (e *events) SnapshotCreated(info raftio.SnapshotInfo) { e.eventsCh <- snapshotCreated{ ShardID: info.ShardID, ReplicaID: info.ReplicaID, @@ -233,7 +235,7 @@ type snapshotCompacted struct { Index uint64 } -func (e *Engine) SnapshotCompacted(info raftio.SnapshotInfo) { +func (e *events) SnapshotCompacted(info raftio.SnapshotInfo) { e.eventsCh <- snapshotCompacted{ ShardID: info.ShardID, ReplicaID: info.ReplicaID, @@ -247,7 +249,7 @@ type logCompacted struct { ReplicaID uint64 } -func (e *Engine) LogCompacted(info raftio.EntryInfo) { +func (e *events) LogCompacted(info raftio.EntryInfo) { e.eventsCh <- logCompacted{ ShardID: info.ShardID, ReplicaID: info.ReplicaID, @@ -259,7 +261,7 @@ type logDBCompacted struct { ReplicaID uint64 } -func (e *Engine) LogDBCompacted(info raftio.EntryInfo) { +func (e *events) LogDBCompacted(info raftio.EntryInfo) { e.eventsCh <- logDBCompacted{ ShardID: info.ShardID, ReplicaID: info.ReplicaID, diff --git a/storage/engine_test.go b/storage/engine_test.go index b16c94b1..b958ed49 100644 --- a/storage/engine_test.go +++ b/storage/engine_test.go @@ -756,15 +756,13 @@ func TestNew(t *testing.T) { } func createTable(t *testing.T, e *Engine) { - require.NoError(t, e.CreateTable(testTableName)) + tab, err := e.CreateTable(testTableName) + require.NoError(t, err) require.Eventually(t, func() bool { - tab, err := e.GetTable(testTableName) - if err != nil { - return false - } c, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) defer cancel() - _, err = tab.LocalIndex(c, true) + active := tab.AsActive(e) + _, err := active.LocalIndex(c, true) return err == nil }, 1*time.Second, 10*time.Millisecond) } @@ -788,7 +786,8 @@ func newTestConfig() Config { } func newTestEngine(t *testing.T, cfg Config) *Engine { - e := &Engine{cfg: cfg, eventsCh: make(chan any, 1), stop: make(chan struct{}), log: zaptest.NewLogger(t).Sugar()} + e := &Engine{cfg: cfg, stop: make(chan struct{}), log: zaptest.NewLogger(t).Sugar()} + e.events = &events{eventsCh: make(chan any, 1), engine: e} nh, err := createNodeHost(e) require.NoError(t, err) e.NodeHost = nh diff --git a/storage/kv/kv_test.go b/storage/kv/kv_test.go index 2f9354d5..6784d158 100644 --- a/storage/kv/kv_test.go +++ b/storage/kv/kv_test.go @@ -57,7 +57,10 @@ type store interface { func fillData(store store, data map[string]string) { for k, v := range data { - _, _ = store.Set(k, v, 0) + _, err := store.Set(k, v, 0) + if err != nil { + panic(err) + } } } @@ -699,6 +702,7 @@ func newRaftStore() *RaftStore { CheckQuorum: true, SnapshotEntries: 10000, CompactionOverhead: 5000, + WaitReady: true, } err = nh.StartConcurrentReplica(map[uint64]string{1: testNodeAddress}, false, NewLFSM(), cc) @@ -709,12 +713,12 @@ func newRaftStore() *RaftStore { ready := make(chan struct{}) go func() { for { - i := nh.GetNodeHostInfo(dragonboat.DefaultNodeHostInfoOption) - if i.ShardInfoList[0].LeaderID == cc.ReplicaID { + _, _, ok, _ := nh.GetLeaderID(cc.ReplicaID) + if ok { close(ready) return } - time.Sleep(500 * time.Millisecond) + time.Sleep(10 * time.Millisecond) } }() diff --git a/storage/kv/raft.go b/storage/kv/raft.go index 5ccedf66..9f1013e7 100644 --- a/storage/kv/raft.go +++ b/storage/kv/raft.go @@ -173,9 +173,7 @@ func (r *RaftStore) Delete(key string, ver uint64) error { } func (r *RaftStore) Exists(key string) (bool, error) { - ctx, cancel := context.WithTimeout(context.Background(), proposalTimeout) - defer cancel() - ok, err := r.NodeHost.SyncRead(ctx, r.ClusterID, QueryExist{Key: key}) + ok, err := r.NodeHost.StaleRead(r.ClusterID, QueryExist{Key: key}) if err != nil { return false, err } @@ -183,9 +181,7 @@ func (r *RaftStore) Exists(key string) (bool, error) { } func (r *RaftStore) Get(key string) (Pair, error) { - ctx, cancel := context.WithTimeout(context.Background(), proposalTimeout) - defer cancel() - val, err := r.NodeHost.SyncRead(ctx, r.ClusterID, QueryKey{Key: key}) + val, err := r.NodeHost.StaleRead(r.ClusterID, QueryKey{Key: key}) if err != nil { return Pair{}, err } @@ -193,9 +189,7 @@ func (r *RaftStore) Get(key string) (Pair, error) { } func (r *RaftStore) GetAll(pattern string) ([]Pair, error) { - ctx, cancel := context.WithTimeout(context.Background(), proposalTimeout) - defer cancel() - val, err := r.NodeHost.SyncRead(ctx, r.ClusterID, QueryAll{Pattern: pattern}) + val, err := r.NodeHost.StaleRead(r.ClusterID, QueryAll{Pattern: pattern}) if err != nil { return nil, err } @@ -203,9 +197,7 @@ func (r *RaftStore) GetAll(pattern string) ([]Pair, error) { } func (r *RaftStore) GetAllValues(pattern string) ([]string, error) { - ctx, cancel := context.WithTimeout(context.Background(), proposalTimeout) - defer cancel() - val, err := r.NodeHost.SyncRead(ctx, r.ClusterID, QueryAllValues{Pattern: pattern}) + val, err := r.NodeHost.StaleRead(r.ClusterID, QueryAllValues{Pattern: pattern}) if err != nil { return nil, err } @@ -213,9 +205,7 @@ func (r *RaftStore) GetAllValues(pattern string) ([]string, error) { } func (r *RaftStore) List(filePath string) ([]string, error) { - ctx, cancel := context.WithTimeout(context.Background(), proposalTimeout) - defer cancel() - val, err := r.NodeHost.SyncRead(ctx, r.ClusterID, QueryList{Path: filePath}) + val, err := r.NodeHost.StaleRead(r.ClusterID, QueryList{Path: filePath}) if err != nil { return nil, err } @@ -223,9 +213,7 @@ func (r *RaftStore) List(filePath string) ([]string, error) { } func (r *RaftStore) ListDir(filePath string) ([]string, error) { - ctx, cancel := context.WithTimeout(context.Background(), proposalTimeout) - defer cancel() - val, err := r.NodeHost.SyncRead(ctx, r.ClusterID, QueryListDir{Path: filePath}) + val, err := r.NodeHost.StaleRead(r.ClusterID, QueryListDir{Path: filePath}) if err != nil { return nil, err } diff --git a/storage/table/manager.go b/storage/table/manager.go index 6c3e6014..f8d13997 100644 --- a/storage/table/manager.go +++ b/storage/table/manager.go @@ -160,15 +160,15 @@ func (m *Manager) ReturnTable(name string) (bool, error) { return true, nil } -func (m *Manager) CreateTable(name string) error { +func (m *Manager) CreateTable(name string) (Table, error) { m.mtx.Lock() defer m.mtx.Unlock() created, err := m.createTable(name) if err != nil { - return err + return Table{}, err } - return m.startTable(created.Name, created.ClusterID) + return created, m.startTable(created.Name, created.ClusterID) } func (m *Manager) createTable(name string) (Table, error) { @@ -204,6 +204,9 @@ func (m *Manager) DeleteTable(name string) error { storeName := storedTableName(name) tab, err := m.store.Get(storeName) if err != nil { + if errors.Is(err, kv.ErrNotExist) { + return serrors.ErrTableNotFound + } return err } diff --git a/storage/table/manager_test.go b/storage/table/manager_test.go index 2028b741..a5abb868 100644 --- a/storage/table/manager_test.go +++ b/storage/table/manager_test.go @@ -36,7 +36,8 @@ func TestManager_CreateTable(t *testing.T) { r.NoError(tm.WaitUntilReady()) t.Log("create table") - r.NoError(tm.CreateTable(testTableName)) + _, err := tm.CreateTable(testTableName) + r.NoError(err) t.Log("get table") tab, err := tm.GetTable(testTableName) @@ -45,7 +46,8 @@ func TestManager_CreateTable(t *testing.T) { r.Greater(tab.ClusterID, tableIDsRangeStart) t.Log("create existing table") - r.ErrorIs(tm.CreateTable(testTableName), serrors.ErrTableExists) + _, err = tm.CreateTable(testTableName) + r.ErrorIs(err, serrors.ErrTableExists) ts, err := tm.GetTables() r.NoError(err) @@ -65,7 +67,8 @@ func TestManager_DeleteTable(t *testing.T) { r.NoError(tm.WaitUntilReady()) t.Log("create table") - r.NoError(tm.CreateTable(testTableName)) + _, err := tm.CreateTable(testTableName) + r.NoError(err) t.Log("get table") tab, err := tm.GetTable(testTableName) @@ -123,7 +126,8 @@ func TestManager_LeaseTable(t *testing.T) { require.NoError(t, tm.Start()) defer tm.Close() require.NoError(t, tm.WaitUntilReady()) - require.NoError(t, tm.CreateTable(existingTable)) + _, err := tm.CreateTable(existingTable) + require.NoError(t, err) for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -171,9 +175,11 @@ func TestManager_ReturnTable(t *testing.T) { require.NoError(t, tm.Start()) defer tm.Close() require.NoError(t, tm.WaitUntilReady()) - require.NoError(t, tm.CreateTable(existingTable)) + _, err := tm.CreateTable(existingTable) + require.NoError(t, err) - require.NoError(t, tm.CreateTable(leasedTable)) + _, err = tm.CreateTable(leasedTable) + require.NoError(t, err) require.NoError(t, tm.LeaseTable(leasedTable, 60*time.Second)) for _, tt := range tests { @@ -218,7 +224,8 @@ func TestManager_GetTable(t *testing.T) { require.NoError(t, tm.Start()) defer tm.Close() require.NoError(t, tm.WaitUntilReady()) - require.NoError(t, tm.CreateTable(existingTable)) + _, err := tm.CreateTable(existingTable) + require.NoError(t, err) for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -242,7 +249,8 @@ func TestManager_Restore(t *testing.T) { require.NoError(t, tm.Start()) defer tm.Close() require.NoError(t, tm.WaitUntilReady()) - require.NoError(t, tm.CreateTable(existingTable)) + _, err := tm.CreateTable(existingTable) + require.NoError(t, err) tab, err := tm.GetTable(existingTable) require.NoError(t, err)