From 2714587ec5e75cd8604fbb960ef4091628b21b64 Mon Sep 17 00:00:00 2001 From: Pasha Sviderski Date: Fri, 25 Jul 2025 19:30:59 +1000 Subject: [PATCH] feat: add RemoveMachine API endpoint to remove a machine from the cluster --- internal/machine/api/pb/cluster.pb.go | 933 +++++++++++---------- internal/machine/api/pb/cluster.proto | 34 +- internal/machine/api/pb/cluster_grpc.pb.go | 38 + internal/machine/cluster/cluster.go | 21 + internal/machine/store/store.go | 65 +- 5 files changed, 618 insertions(+), 473 deletions(-) diff --git a/internal/machine/api/pb/cluster.pb.go b/internal/machine/api/pb/cluster.pb.go index d0d33752..32bae120 100644 --- a/internal/machine/api/pb/cluster.pb.go +++ b/internal/machine/api/pb/cluster.pb.go @@ -124,7 +124,7 @@ func (x DNSRecord_RecordType) Number() protoreflect.EnumNumber { // Deprecated: Use DNSRecord_RecordType.Descriptor instead. func (DNSRecord_RecordType) EnumDescriptor() ([]byte, []int) { - return file_internal_machine_api_pb_cluster_proto_rawDescGZIP(), []int{8, 0} + return file_internal_machine_api_pb_cluster_proto_rawDescGZIP(), []int{11, 0} } type AddMachineRequest struct { @@ -339,257 +339,6 @@ func (x *ListMachinesResponse) GetMachines() []*MachineMember { return nil } -type Domain struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` -} - -func (x *Domain) Reset() { - *x = Domain{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Domain) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Domain) ProtoMessage() {} - -func (x *Domain) ProtoReflect() protoreflect.Message { - mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Domain.ProtoReflect.Descriptor instead. -func (*Domain) Descriptor() ([]byte, []int) { - return file_internal_machine_api_pb_cluster_proto_rawDescGZIP(), []int{4} -} - -func (x *Domain) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -type ReserveDomainRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Endpoint string `protobuf:"bytes,1,opt,name=endpoint,proto3" json:"endpoint,omitempty"` -} - -func (x *ReserveDomainRequest) Reset() { - *x = ReserveDomainRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ReserveDomainRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ReserveDomainRequest) ProtoMessage() {} - -func (x *ReserveDomainRequest) ProtoReflect() protoreflect.Message { - mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ReserveDomainRequest.ProtoReflect.Descriptor instead. -func (*ReserveDomainRequest) Descriptor() ([]byte, []int) { - return file_internal_machine_api_pb_cluster_proto_rawDescGZIP(), []int{5} -} - -func (x *ReserveDomainRequest) GetEndpoint() string { - if x != nil { - return x.Endpoint - } - return "" -} - -type CreateDomainRecordsRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Records []*DNSRecord `protobuf:"bytes,1,rep,name=records,proto3" json:"records,omitempty"` -} - -func (x *CreateDomainRecordsRequest) Reset() { - *x = CreateDomainRecordsRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CreateDomainRecordsRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateDomainRecordsRequest) ProtoMessage() {} - -func (x *CreateDomainRecordsRequest) ProtoReflect() protoreflect.Message { - mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[6] - 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 CreateDomainRecordsRequest.ProtoReflect.Descriptor instead. -func (*CreateDomainRecordsRequest) Descriptor() ([]byte, []int) { - return file_internal_machine_api_pb_cluster_proto_rawDescGZIP(), []int{6} -} - -func (x *CreateDomainRecordsRequest) GetRecords() []*DNSRecord { - if x != nil { - return x.Records - } - return nil -} - -type CreateDomainRecordsResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Records []*DNSRecord `protobuf:"bytes,1,rep,name=records,proto3" json:"records,omitempty"` -} - -func (x *CreateDomainRecordsResponse) Reset() { - *x = CreateDomainRecordsResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CreateDomainRecordsResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateDomainRecordsResponse) ProtoMessage() {} - -func (x *CreateDomainRecordsResponse) ProtoReflect() protoreflect.Message { - mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[7] - 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 CreateDomainRecordsResponse.ProtoReflect.Descriptor instead. -func (*CreateDomainRecordsResponse) Descriptor() ([]byte, []int) { - return file_internal_machine_api_pb_cluster_proto_rawDescGZIP(), []int{7} -} - -func (x *CreateDomainRecordsResponse) GetRecords() []*DNSRecord { - if x != nil { - return x.Records - } - return nil -} - -type DNSRecord struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Type DNSRecord_RecordType `protobuf:"varint,2,opt,name=type,proto3,enum=api.DNSRecord_RecordType" json:"type,omitempty"` - Values []string `protobuf:"bytes,3,rep,name=values,proto3" json:"values,omitempty"` -} - -func (x *DNSRecord) Reset() { - *x = DNSRecord{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DNSRecord) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DNSRecord) ProtoMessage() {} - -func (x *DNSRecord) ProtoReflect() protoreflect.Message { - mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[8] - 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 DNSRecord.ProtoReflect.Descriptor instead. -func (*DNSRecord) Descriptor() ([]byte, []int) { - return file_internal_machine_api_pb_cluster_proto_rawDescGZIP(), []int{8} -} - -func (x *DNSRecord) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *DNSRecord) GetType() DNSRecord_RecordType { - if x != nil { - return x.Type - } - return DNSRecord_UNSPECIFIED -} - -func (x *DNSRecord) GetValues() []string { - if x != nil { - return x.Values - } - return nil -} - type UpdateMachineRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -606,7 +355,7 @@ type UpdateMachineRequest struct { func (x *UpdateMachineRequest) Reset() { *x = UpdateMachineRequest{} if protoimpl.UnsafeEnabled { - mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[9] + mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -619,7 +368,7 @@ func (x *UpdateMachineRequest) String() string { func (*UpdateMachineRequest) ProtoMessage() {} func (x *UpdateMachineRequest) ProtoReflect() protoreflect.Message { - mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[9] + mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -632,7 +381,7 @@ func (x *UpdateMachineRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateMachineRequest.ProtoReflect.Descriptor instead. func (*UpdateMachineRequest) Descriptor() ([]byte, []int) { - return file_internal_machine_api_pb_cluster_proto_rawDescGZIP(), []int{9} + return file_internal_machine_api_pb_cluster_proto_rawDescGZIP(), []int{4} } func (x *UpdateMachineRequest) GetMachineId() string { @@ -674,7 +423,7 @@ type UpdateMachineResponse struct { func (x *UpdateMachineResponse) Reset() { *x = UpdateMachineResponse{} if protoimpl.UnsafeEnabled { - mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[10] + mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -687,7 +436,7 @@ func (x *UpdateMachineResponse) String() string { func (*UpdateMachineResponse) ProtoMessage() {} func (x *UpdateMachineResponse) ProtoReflect() protoreflect.Message { - mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[10] + mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -700,7 +449,7 @@ func (x *UpdateMachineResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateMachineResponse.ProtoReflect.Descriptor instead. func (*UpdateMachineResponse) Descriptor() ([]byte, []int) { - return file_internal_machine_api_pb_cluster_proto_rawDescGZIP(), []int{10} + return file_internal_machine_api_pb_cluster_proto_rawDescGZIP(), []int{5} } func (x *UpdateMachineResponse) GetMachine() *MachineInfo { @@ -710,6 +459,304 @@ func (x *UpdateMachineResponse) GetMachine() *MachineInfo { return nil } +type RemoveMachineRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *RemoveMachineRequest) Reset() { + *x = RemoveMachineRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RemoveMachineRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RemoveMachineRequest) ProtoMessage() {} + +func (x *RemoveMachineRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[6] + 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 RemoveMachineRequest.ProtoReflect.Descriptor instead. +func (*RemoveMachineRequest) Descriptor() ([]byte, []int) { + return file_internal_machine_api_pb_cluster_proto_rawDescGZIP(), []int{6} +} + +func (x *RemoveMachineRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +type Domain struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *Domain) Reset() { + *x = Domain{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Domain) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Domain) ProtoMessage() {} + +func (x *Domain) ProtoReflect() protoreflect.Message { + mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[7] + 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 Domain.ProtoReflect.Descriptor instead. +func (*Domain) Descriptor() ([]byte, []int) { + return file_internal_machine_api_pb_cluster_proto_rawDescGZIP(), []int{7} +} + +func (x *Domain) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +type ReserveDomainRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Endpoint string `protobuf:"bytes,1,opt,name=endpoint,proto3" json:"endpoint,omitempty"` +} + +func (x *ReserveDomainRequest) Reset() { + *x = ReserveDomainRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReserveDomainRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReserveDomainRequest) ProtoMessage() {} + +func (x *ReserveDomainRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[8] + 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 ReserveDomainRequest.ProtoReflect.Descriptor instead. +func (*ReserveDomainRequest) Descriptor() ([]byte, []int) { + return file_internal_machine_api_pb_cluster_proto_rawDescGZIP(), []int{8} +} + +func (x *ReserveDomainRequest) GetEndpoint() string { + if x != nil { + return x.Endpoint + } + return "" +} + +type CreateDomainRecordsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Records []*DNSRecord `protobuf:"bytes,1,rep,name=records,proto3" json:"records,omitempty"` +} + +func (x *CreateDomainRecordsRequest) Reset() { + *x = CreateDomainRecordsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateDomainRecordsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateDomainRecordsRequest) ProtoMessage() {} + +func (x *CreateDomainRecordsRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[9] + 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 CreateDomainRecordsRequest.ProtoReflect.Descriptor instead. +func (*CreateDomainRecordsRequest) Descriptor() ([]byte, []int) { + return file_internal_machine_api_pb_cluster_proto_rawDescGZIP(), []int{9} +} + +func (x *CreateDomainRecordsRequest) GetRecords() []*DNSRecord { + if x != nil { + return x.Records + } + return nil +} + +type CreateDomainRecordsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Records []*DNSRecord `protobuf:"bytes,1,rep,name=records,proto3" json:"records,omitempty"` +} + +func (x *CreateDomainRecordsResponse) Reset() { + *x = CreateDomainRecordsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateDomainRecordsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateDomainRecordsResponse) ProtoMessage() {} + +func (x *CreateDomainRecordsResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[10] + 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 CreateDomainRecordsResponse.ProtoReflect.Descriptor instead. +func (*CreateDomainRecordsResponse) Descriptor() ([]byte, []int) { + return file_internal_machine_api_pb_cluster_proto_rawDescGZIP(), []int{10} +} + +func (x *CreateDomainRecordsResponse) GetRecords() []*DNSRecord { + if x != nil { + return x.Records + } + return nil +} + +type DNSRecord struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Type DNSRecord_RecordType `protobuf:"varint,2,opt,name=type,proto3,enum=api.DNSRecord_RecordType" json:"type,omitempty"` + Values []string `protobuf:"bytes,3,rep,name=values,proto3" json:"values,omitempty"` +} + +func (x *DNSRecord) Reset() { + *x = DNSRecord{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_machine_api_pb_cluster_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DNSRecord) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DNSRecord) ProtoMessage() {} + +func (x *DNSRecord) ProtoReflect() protoreflect.Message { + mi := &file_internal_machine_api_pb_cluster_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 DNSRecord.ProtoReflect.Descriptor instead. +func (*DNSRecord) Descriptor() ([]byte, []int) { + return file_internal_machine_api_pb_cluster_proto_rawDescGZIP(), []int{11} +} + +func (x *DNSRecord) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *DNSRecord) GetType() DNSRecord_RecordType { + if x != nil { + return x.Type + } + return DNSRecord_UNSPECIFIED +} + +func (x *DNSRecord) GetValues() []string { + if x != nil { + return x.Values + } + return nil +} + var File_internal_machine_api_pb_cluster_proto protoreflect.FileDescriptor var file_internal_machine_api_pb_cluster_proto_rawDesc = []byte{ @@ -750,80 +797,87 @@ var file_internal_machine_api_pb_cluster_proto_rawDesc = []byte{ 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x08, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x08, 0x6d, 0x61, 0x63, 0x68, - 0x69, 0x6e, 0x65, 0x73, 0x22, 0x1c, 0x0a, 0x06, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x12, - 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x22, 0x32, 0x0a, 0x14, 0x52, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x44, 0x6f, 0x6d, - 0x61, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, - 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, - 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x22, 0x46, 0x0a, 0x1a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x28, 0x0a, 0x07, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x18, - 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x4e, 0x53, 0x52, - 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x07, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x22, 0x47, - 0x0a, 0x1b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x65, - 0x63, 0x6f, 0x72, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x28, 0x0a, - 0x07, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x4e, 0x53, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x07, - 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x22, 0x96, 0x01, 0x0a, 0x09, 0x44, 0x4e, 0x53, 0x52, - 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2d, 0x0a, 0x04, 0x74, 0x79, 0x70, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x19, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x4e, - 0x53, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x54, 0x79, - 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, - 0x22, 0x2e, 0x0a, 0x0a, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0f, - 0x0a, 0x0b, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, - 0x05, 0x0a, 0x01, 0x41, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x41, 0x41, 0x41, 0x41, 0x10, 0x02, - 0x22, 0xbb, 0x01, 0x0a, 0x14, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, - 0x6e, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x61, 0x63, - 0x68, 0x69, 0x6e, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6d, - 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x88, 0x01, - 0x01, 0x12, 0x29, 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x69, 0x70, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x49, 0x50, 0x48, 0x01, 0x52, - 0x08, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x49, 0x70, 0x88, 0x01, 0x01, 0x12, 0x29, 0x0a, 0x09, - 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x0b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x49, 0x50, 0x50, 0x6f, 0x72, 0x74, 0x52, 0x09, 0x65, 0x6e, - 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x6e, 0x61, 0x6d, 0x65, - 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x69, 0x70, 0x22, 0x43, - 0x0a, 0x15, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x07, 0x6d, 0x61, 0x63, 0x68, 0x69, - 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, - 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x07, 0x6d, 0x61, 0x63, 0x68, - 0x69, 0x6e, 0x65, 0x32, 0xce, 0x03, 0x0a, 0x07, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x12, - 0x3d, 0x0a, 0x0a, 0x41, 0x64, 0x64, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x12, 0x16, 0x2e, + 0x69, 0x6e, 0x65, 0x73, 0x22, 0xbb, 0x01, 0x0a, 0x14, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, + 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, + 0x0a, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x09, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x88, 0x01, 0x01, 0x12, 0x29, 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, + 0x69, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x49, + 0x50, 0x48, 0x01, 0x52, 0x08, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x49, 0x70, 0x88, 0x01, 0x01, + 0x12, 0x29, 0x0a, 0x09, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x18, 0x04, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x49, 0x50, 0x50, 0x6f, 0x72, 0x74, + 0x52, 0x09, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x42, 0x07, 0x0a, 0x05, 0x5f, + 0x6e, 0x61, 0x6d, 0x65, 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, + 0x69, 0x70, 0x22, 0x43, 0x0a, 0x15, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x63, 0x68, + 0x69, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x07, 0x6d, + 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x61, + 0x70, 0x69, 0x2e, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x07, + 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x22, 0x26, 0x0a, 0x14, 0x52, 0x65, 0x6d, 0x6f, 0x76, + 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 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, + 0x1c, 0x0a, 0x06, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x32, 0x0a, + 0x14, 0x52, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, + 0x74, 0x22, 0x46, 0x0a, 0x1a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, + 0x6e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x28, 0x0a, 0x07, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x0e, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x4e, 0x53, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, + 0x52, 0x07, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x22, 0x47, 0x0a, 0x1b, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x28, 0x0a, 0x07, 0x72, 0x65, 0x63, 0x6f, + 0x72, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x61, 0x70, 0x69, 0x2e, + 0x44, 0x4e, 0x53, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x07, 0x72, 0x65, 0x63, 0x6f, 0x72, + 0x64, 0x73, 0x22, 0x96, 0x01, 0x0a, 0x09, 0x44, 0x4e, 0x53, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2d, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x19, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x4e, 0x53, 0x52, 0x65, 0x63, 0x6f, + 0x72, 0x64, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, + 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x03, 0x20, + 0x03, 0x28, 0x09, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x22, 0x2e, 0x0a, 0x0a, 0x52, + 0x65, 0x63, 0x6f, 0x72, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x55, 0x4e, 0x53, + 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x05, 0x0a, 0x01, 0x41, 0x10, + 0x01, 0x12, 0x08, 0x0a, 0x04, 0x41, 0x41, 0x41, 0x41, 0x10, 0x02, 0x32, 0x92, 0x04, 0x0a, 0x07, + 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x12, 0x3d, 0x0a, 0x0a, 0x41, 0x64, 0x64, 0x4d, 0x61, + 0x63, 0x68, 0x69, 0x6e, 0x65, 0x12, 0x16, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x64, 0x64, 0x4d, + 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x64, 0x64, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x64, 0x64, 0x4d, - 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41, - 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x73, 0x12, 0x16, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x19, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x69, 0x73, - 0x74, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x46, 0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, - 0x6e, 0x65, 0x12, 0x19, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, - 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, - 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x37, 0x0a, 0x0d, 0x52, 0x65, 0x73, - 0x65, 0x72, 0x76, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x19, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x52, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x6f, 0x6d, 0x61, - 0x69, 0x6e, 0x12, 0x30, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, - 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x0b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x6f, - 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x34, 0x0a, 0x0d, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x44, - 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x0b, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x58, 0x0a, 0x13, 0x43, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, - 0x73, 0x12, 0x1f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x6f, - 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, - 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x37, 0x5a, 0x35, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x70, 0x73, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x6b, 0x69, 0x2f, 0x75, 0x6e, - 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x6d, - 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, + 0x63, 0x68, 0x69, 0x6e, 0x65, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x19, + 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x46, 0x0a, 0x0d, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x12, 0x19, 0x2e, 0x61, 0x70, 0x69, + 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x42, 0x0a, 0x0d, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, + 0x6e, 0x65, 0x12, 0x19, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4d, + 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x37, 0x0a, 0x0d, 0x52, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, + 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x19, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x73, + 0x65, 0x72, 0x76, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x0b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x30, + 0x0a, 0x09, 0x47, 0x65, 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x16, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, + 0x70, 0x74, 0x79, 0x1a, 0x0b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, + 0x12, 0x34, 0x0a, 0x0d, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, + 0x6e, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x0b, 0x2e, 0x61, 0x70, 0x69, 0x2e, + 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x58, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x12, 0x1f, 0x2e, + 0x61, 0x70, 0x69, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, + 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, + 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, + 0x6e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x42, 0x37, 0x5a, 0x35, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, + 0x73, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x6b, 0x69, 0x2f, 0x75, 0x6e, 0x63, 0x6c, 0x6f, 0x75, + 0x64, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x6d, 0x61, 0x63, 0x68, 0x69, + 0x6e, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -839,7 +893,7 @@ func file_internal_machine_api_pb_cluster_proto_rawDescGZIP() []byte { } var file_internal_machine_api_pb_cluster_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_internal_machine_api_pb_cluster_proto_msgTypes = make([]protoimpl.MessageInfo, 11) +var file_internal_machine_api_pb_cluster_proto_msgTypes = make([]protoimpl.MessageInfo, 12) var file_internal_machine_api_pb_cluster_proto_goTypes = []any{ (MachineMember_MembershipState)(0), // 0: api.MachineMember.MembershipState (DNSRecord_RecordType)(0), // 1: api.DNSRecord.RecordType @@ -847,48 +901,51 @@ var file_internal_machine_api_pb_cluster_proto_goTypes = []any{ (*AddMachineResponse)(nil), // 3: api.AddMachineResponse (*MachineMember)(nil), // 4: api.MachineMember (*ListMachinesResponse)(nil), // 5: api.ListMachinesResponse - (*Domain)(nil), // 6: api.Domain - (*ReserveDomainRequest)(nil), // 7: api.ReserveDomainRequest - (*CreateDomainRecordsRequest)(nil), // 8: api.CreateDomainRecordsRequest - (*CreateDomainRecordsResponse)(nil), // 9: api.CreateDomainRecordsResponse - (*DNSRecord)(nil), // 10: api.DNSRecord - (*UpdateMachineRequest)(nil), // 11: api.UpdateMachineRequest - (*UpdateMachineResponse)(nil), // 12: api.UpdateMachineResponse - (*NetworkConfig)(nil), // 13: api.NetworkConfig - (*IP)(nil), // 14: api.IP - (*MachineInfo)(nil), // 15: api.MachineInfo - (*IPPort)(nil), // 16: api.IPPort - (*emptypb.Empty)(nil), // 17: google.protobuf.Empty + (*UpdateMachineRequest)(nil), // 6: api.UpdateMachineRequest + (*UpdateMachineResponse)(nil), // 7: api.UpdateMachineResponse + (*RemoveMachineRequest)(nil), // 8: api.RemoveMachineRequest + (*Domain)(nil), // 9: api.Domain + (*ReserveDomainRequest)(nil), // 10: api.ReserveDomainRequest + (*CreateDomainRecordsRequest)(nil), // 11: api.CreateDomainRecordsRequest + (*CreateDomainRecordsResponse)(nil), // 12: api.CreateDomainRecordsResponse + (*DNSRecord)(nil), // 13: api.DNSRecord + (*NetworkConfig)(nil), // 14: api.NetworkConfig + (*IP)(nil), // 15: api.IP + (*MachineInfo)(nil), // 16: api.MachineInfo + (*IPPort)(nil), // 17: api.IPPort + (*emptypb.Empty)(nil), // 18: google.protobuf.Empty } var file_internal_machine_api_pb_cluster_proto_depIdxs = []int32{ - 13, // 0: api.AddMachineRequest.network:type_name -> api.NetworkConfig - 14, // 1: api.AddMachineRequest.public_ip:type_name -> api.IP - 15, // 2: api.AddMachineResponse.machine:type_name -> api.MachineInfo - 15, // 3: api.MachineMember.machine:type_name -> api.MachineInfo + 14, // 0: api.AddMachineRequest.network:type_name -> api.NetworkConfig + 15, // 1: api.AddMachineRequest.public_ip:type_name -> api.IP + 16, // 2: api.AddMachineResponse.machine:type_name -> api.MachineInfo + 16, // 3: api.MachineMember.machine:type_name -> api.MachineInfo 0, // 4: api.MachineMember.state:type_name -> api.MachineMember.MembershipState 4, // 5: api.ListMachinesResponse.machines:type_name -> api.MachineMember - 10, // 6: api.CreateDomainRecordsRequest.records:type_name -> api.DNSRecord - 10, // 7: api.CreateDomainRecordsResponse.records:type_name -> api.DNSRecord - 1, // 8: api.DNSRecord.type:type_name -> api.DNSRecord.RecordType - 14, // 9: api.UpdateMachineRequest.public_ip:type_name -> api.IP - 16, // 10: api.UpdateMachineRequest.endpoints:type_name -> api.IPPort - 15, // 11: api.UpdateMachineResponse.machine:type_name -> api.MachineInfo + 15, // 6: api.UpdateMachineRequest.public_ip:type_name -> api.IP + 17, // 7: api.UpdateMachineRequest.endpoints:type_name -> api.IPPort + 16, // 8: api.UpdateMachineResponse.machine:type_name -> api.MachineInfo + 13, // 9: api.CreateDomainRecordsRequest.records:type_name -> api.DNSRecord + 13, // 10: api.CreateDomainRecordsResponse.records:type_name -> api.DNSRecord + 1, // 11: api.DNSRecord.type:type_name -> api.DNSRecord.RecordType 2, // 12: api.Cluster.AddMachine:input_type -> api.AddMachineRequest - 17, // 13: api.Cluster.ListMachines:input_type -> google.protobuf.Empty - 11, // 14: api.Cluster.UpdateMachine:input_type -> api.UpdateMachineRequest - 7, // 15: api.Cluster.ReserveDomain:input_type -> api.ReserveDomainRequest - 17, // 16: api.Cluster.GetDomain:input_type -> google.protobuf.Empty - 17, // 17: api.Cluster.ReleaseDomain:input_type -> google.protobuf.Empty - 8, // 18: api.Cluster.CreateDomainRecords:input_type -> api.CreateDomainRecordsRequest - 3, // 19: api.Cluster.AddMachine:output_type -> api.AddMachineResponse - 5, // 20: api.Cluster.ListMachines:output_type -> api.ListMachinesResponse - 12, // 21: api.Cluster.UpdateMachine:output_type -> api.UpdateMachineResponse - 6, // 22: api.Cluster.ReserveDomain:output_type -> api.Domain - 6, // 23: api.Cluster.GetDomain:output_type -> api.Domain - 6, // 24: api.Cluster.ReleaseDomain:output_type -> api.Domain - 9, // 25: api.Cluster.CreateDomainRecords:output_type -> api.CreateDomainRecordsResponse - 19, // [19:26] is the sub-list for method output_type - 12, // [12:19] is the sub-list for method input_type + 18, // 13: api.Cluster.ListMachines:input_type -> google.protobuf.Empty + 6, // 14: api.Cluster.UpdateMachine:input_type -> api.UpdateMachineRequest + 8, // 15: api.Cluster.RemoveMachine:input_type -> api.RemoveMachineRequest + 10, // 16: api.Cluster.ReserveDomain:input_type -> api.ReserveDomainRequest + 18, // 17: api.Cluster.GetDomain:input_type -> google.protobuf.Empty + 18, // 18: api.Cluster.ReleaseDomain:input_type -> google.protobuf.Empty + 11, // 19: api.Cluster.CreateDomainRecords:input_type -> api.CreateDomainRecordsRequest + 3, // 20: api.Cluster.AddMachine:output_type -> api.AddMachineResponse + 5, // 21: api.Cluster.ListMachines:output_type -> api.ListMachinesResponse + 7, // 22: api.Cluster.UpdateMachine:output_type -> api.UpdateMachineResponse + 18, // 23: api.Cluster.RemoveMachine:output_type -> google.protobuf.Empty + 9, // 24: api.Cluster.ReserveDomain:output_type -> api.Domain + 9, // 25: api.Cluster.GetDomain:output_type -> api.Domain + 9, // 26: api.Cluster.ReleaseDomain:output_type -> api.Domain + 12, // 27: api.Cluster.CreateDomainRecords:output_type -> api.CreateDomainRecordsResponse + 20, // [20:28] is the sub-list for method output_type + 12, // [12:20] is the sub-list for method input_type 12, // [12:12] is the sub-list for extension type_name 12, // [12:12] is the sub-list for extension extendee 0, // [0:12] is the sub-list for field type_name @@ -951,66 +1008,6 @@ func file_internal_machine_api_pb_cluster_proto_init() { } } file_internal_machine_api_pb_cluster_proto_msgTypes[4].Exporter = func(v any, i int) any { - switch v := v.(*Domain); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_machine_api_pb_cluster_proto_msgTypes[5].Exporter = func(v any, i int) any { - switch v := v.(*ReserveDomainRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_machine_api_pb_cluster_proto_msgTypes[6].Exporter = func(v any, i int) any { - switch v := v.(*CreateDomainRecordsRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_machine_api_pb_cluster_proto_msgTypes[7].Exporter = func(v any, i int) any { - switch v := v.(*CreateDomainRecordsResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_machine_api_pb_cluster_proto_msgTypes[8].Exporter = func(v any, i int) any { - switch v := v.(*DNSRecord); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_machine_api_pb_cluster_proto_msgTypes[9].Exporter = func(v any, i int) any { switch v := v.(*UpdateMachineRequest); i { case 0: return &v.state @@ -1022,7 +1019,7 @@ func file_internal_machine_api_pb_cluster_proto_init() { return nil } } - file_internal_machine_api_pb_cluster_proto_msgTypes[10].Exporter = func(v any, i int) any { + file_internal_machine_api_pb_cluster_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*UpdateMachineResponse); i { case 0: return &v.state @@ -1034,15 +1031,87 @@ func file_internal_machine_api_pb_cluster_proto_init() { return nil } } + file_internal_machine_api_pb_cluster_proto_msgTypes[6].Exporter = func(v any, i int) any { + switch v := v.(*RemoveMachineRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_machine_api_pb_cluster_proto_msgTypes[7].Exporter = func(v any, i int) any { + switch v := v.(*Domain); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_machine_api_pb_cluster_proto_msgTypes[8].Exporter = func(v any, i int) any { + switch v := v.(*ReserveDomainRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_machine_api_pb_cluster_proto_msgTypes[9].Exporter = func(v any, i int) any { + switch v := v.(*CreateDomainRecordsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_machine_api_pb_cluster_proto_msgTypes[10].Exporter = func(v any, i int) any { + switch v := v.(*CreateDomainRecordsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_machine_api_pb_cluster_proto_msgTypes[11].Exporter = func(v any, i int) any { + switch v := v.(*DNSRecord); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } - file_internal_machine_api_pb_cluster_proto_msgTypes[9].OneofWrappers = []any{} + file_internal_machine_api_pb_cluster_proto_msgTypes[4].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_internal_machine_api_pb_cluster_proto_rawDesc, NumEnums: 2, - NumMessages: 11, + NumMessages: 12, NumExtensions: 0, NumServices: 1, }, diff --git a/internal/machine/api/pb/cluster.proto b/internal/machine/api/pb/cluster.proto index fe08f8cf..09cfaded 100644 --- a/internal/machine/api/pb/cluster.proto +++ b/internal/machine/api/pb/cluster.proto @@ -12,7 +12,7 @@ service Cluster { rpc AddMachine(AddMachineRequest) returns (AddMachineResponse); rpc ListMachines(google.protobuf.Empty) returns (ListMachinesResponse); rpc UpdateMachine(UpdateMachineRequest) returns (UpdateMachineResponse); - // TODO: add RemoveMachine (see stashed changes) + rpc RemoveMachine(RemoveMachineRequest) returns (google.protobuf.Empty); rpc ReserveDomain(ReserveDomainRequest) returns (Domain); rpc GetDomain(google.protobuf.Empty) returns (Domain); @@ -51,6 +51,24 @@ message ListMachinesResponse { repeated MachineMember machines = 1; } +message UpdateMachineRequest { + // Machine to update + string machine_id = 1; + + // Updated machine information + optional string name = 2; + optional IP public_ip = 3; + repeated IPPort endpoints = 4; +} + +message UpdateMachineResponse { + MachineInfo machine = 1; +} + +message RemoveMachineRequest { + string id = 1; +} + message Domain { string name = 1; } @@ -78,17 +96,3 @@ message DNSRecord { RecordType type = 2; repeated string values = 3; } - -message UpdateMachineRequest { - // Machine to update - string machine_id = 1; - - // Updated machine information - optional string name = 2; - optional IP public_ip = 3; - repeated IPPort endpoints = 4; -} - -message UpdateMachineResponse { - MachineInfo machine = 1; -} diff --git a/internal/machine/api/pb/cluster_grpc.pb.go b/internal/machine/api/pb/cluster_grpc.pb.go index b88f418f..539e3cce 100644 --- a/internal/machine/api/pb/cluster_grpc.pb.go +++ b/internal/machine/api/pb/cluster_grpc.pb.go @@ -23,6 +23,7 @@ const ( Cluster_AddMachine_FullMethodName = "/api.Cluster/AddMachine" Cluster_ListMachines_FullMethodName = "/api.Cluster/ListMachines" Cluster_UpdateMachine_FullMethodName = "/api.Cluster/UpdateMachine" + Cluster_RemoveMachine_FullMethodName = "/api.Cluster/RemoveMachine" Cluster_ReserveDomain_FullMethodName = "/api.Cluster/ReserveDomain" Cluster_GetDomain_FullMethodName = "/api.Cluster/GetDomain" Cluster_ReleaseDomain_FullMethodName = "/api.Cluster/ReleaseDomain" @@ -36,6 +37,7 @@ type ClusterClient interface { AddMachine(ctx context.Context, in *AddMachineRequest, opts ...grpc.CallOption) (*AddMachineResponse, error) ListMachines(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ListMachinesResponse, error) UpdateMachine(ctx context.Context, in *UpdateMachineRequest, opts ...grpc.CallOption) (*UpdateMachineResponse, error) + RemoveMachine(ctx context.Context, in *RemoveMachineRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) ReserveDomain(ctx context.Context, in *ReserveDomainRequest, opts ...grpc.CallOption) (*Domain, error) GetDomain(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*Domain, error) ReleaseDomain(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*Domain, error) @@ -80,6 +82,16 @@ func (c *clusterClient) UpdateMachine(ctx context.Context, in *UpdateMachineRequ return out, nil } +func (c *clusterClient) RemoveMachine(ctx context.Context, in *RemoveMachineRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, Cluster_RemoveMachine_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *clusterClient) ReserveDomain(ctx context.Context, in *ReserveDomainRequest, opts ...grpc.CallOption) (*Domain, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Domain) @@ -127,6 +139,7 @@ type ClusterServer interface { AddMachine(context.Context, *AddMachineRequest) (*AddMachineResponse, error) ListMachines(context.Context, *emptypb.Empty) (*ListMachinesResponse, error) UpdateMachine(context.Context, *UpdateMachineRequest) (*UpdateMachineResponse, error) + RemoveMachine(context.Context, *RemoveMachineRequest) (*emptypb.Empty, error) ReserveDomain(context.Context, *ReserveDomainRequest) (*Domain, error) GetDomain(context.Context, *emptypb.Empty) (*Domain, error) ReleaseDomain(context.Context, *emptypb.Empty) (*Domain, error) @@ -150,6 +163,9 @@ func (UnimplementedClusterServer) ListMachines(context.Context, *emptypb.Empty) func (UnimplementedClusterServer) UpdateMachine(context.Context, *UpdateMachineRequest) (*UpdateMachineResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateMachine not implemented") } +func (UnimplementedClusterServer) RemoveMachine(context.Context, *RemoveMachineRequest) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method RemoveMachine not implemented") +} func (UnimplementedClusterServer) ReserveDomain(context.Context, *ReserveDomainRequest) (*Domain, error) { return nil, status.Errorf(codes.Unimplemented, "method ReserveDomain not implemented") } @@ -237,6 +253,24 @@ func _Cluster_UpdateMachine_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } +func _Cluster_RemoveMachine_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RemoveMachineRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ClusterServer).RemoveMachine(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Cluster_RemoveMachine_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ClusterServer).RemoveMachine(ctx, req.(*RemoveMachineRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Cluster_ReserveDomain_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ReserveDomainRequest) if err := dec(in); err != nil { @@ -328,6 +362,10 @@ var Cluster_ServiceDesc = grpc.ServiceDesc{ MethodName: "UpdateMachine", Handler: _Cluster_UpdateMachine_Handler, }, + { + MethodName: "RemoveMachine", + Handler: _Cluster_RemoveMachine_Handler, + }, { MethodName: "ReserveDomain", Handler: _Cluster_ReserveDomain_Handler, diff --git a/internal/machine/cluster/cluster.go b/internal/machine/cluster/cluster.go index 719cca37..64b37111 100644 --- a/internal/machine/cluster/cluster.go +++ b/internal/machine/cluster/cluster.go @@ -326,3 +326,24 @@ func (c *Cluster) ListMachines(ctx context.Context, _ *emptypb.Empty) (*pb.ListM return &pb.ListMachinesResponse{Machines: members}, nil } + +// RemoveMachine removes a machine from the cluster. +func (c *Cluster) RemoveMachine(ctx context.Context, req *pb.RemoveMachineRequest) (*emptypb.Empty, error) { + if err := c.checkInitialised(ctx); err != nil { + return nil, err + } + + if req.Id == "" { + return nil, status.Error(codes.InvalidArgument, "machine ID not set") + } + + if err := c.store.DeleteMachine(ctx, req.Id); err != nil { + if errors.Is(err, store.ErrMachineNotFound) { + return nil, status.Errorf(codes.NotFound, "machine not found: %s", req.Id) + } + return nil, status.Errorf(codes.Internal, "delete machine from store: %v", err) + } + slog.Info("Machine removed from the cluster.", "id", req.Id) + + return &emptypb.Empty{}, nil +} diff --git a/internal/machine/store/store.go b/internal/machine/store/store.go index 45b0d8fb..58d44e05 100644 --- a/internal/machine/store/store.go +++ b/internal/machine/store/store.go @@ -68,32 +68,6 @@ func (s *Store) CreateMachine(ctx context.Context, m *pb.MachineInfo) error { return nil } -func (s *Store) UpdateMachine(ctx context.Context, m *pb.MachineInfo) error { - if m == nil { - return fmt.Errorf("machine info cannot be nil") - } - if m.Id == "" { - return fmt.Errorf("machine ID cannot be empty") - } - - mJSON, err := protojson.Marshal(m) - if err != nil { - return fmt.Errorf("marshal machine info: %w", err) - } - - result, err := s.corro.ExecContext(ctx, "UPDATE machines SET info = ? WHERE id = ?", string(mJSON), m.Id) - if err != nil { - return fmt.Errorf("update machine: %w", err) - } - - // Check if machine exists - if result.RowsAffected == 0 { - return fmt.Errorf("%w: %s", ErrMachineNotFound, m.Id) - } - - return nil -} - func (s *Store) GetMachine(ctx context.Context, machineID string) (*pb.MachineInfo, error) { if machineID == "" { return nil, fmt.Errorf("machine ID cannot be empty") @@ -170,6 +144,45 @@ func (s *Store) ListMachines(ctx context.Context) ([]*pb.MachineInfo, error) { return machines, nil } +func (s *Store) UpdateMachine(ctx context.Context, m *pb.MachineInfo) error { + if m == nil { + return fmt.Errorf("machine info cannot be nil") + } + if m.Id == "" { + return fmt.Errorf("machine ID cannot be empty") + } + + mJSON, err := protojson.Marshal(m) + if err != nil { + return fmt.Errorf("marshal machine info: %w", err) + } + + result, err := s.corro.ExecContext(ctx, "UPDATE machines SET info = ? WHERE id = ?", string(mJSON), m.Id) + if err != nil { + return fmt.Errorf("update machine: %w", err) + } + + // Check if machine exists + if result.RowsAffected == 0 { + return fmt.Errorf("%w: %s", ErrMachineNotFound, m.Id) + } + + return nil +} + +func (s *Store) DeleteMachine(ctx context.Context, id string) error { + result, err := s.corro.ExecContext(ctx, "DELETE FROM machines WHERE id = ?", id) + if err != nil { + return fmt.Errorf("delete machine: %w", err) + } + // Check if machine was deleted. + if result.RowsAffected == 0 { + return fmt.Errorf("%w: %s", ErrMachineNotFound, id) + } + + return nil +} + // SubscribeMachines returns a list of machines and a channel that signals changes to the list. The channel doesn't // receive any values, it just signals when a machine has been added, updated, or deleted in the database. func (s *Store) SubscribeMachines(ctx context.Context) ([]*pb.MachineInfo, <-chan struct{}, error) {