From ff001bc5a8c7ceb54eb8adc4901c6e6d6001a026 Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Tue, 28 Mar 2023 20:30:00 -0400 Subject: [PATCH] Migrate to a Protos data model for Notify Requests --- CHANGELOG.md | 1 + command/command.pb.go | 154 +++++++++++++++++++++++++++++++----------- command/command.proto | 5 ++ http/service.go | 7 +- http/service_test.go | 2 +- store/store.go | 6 +- store/store_test.go | 19 ++++-- 7 files changed, 141 insertions(+), 53 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37caac77..28b8171d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - [PR #1180](https://github.com/rqlite/rqlite/pull/1180): Support large numbers in requests. - [PR #1186](https://github.com/rqlite/rqlite/pull/1186): Improve read-only (non-voting) node management. Fixes [issue #1182](https://github.com/rqlite/rqlite/issues/1182). - [PR #1189](https://github.com/rqlite/rqlite/pull/1189): Migrate to a Protobuf data model for Join Requests. +- [PR #1190](https://github.com/rqlite/rqlite/pull/1190): Migrate to a Protobuf data model for Notify Requests. ## 7.14.1 (March 17th 2023) ## Implementation changes and bug fixes diff --git a/command/command.pb.go b/command/command.pb.go index 80530e47..2737130f 100644 --- a/command/command.pb.go +++ b/command/command.pb.go @@ -173,7 +173,7 @@ func (x Command_Type) Number() protoreflect.EnumNumber { // Deprecated: Use Command_Type.Descriptor instead. func (Command_Type) EnumDescriptor() ([]byte, []int) { - return file_command_proto_rawDescGZIP(), []int{13, 0} + return file_command_proto_rawDescGZIP(), []int{14, 0} } type Parameter struct { @@ -905,6 +905,61 @@ func (x *JoinRequest) GetVoter() bool { return false } +type NotifyRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` +} + +func (x *NotifyRequest) Reset() { + *x = NotifyRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_command_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NotifyRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NotifyRequest) ProtoMessage() {} + +func (x *NotifyRequest) ProtoReflect() protoreflect.Message { + mi := &file_command_proto_msgTypes[11] + 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 NotifyRequest.ProtoReflect.Descriptor instead. +func (*NotifyRequest) Descriptor() ([]byte, []int) { + return file_command_proto_rawDescGZIP(), []int{11} +} + +func (x *NotifyRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *NotifyRequest) GetAddress() string { + if x != nil { + return x.Address + } + return "" +} + type RemoveNodeRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -916,7 +971,7 @@ type RemoveNodeRequest struct { func (x *RemoveNodeRequest) Reset() { *x = RemoveNodeRequest{} if protoimpl.UnsafeEnabled { - mi := &file_command_proto_msgTypes[11] + mi := &file_command_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -929,7 +984,7 @@ func (x *RemoveNodeRequest) String() string { func (*RemoveNodeRequest) ProtoMessage() {} func (x *RemoveNodeRequest) ProtoReflect() protoreflect.Message { - mi := &file_command_proto_msgTypes[11] + mi := &file_command_proto_msgTypes[12] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -942,7 +997,7 @@ func (x *RemoveNodeRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RemoveNodeRequest.ProtoReflect.Descriptor instead. func (*RemoveNodeRequest) Descriptor() ([]byte, []int) { - return file_command_proto_rawDescGZIP(), []int{11} + return file_command_proto_rawDescGZIP(), []int{12} } func (x *RemoveNodeRequest) GetId() string { @@ -963,7 +1018,7 @@ type Noop struct { func (x *Noop) Reset() { *x = Noop{} if protoimpl.UnsafeEnabled { - mi := &file_command_proto_msgTypes[12] + mi := &file_command_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -976,7 +1031,7 @@ func (x *Noop) String() string { func (*Noop) ProtoMessage() {} func (x *Noop) ProtoReflect() protoreflect.Message { - mi := &file_command_proto_msgTypes[12] + mi := &file_command_proto_msgTypes[13] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -989,7 +1044,7 @@ func (x *Noop) ProtoReflect() protoreflect.Message { // Deprecated: Use Noop.ProtoReflect.Descriptor instead. func (*Noop) Descriptor() ([]byte, []int) { - return file_command_proto_rawDescGZIP(), []int{12} + return file_command_proto_rawDescGZIP(), []int{13} } func (x *Noop) GetId() string { @@ -1012,7 +1067,7 @@ type Command struct { func (x *Command) Reset() { *x = Command{} if protoimpl.UnsafeEnabled { - mi := &file_command_proto_msgTypes[13] + mi := &file_command_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1025,7 +1080,7 @@ func (x *Command) String() string { func (*Command) ProtoMessage() {} func (x *Command) ProtoReflect() protoreflect.Message { - mi := &file_command_proto_msgTypes[13] + mi := &file_command_proto_msgTypes[14] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1038,7 +1093,7 @@ func (x *Command) ProtoReflect() protoreflect.Message { // Deprecated: Use Command.ProtoReflect.Descriptor instead. func (*Command) Descriptor() ([]byte, []int) { - return file_command_proto_rawDescGZIP(), []int{13} + return file_command_proto_rawDescGZIP(), []int{14} } func (x *Command) GetType() Command_Type { @@ -1149,30 +1204,34 @@ var file_command_proto_rawDesc = []byte{ 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x6f, 0x74, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x76, 0x6f, 0x74, 0x65, 0x72, 0x22, - 0x23, 0x0a, 0x11, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x02, 0x69, 0x64, 0x22, 0x16, 0x0a, 0x04, 0x4e, 0x6f, 0x6f, 0x70, 0x12, 0x0e, 0x0a, 0x02, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x8f, 0x02, 0x0a, - 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x29, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, - 0x79, 0x70, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x75, 0x62, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, - 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x73, 0x75, 0x62, 0x43, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, - 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x63, 0x6f, 0x6d, 0x70, 0x72, 0x65, - 0x73, 0x73, 0x65, 0x64, 0x22, 0x97, 0x01, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, - 0x14, 0x43, 0x4f, 0x4d, 0x4d, 0x41, 0x4e, 0x44, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, - 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x16, 0x0a, 0x12, 0x43, 0x4f, 0x4d, 0x4d, 0x41, - 0x4e, 0x44, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x51, 0x55, 0x45, 0x52, 0x59, 0x10, 0x01, 0x12, - 0x18, 0x0a, 0x14, 0x43, 0x4f, 0x4d, 0x4d, 0x41, 0x4e, 0x44, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, - 0x45, 0x58, 0x45, 0x43, 0x55, 0x54, 0x45, 0x10, 0x02, 0x12, 0x15, 0x0a, 0x11, 0x43, 0x4f, 0x4d, - 0x4d, 0x41, 0x4e, 0x44, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4e, 0x4f, 0x4f, 0x50, 0x10, 0x03, - 0x12, 0x15, 0x0a, 0x11, 0x43, 0x4f, 0x4d, 0x4d, 0x41, 0x4e, 0x44, 0x5f, 0x54, 0x59, 0x50, 0x45, - 0x5f, 0x4c, 0x4f, 0x41, 0x44, 0x10, 0x04, 0x12, 0x15, 0x0a, 0x11, 0x43, 0x4f, 0x4d, 0x4d, 0x41, - 0x4e, 0x44, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4a, 0x4f, 0x49, 0x4e, 0x10, 0x05, 0x42, 0x22, - 0x5a, 0x20, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x71, 0x6c, - 0x69, 0x74, 0x65, 0x2f, 0x72, 0x71, 0x6c, 0x69, 0x74, 0x65, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, - 0x6e, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x39, 0x0a, 0x0d, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, + 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x23, 0x0a, 0x11, 0x52, 0x65, + 0x6d, 0x6f, 0x76, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, + 0x16, 0x0a, 0x04, 0x4e, 0x6f, 0x6f, 0x70, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x8f, 0x02, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x12, 0x29, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x15, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1f, + 0x0a, 0x0b, 0x73, 0x75, 0x62, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x73, 0x75, 0x62, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, + 0x1e, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x0a, 0x63, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x22, + 0x97, 0x01, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x14, 0x43, 0x4f, 0x4d, 0x4d, + 0x41, 0x4e, 0x44, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, + 0x10, 0x00, 0x12, 0x16, 0x0a, 0x12, 0x43, 0x4f, 0x4d, 0x4d, 0x41, 0x4e, 0x44, 0x5f, 0x54, 0x59, + 0x50, 0x45, 0x5f, 0x51, 0x55, 0x45, 0x52, 0x59, 0x10, 0x01, 0x12, 0x18, 0x0a, 0x14, 0x43, 0x4f, + 0x4d, 0x4d, 0x41, 0x4e, 0x44, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x45, 0x58, 0x45, 0x43, 0x55, + 0x54, 0x45, 0x10, 0x02, 0x12, 0x15, 0x0a, 0x11, 0x43, 0x4f, 0x4d, 0x4d, 0x41, 0x4e, 0x44, 0x5f, + 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4e, 0x4f, 0x4f, 0x50, 0x10, 0x03, 0x12, 0x15, 0x0a, 0x11, 0x43, + 0x4f, 0x4d, 0x4d, 0x41, 0x4e, 0x44, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4c, 0x4f, 0x41, 0x44, + 0x10, 0x04, 0x12, 0x15, 0x0a, 0x11, 0x43, 0x4f, 0x4d, 0x4d, 0x41, 0x4e, 0x44, 0x5f, 0x54, 0x59, + 0x50, 0x45, 0x5f, 0x4a, 0x4f, 0x49, 0x4e, 0x10, 0x05, 0x42, 0x22, 0x5a, 0x20, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x71, 0x6c, 0x69, 0x74, 0x65, 0x2f, 0x72, + 0x71, 0x6c, 0x69, 0x74, 0x65, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1188,7 +1247,7 @@ func file_command_proto_rawDescGZIP() []byte { } var file_command_proto_enumTypes = make([]protoimpl.EnumInfo, 3) -var file_command_proto_msgTypes = make([]protoimpl.MessageInfo, 14) +var file_command_proto_msgTypes = make([]protoimpl.MessageInfo, 15) var file_command_proto_goTypes = []interface{}{ (QueryRequest_Level)(0), // 0: command.QueryRequest.Level (BackupRequest_Format)(0), // 1: command.BackupRequest.Format @@ -1204,9 +1263,10 @@ var file_command_proto_goTypes = []interface{}{ (*BackupRequest)(nil), // 11: command.BackupRequest (*LoadRequest)(nil), // 12: command.LoadRequest (*JoinRequest)(nil), // 13: command.JoinRequest - (*RemoveNodeRequest)(nil), // 14: command.RemoveNodeRequest - (*Noop)(nil), // 15: command.Noop - (*Command)(nil), // 16: command.Command + (*NotifyRequest)(nil), // 14: command.NotifyRequest + (*RemoveNodeRequest)(nil), // 15: command.RemoveNodeRequest + (*Noop)(nil), // 16: command.Noop + (*Command)(nil), // 17: command.Command } var file_command_proto_depIdxs = []int32{ 3, // 0: command.Statement.parameters:type_name -> command.Parameter @@ -1364,7 +1424,7 @@ func file_command_proto_init() { } } file_command_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RemoveNodeRequest); i { + switch v := v.(*NotifyRequest); i { case 0: return &v.state case 1: @@ -1376,7 +1436,7 @@ func file_command_proto_init() { } } file_command_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Noop); i { + switch v := v.(*RemoveNodeRequest); i { case 0: return &v.state case 1: @@ -1388,6 +1448,18 @@ func file_command_proto_init() { } } file_command_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Noop); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_command_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Command); i { case 0: return &v.state @@ -1413,7 +1485,7 @@ func file_command_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_command_proto_rawDesc, NumEnums: 3, - NumMessages: 14, + NumMessages: 15, NumExtensions: 0, NumServices: 0, }, diff --git a/command/command.proto b/command/command.proto index 1d71ba0e..cdfee2c2 100644 --- a/command/command.proto +++ b/command/command.proto @@ -80,6 +80,11 @@ message JoinRequest { bool voter = 3; } +message NotifyRequest { + string id = 1; + string address = 2; +} + message RemoveNodeRequest { string id = 1; } diff --git a/http/service.go b/http/service.go index 3272b0ed..76497020 100644 --- a/http/service.go +++ b/http/service.go @@ -65,7 +65,7 @@ type Store interface { Join(jr *command.JoinRequest) error // Notify notifies this node that a node is available at addr. - Notify(id, addr string) error + Notify(nr *command.NotifyRequest) error // RemoveNode removes the node from the cluster. Remove(rn *command.RemoveNodeRequest) error @@ -577,7 +577,10 @@ func (s *Service) handleNotify(w http.ResponseWriter, r *http.Request) { return } - if err := s.store.Notify(remoteID, remoteAddr); err != nil { + if err := s.store.Notify(&command.NotifyRequest{ + Id: remoteID, + Address: remoteAddr, + }); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } } diff --git a/http/service_test.go b/http/service_test.go index 8e6c7591..d2041911 100644 --- a/http/service_test.go +++ b/http/service_test.go @@ -1210,7 +1210,7 @@ func (m *MockStore) Join(jr *command.JoinRequest) error { return nil } -func (m *MockStore) Notify(id, addr string) error { +func (m *MockStore) Notify(nr *command.NotifyRequest) error { return nil } diff --git a/store/store.go b/store/store.go index fc52a44d..8fa6d24d 100644 --- a/store/store.go +++ b/store/store.go @@ -978,7 +978,7 @@ func (s *Store) Load(lr *command.LoadRequest) error { // with the *advertised Raft address* which the Store doesn't know about. // // Notifying is idempotent. A node may repeatedly notify the Store without issue. -func (s *Store) Notify(id, addr string) error { +func (s *Store) Notify(nr *command.NotifyRequest) error { if !s.open { return ErrNotOpen } @@ -991,10 +991,10 @@ func (s *Store) Notify(id, addr string) error { return nil } - if _, ok := s.notifyingNodes[id]; ok { + if _, ok := s.notifyingNodes[nr.Id]; ok { return nil } - s.notifyingNodes[id] = &Server{id, addr, "voter"} + s.notifyingNodes[nr.Id] = &Server{nr.Id, nr.Address, "voter"} if len(s.notifyingNodes) < s.BootstrapExpect { return nil } diff --git a/store/store_test.go b/store/store_test.go index 7e5ca356..29789c25 100644 --- a/store/store_test.go +++ b/store/store_test.go @@ -44,7 +44,7 @@ func Test_StoreSingleNodeNotOpen(t *testing.T) { if err := s.Join(joinRequest("id", "localhost", true)); err != ErrNotOpen { t.Fatalf("wrong error received for non-open store: %s", err) } - if err := s.Notify("id", "localhost"); err != ErrNotOpen { + if err := s.Notify(notifyRequest("id", "localhost")); err != ErrNotOpen { t.Fatalf("wrong error received for non-open store: %s", err) } if err := s.Remove(nil); err != ErrNotOpen { @@ -1327,16 +1327,16 @@ func Test_MultiNodeStoreNotifyBootstrap(t *testing.T) { defer s2.Close(true) s0.BootstrapExpect = 3 - if err := s0.Notify(s0.ID(), ln0.Addr().String()); err != nil { + if err := s0.Notify(notifyRequest(s0.ID(), ln0.Addr().String())); err != nil { t.Fatalf("failed to notify store: %s", err.Error()) } - if err := s0.Notify(s0.ID(), ln0.Addr().String()); err != nil { + if err := s0.Notify(notifyRequest(s0.ID(), ln0.Addr().String())); err != nil { t.Fatalf("failed to notify store -- not idempotent: %s", err.Error()) } - if err := s0.Notify(s1.ID(), ln1.Addr().String()); err != nil { + if err := s0.Notify(notifyRequest(s1.ID(), ln1.Addr().String())); err != nil { t.Fatalf("failed to notify store: %s", err.Error()) } - if err := s0.Notify(s2.ID(), ln2.Addr().String()); err != nil { + if err := s0.Notify(notifyRequest(s2.ID(), ln2.Addr().String())); err != nil { t.Fatalf("failed to notify store: %s", err.Error()) } @@ -1381,7 +1381,7 @@ func Test_MultiNodeStoreNotifyBootstrap(t *testing.T) { // Calling Notify() on a node that is part of a cluster should // be a no-op. - if err := s0.Notify(s1.ID(), ln1.Addr().String()); err != nil { + if err := s0.Notify(notifyRequest(s1.ID(), ln1.Addr().String())); err != nil { t.Fatalf("failed to notify store that is part of cluster: %s", err.Error()) } } @@ -2284,6 +2284,13 @@ func joinRequest(id, addr string, voter bool) *command.JoinRequest { } } +func notifyRequest(id, addr string) *command.NotifyRequest { + return &command.NotifyRequest{ + Id: id, + Address: addr, + } +} + func removeNodeRequest(id string) *command.RemoveNodeRequest { return &command.RemoveNodeRequest{ Id: id,