diff --git a/api/buf.yaml b/api/buf.yaml index 8221480214..679c6ebcde 100644 --- a/api/buf.yaml +++ b/api/buf.yaml @@ -1,4 +1,5 @@ version: v1 +name: buf.build/pyroscope/api lint: use: - DEFAULT diff --git a/api/gen/proto/go/settings/v1/setting.pb.go b/api/gen/proto/go/settings/v1/setting.pb.go index 81e54c1dce..292e87e6d1 100644 --- a/api/gen/proto/go/settings/v1/setting.pb.go +++ b/api/gen/proto/go/settings/v1/setting.pb.go @@ -7,6 +7,7 @@ package settingsv1 import ( + v1 "github.com/grafana/pyroscope/api/gen/proto/go/types/v1" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -20,6 +21,144 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// CollectionRuleAction is the action to be performed on relabeling. +// aligns to https://github.com/prometheus/prometheus/blob/f24ce00320f8605add7c7c5e69f722193c066672/model/relabel/relabel.go#L40-L66 +type CollectionRuleAction int32 + +const ( + CollectionRuleAction_COLLECTION_RULE_ACTION_UNSPECIFIED CollectionRuleAction = 0 + // Replace performs a regex replacement. + CollectionRuleAction_COLLECTION_RULE_ACTION_REPLACE CollectionRuleAction = 1 + // Keep drops targets for which the input does not match the regex. + CollectionRuleAction_COLLECTION_RULE_ACTION_KEEP CollectionRuleAction = 2 + // Drop drops targets for which the input does match the regex. + CollectionRuleAction_COLLECTION_RULE_ACTION_DROP CollectionRuleAction = 3 + // KeepEqual drops targets for which the input does not match the target. + CollectionRuleAction_COLLECTION_RULE_ACTION_KEEP_EQUAL CollectionRuleAction = 4 + // DropEqual drops targets for which the input does match the target. + CollectionRuleAction_COLLECTION_RULE_ACTION_DROP_EQUAL CollectionRuleAction = 5 + // HashMod sets a label to the modulus of a hash of labels. + CollectionRuleAction_COLLECTION_RULE_ACTION_HASHMOD CollectionRuleAction = 6 + // LabelMap copies labels to other labelnames based on a regex. + CollectionRuleAction_COLLECTION_RULE_ACTION_LABELMAP CollectionRuleAction = 7 + // LabelDrop drops any label matching the regex. + CollectionRuleAction_COLLECTION_RULE_ACTION_LABELDROP CollectionRuleAction = 8 + // LabelKeep drops any label not matching the regex. + CollectionRuleAction_COLLECTION_RULE_ACTION_LABELKEEP CollectionRuleAction = 9 + // Lowercase maps input letters to their lower case. + CollectionRuleAction_COLLECTION_RULE_ACTION_LOWERCASE CollectionRuleAction = 10 + // Uppercase maps input letters to their upper case. + CollectionRuleAction_COLLECTION_RULE_ACTION_UPPERCASE CollectionRuleAction = 11 +) + +// Enum value maps for CollectionRuleAction. +var ( + CollectionRuleAction_name = map[int32]string{ + 0: "COLLECTION_RULE_ACTION_UNSPECIFIED", + 1: "COLLECTION_RULE_ACTION_REPLACE", + 2: "COLLECTION_RULE_ACTION_KEEP", + 3: "COLLECTION_RULE_ACTION_DROP", + 4: "COLLECTION_RULE_ACTION_KEEP_EQUAL", + 5: "COLLECTION_RULE_ACTION_DROP_EQUAL", + 6: "COLLECTION_RULE_ACTION_HASHMOD", + 7: "COLLECTION_RULE_ACTION_LABELMAP", + 8: "COLLECTION_RULE_ACTION_LABELDROP", + 9: "COLLECTION_RULE_ACTION_LABELKEEP", + 10: "COLLECTION_RULE_ACTION_LOWERCASE", + 11: "COLLECTION_RULE_ACTION_UPPERCASE", + } + CollectionRuleAction_value = map[string]int32{ + "COLLECTION_RULE_ACTION_UNSPECIFIED": 0, + "COLLECTION_RULE_ACTION_REPLACE": 1, + "COLLECTION_RULE_ACTION_KEEP": 2, + "COLLECTION_RULE_ACTION_DROP": 3, + "COLLECTION_RULE_ACTION_KEEP_EQUAL": 4, + "COLLECTION_RULE_ACTION_DROP_EQUAL": 5, + "COLLECTION_RULE_ACTION_HASHMOD": 6, + "COLLECTION_RULE_ACTION_LABELMAP": 7, + "COLLECTION_RULE_ACTION_LABELDROP": 8, + "COLLECTION_RULE_ACTION_LABELKEEP": 9, + "COLLECTION_RULE_ACTION_LOWERCASE": 10, + "COLLECTION_RULE_ACTION_UPPERCASE": 11, + } +) + +func (x CollectionRuleAction) Enum() *CollectionRuleAction { + p := new(CollectionRuleAction) + *p = x + return p +} + +func (x CollectionRuleAction) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (CollectionRuleAction) Descriptor() protoreflect.EnumDescriptor { + return file_settings_v1_setting_proto_enumTypes[0].Descriptor() +} + +func (CollectionRuleAction) Type() protoreflect.EnumType { + return &file_settings_v1_setting_proto_enumTypes[0] +} + +func (x CollectionRuleAction) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use CollectionRuleAction.Descriptor instead. +func (CollectionRuleAction) EnumDescriptor() ([]byte, []int) { + return file_settings_v1_setting_proto_rawDescGZIP(), []int{0} +} + +type Status int32 + +const ( + Status_STATUS_UNSPECIFIED Status = 0 + Status_STATUS_OK Status = 1 + Status_STATUS_ERROR Status = 2 +) + +// Enum value maps for Status. +var ( + Status_name = map[int32]string{ + 0: "STATUS_UNSPECIFIED", + 1: "STATUS_OK", + 2: "STATUS_ERROR", + } + Status_value = map[string]int32{ + "STATUS_UNSPECIFIED": 0, + "STATUS_OK": 1, + "STATUS_ERROR": 2, + } +) + +func (x Status) Enum() *Status { + p := new(Status) + *p = x + return p +} + +func (x Status) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Status) Descriptor() protoreflect.EnumDescriptor { + return file_settings_v1_setting_proto_enumTypes[1].Descriptor() +} + +func (Status) Type() protoreflect.EnumType { + return &file_settings_v1_setting_proto_enumTypes[1] +} + +func (x Status) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Status.Descriptor instead. +func (Status) EnumDescriptor() ([]byte, []int) { + return file_settings_v1_setting_proto_rawDescGZIP(), []int{1} +} + type GetSettingsRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -262,55 +401,764 @@ func (x *Setting) GetModifiedAt() int64 { return 0 } +// CollectionRule is the configuration for relabeling of target label sets. +// aligns to https://github.com/prometheus/prometheus/blob/f24ce00320f8605add7c7c5e69f722193c066672/model/relabel/relabel.go#L82C1-L100C2 +type CollectionRule struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // A list of labels from which values are taken and concatenated + // with the configured separator in order. + SourceLabels []string `protobuf:"bytes,2,rep,name=source_labels,json=sourceLabels,proto3" json:"source_labels,omitempty"` + // separator is the string between concatenated values from the source labels. + Separator *string `protobuf:"bytes,3,opt,name=separator,proto3,oneof" json:"separator,omitempty"` + // regex against which the concatenation is matched. + Regex *string `protobuf:"bytes,4,opt,name=regex,proto3,oneof" json:"regex,omitempty"` + // modulus to take of the hash of concatenated values from the source labels. + Modulus *uint64 `protobuf:"varint,5,opt,name=modulus,proto3,oneof" json:"modulus,omitempty"` + // target_label is the label to which the resulting string is written in a replacement. + // Regexp interpolation is allowed for the replace action. + TargetLabel *string `protobuf:"bytes,6,opt,name=target_label,json=targetLabel,proto3,oneof" json:"target_label,omitempty"` + // replacement is the regex replacement pattern to be used. + Replacement *string `protobuf:"bytes,7,opt,name=replacement,proto3,oneof" json:"replacement,omitempty"` + // action is the action to be performed for the relabeling. + Action CollectionRuleAction `protobuf:"varint,8,opt,name=action,proto3,enum=settings.v1.CollectionRuleAction" json:"action,omitempty"` +} + +func (x *CollectionRule) Reset() { + *x = CollectionRule{} + if protoimpl.UnsafeEnabled { + mi := &file_settings_v1_setting_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CollectionRule) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CollectionRule) ProtoMessage() {} + +func (x *CollectionRule) ProtoReflect() protoreflect.Message { + mi := &file_settings_v1_setting_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 CollectionRule.ProtoReflect.Descriptor instead. +func (*CollectionRule) Descriptor() ([]byte, []int) { + return file_settings_v1_setting_proto_rawDescGZIP(), []int{5} +} + +func (x *CollectionRule) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *CollectionRule) GetSourceLabels() []string { + if x != nil { + return x.SourceLabels + } + return nil +} + +func (x *CollectionRule) GetSeparator() string { + if x != nil && x.Separator != nil { + return *x.Separator + } + return "" +} + +func (x *CollectionRule) GetRegex() string { + if x != nil && x.Regex != nil { + return *x.Regex + } + return "" +} + +func (x *CollectionRule) GetModulus() uint64 { + if x != nil && x.Modulus != nil { + return *x.Modulus + } + return 0 +} + +func (x *CollectionRule) GetTargetLabel() string { + if x != nil && x.TargetLabel != nil { + return *x.TargetLabel + } + return "" +} + +func (x *CollectionRule) GetReplacement() string { + if x != nil && x.Replacement != nil { + return *x.Replacement + } + return "" +} + +func (x *CollectionRule) GetAction() CollectionRuleAction { + if x != nil { + return x.Action + } + return CollectionRuleAction_COLLECTION_RULE_ACTION_UNSPECIFIED +} + +// CollectionRuleStore is how the message gets stored in object store +type CollectionRuleStore struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Rules []*CollectionRule `protobuf:"bytes,1,rep,name=rules,proto3" json:"rules,omitempty"` + LastUpdated int64 `protobuf:"varint,2,opt,name=last_updated,json=lastUpdated,proto3" json:"last_updated,omitempty"` // milliseconds unix time +} + +func (x *CollectionRuleStore) Reset() { + *x = CollectionRuleStore{} + if protoimpl.UnsafeEnabled { + mi := &file_settings_v1_setting_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CollectionRuleStore) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CollectionRuleStore) ProtoMessage() {} + +func (x *CollectionRuleStore) ProtoReflect() protoreflect.Message { + mi := &file_settings_v1_setting_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 CollectionRuleStore.ProtoReflect.Descriptor instead. +func (*CollectionRuleStore) Descriptor() ([]byte, []int) { + return file_settings_v1_setting_proto_rawDescGZIP(), []int{6} +} + +func (x *CollectionRuleStore) GetRules() []*CollectionRule { + if x != nil { + return x.Rules + } + return nil +} + +func (x *CollectionRuleStore) GetLastUpdated() int64 { + if x != nil { + return x.LastUpdated + } + return 0 +} + +type CollectionTarget struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Labels []*v1.LabelPair `protobuf:"bytes,1,rep,name=labels,proto3" json:"labels,omitempty"` +} + +func (x *CollectionTarget) Reset() { + *x = CollectionTarget{} + if protoimpl.UnsafeEnabled { + mi := &file_settings_v1_setting_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CollectionTarget) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CollectionTarget) ProtoMessage() {} + +func (x *CollectionTarget) ProtoReflect() protoreflect.Message { + mi := &file_settings_v1_setting_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 CollectionTarget.ProtoReflect.Descriptor instead. +func (*CollectionTarget) Descriptor() ([]byte, []int) { + return file_settings_v1_setting_proto_rawDescGZIP(), []int{7} +} + +func (x *CollectionTarget) GetLabels() []*v1.LabelPair { + if x != nil { + return x.Labels + } + return nil +} + +// CollectionInstance represents a single instance of the collection agent (generally Grafana Alloy) +type CollectionInstance struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Hostname string `protobuf:"bytes,1,opt,name=hostname,proto3" json:"hostname,omitempty"` + Targets []*CollectionTarget `protobuf:"bytes,2,rep,name=targets,proto3" json:"targets,omitempty"` + LastUpdated int64 `protobuf:"varint,3,opt,name=last_updated,json=lastUpdated,proto3" json:"last_updated,omitempty"` // milliseconds unix time +} + +func (x *CollectionInstance) Reset() { + *x = CollectionInstance{} + if protoimpl.UnsafeEnabled { + mi := &file_settings_v1_setting_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CollectionInstance) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CollectionInstance) ProtoMessage() {} + +func (x *CollectionInstance) ProtoReflect() protoreflect.Message { + mi := &file_settings_v1_setting_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 CollectionInstance.ProtoReflect.Descriptor instead. +func (*CollectionInstance) Descriptor() ([]byte, []int) { + return file_settings_v1_setting_proto_rawDescGZIP(), []int{8} +} + +func (x *CollectionInstance) GetHostname() string { + if x != nil { + return x.Hostname + } + return "" +} + +func (x *CollectionInstance) GetTargets() []*CollectionTarget { + if x != nil { + return x.Targets + } + return nil +} + +func (x *CollectionInstance) GetLastUpdated() int64 { + if x != nil { + return x.LastUpdated + } + return 0 +} + +type CollectionMessage struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Status Status `protobuf:"varint,1,opt,name=status,proto3,enum=settings.v1.Status" json:"status,omitempty"` + Message *string `protobuf:"bytes,2,opt,name=message,proto3,oneof" json:"message,omitempty"` + Id int64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty"` + PayloadSubscribe *CollectionPayloadSubscribe `protobuf:"bytes,4,opt,name=payload_subscribe,json=payloadSubscribe,proto3" json:"payload_subscribe,omitempty"` + PayloadData *CollectionPayloadData `protobuf:"bytes,5,opt,name=payload_data,json=payloadData,proto3" json:"payload_data,omitempty"` + PayloadRuleInsert *CollectionPayloadRuleInsert `protobuf:"bytes,6,opt,name=payload_rule_insert,json=payloadRuleInsert,proto3" json:"payload_rule_insert,omitempty"` + PayloadRuleDelete *CollectionPayloadRuleDelete `protobuf:"bytes,7,opt,name=payload_rule_delete,json=payloadRuleDelete,proto3" json:"payload_rule_delete,omitempty"` +} + +func (x *CollectionMessage) Reset() { + *x = CollectionMessage{} + if protoimpl.UnsafeEnabled { + mi := &file_settings_v1_setting_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CollectionMessage) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CollectionMessage) ProtoMessage() {} + +func (x *CollectionMessage) ProtoReflect() protoreflect.Message { + mi := &file_settings_v1_setting_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 CollectionMessage.ProtoReflect.Descriptor instead. +func (*CollectionMessage) Descriptor() ([]byte, []int) { + return file_settings_v1_setting_proto_rawDescGZIP(), []int{9} +} + +func (x *CollectionMessage) GetStatus() Status { + if x != nil { + return x.Status + } + return Status_STATUS_UNSPECIFIED +} + +func (x *CollectionMessage) GetMessage() string { + if x != nil && x.Message != nil { + return *x.Message + } + return "" +} + +func (x *CollectionMessage) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *CollectionMessage) GetPayloadSubscribe() *CollectionPayloadSubscribe { + if x != nil { + return x.PayloadSubscribe + } + return nil +} + +func (x *CollectionMessage) GetPayloadData() *CollectionPayloadData { + if x != nil { + return x.PayloadData + } + return nil +} + +func (x *CollectionMessage) GetPayloadRuleInsert() *CollectionPayloadRuleInsert { + if x != nil { + return x.PayloadRuleInsert + } + return nil +} + +func (x *CollectionMessage) GetPayloadRuleDelete() *CollectionPayloadRuleDelete { + if x != nil { + return x.PayloadRuleDelete + } + return nil +} + +type CollectionPayloadSubscribe struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Topics []string `protobuf:"bytes,1,rep,name=topics,proto3" json:"topics,omitempty"` +} + +func (x *CollectionPayloadSubscribe) Reset() { + *x = CollectionPayloadSubscribe{} + if protoimpl.UnsafeEnabled { + mi := &file_settings_v1_setting_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CollectionPayloadSubscribe) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CollectionPayloadSubscribe) ProtoMessage() {} + +func (x *CollectionPayloadSubscribe) ProtoReflect() protoreflect.Message { + mi := &file_settings_v1_setting_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 CollectionPayloadSubscribe.ProtoReflect.Descriptor instead. +func (*CollectionPayloadSubscribe) Descriptor() ([]byte, []int) { + return file_settings_v1_setting_proto_rawDescGZIP(), []int{10} +} + +func (x *CollectionPayloadSubscribe) GetTopics() []string { + if x != nil { + return x.Topics + } + return nil +} + +type CollectionPayloadData struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Rules []*CollectionRule `protobuf:"bytes,1,rep,name=rules,proto3" json:"rules,omitempty"` + Instances []*CollectionInstance `protobuf:"bytes,2,rep,name=instances,proto3" json:"instances,omitempty"` +} + +func (x *CollectionPayloadData) Reset() { + *x = CollectionPayloadData{} + if protoimpl.UnsafeEnabled { + mi := &file_settings_v1_setting_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CollectionPayloadData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CollectionPayloadData) ProtoMessage() {} + +func (x *CollectionPayloadData) ProtoReflect() protoreflect.Message { + mi := &file_settings_v1_setting_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 CollectionPayloadData.ProtoReflect.Descriptor instead. +func (*CollectionPayloadData) Descriptor() ([]byte, []int) { + return file_settings_v1_setting_proto_rawDescGZIP(), []int{11} +} + +func (x *CollectionPayloadData) GetRules() []*CollectionRule { + if x != nil { + return x.Rules + } + return nil +} + +func (x *CollectionPayloadData) GetInstances() []*CollectionInstance { + if x != nil { + return x.Instances + } + return nil +} + +type CollectionPayloadRuleInsert struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Rule *CollectionRule `protobuf:"bytes,1,opt,name=rule,proto3" json:"rule,omitempty"` + After *int64 `protobuf:"varint,2,opt,name=after,proto3,oneof" json:"after,omitempty"` +} + +func (x *CollectionPayloadRuleInsert) Reset() { + *x = CollectionPayloadRuleInsert{} + if protoimpl.UnsafeEnabled { + mi := &file_settings_v1_setting_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CollectionPayloadRuleInsert) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CollectionPayloadRuleInsert) ProtoMessage() {} + +func (x *CollectionPayloadRuleInsert) ProtoReflect() protoreflect.Message { + mi := &file_settings_v1_setting_proto_msgTypes[12] + 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 CollectionPayloadRuleInsert.ProtoReflect.Descriptor instead. +func (*CollectionPayloadRuleInsert) Descriptor() ([]byte, []int) { + return file_settings_v1_setting_proto_rawDescGZIP(), []int{12} +} + +func (x *CollectionPayloadRuleInsert) GetRule() *CollectionRule { + if x != nil { + return x.Rule + } + return nil +} + +func (x *CollectionPayloadRuleInsert) GetAfter() int64 { + if x != nil && x.After != nil { + return *x.After + } + return 0 +} + +type CollectionPayloadRuleDelete struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *CollectionPayloadRuleDelete) Reset() { + *x = CollectionPayloadRuleDelete{} + if protoimpl.UnsafeEnabled { + mi := &file_settings_v1_setting_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CollectionPayloadRuleDelete) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CollectionPayloadRuleDelete) ProtoMessage() {} + +func (x *CollectionPayloadRuleDelete) ProtoReflect() protoreflect.Message { + mi := &file_settings_v1_setting_proto_msgTypes[13] + 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 CollectionPayloadRuleDelete.ProtoReflect.Descriptor instead. +func (*CollectionPayloadRuleDelete) Descriptor() ([]byte, []int) { + return file_settings_v1_setting_proto_rawDescGZIP(), []int{13} +} + +func (x *CollectionPayloadRuleDelete) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + var File_settings_v1_setting_proto protoreflect.FileDescriptor var file_settings_v1_setting_proto_rawDesc = []byte{ 0x0a, 0x19, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x73, 0x65, 0x74, - 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2e, 0x76, 0x31, 0x22, 0x14, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x53, - 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x47, - 0x0a, 0x13, 0x47, 0x65, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, - 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, - 0x67, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x08, 0x73, - 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x22, 0x44, 0x0a, 0x12, 0x53, 0x65, 0x74, 0x53, 0x65, - 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2e, 0x0a, - 0x07, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, - 0x2e, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, - 0x74, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x22, 0x45, 0x0a, - 0x13, 0x53, 0x65, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x07, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, - 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x73, 0x65, 0x74, - 0x74, 0x69, 0x6e, 0x67, 0x22, 0x53, 0x0a, 0x07, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x12, - 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x6d, 0x6f, 0x64, - 0x69, 0x66, 0x69, 0x65, 0x64, 0x41, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x6d, - 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x41, 0x74, 0x32, 0xa9, 0x01, 0x0a, 0x0f, 0x53, 0x65, - 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x4a, 0x0a, - 0x03, 0x47, 0x65, 0x74, 0x12, 0x1f, 0x2e, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2e, - 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, - 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4a, 0x0a, 0x03, 0x53, 0x65, 0x74, - 0x12, 0x1f, 0x2e, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x53, - 0x65, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x20, 0x2e, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2e, 0x76, 0x31, 0x2e, - 0x53, 0x65, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0xb2, 0x01, 0x0a, 0x0f, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65, - 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2e, 0x76, 0x31, 0x42, 0x0c, 0x53, 0x65, 0x74, 0x74, 0x69, - 0x6e, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x61, 0x66, 0x61, 0x6e, 0x61, 0x2f, 0x70, 0x79, - 0x72, 0x6f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x65, 0x6e, 0x2f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, - 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x76, 0x31, 0xa2, - 0x02, 0x03, 0x53, 0x58, 0x58, 0xaa, 0x02, 0x0b, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, - 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0b, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x5c, 0x56, - 0x31, 0xe2, 0x02, 0x17, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x5c, 0x56, 0x31, 0x5c, - 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0c, 0x53, 0x65, - 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2e, 0x76, 0x31, 0x1a, 0x14, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, + 0x76, 0x31, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x14, + 0x0a, 0x12, 0x47, 0x65, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x22, 0x47, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, + 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x08, 0x73, + 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, + 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x74, + 0x69, 0x6e, 0x67, 0x52, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x22, 0x44, 0x0a, + 0x12, 0x53, 0x65, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x2e, 0x0a, 0x07, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2e, + 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x73, 0x65, 0x74, 0x74, + 0x69, 0x6e, 0x67, 0x22, 0x45, 0x0a, 0x13, 0x53, 0x65, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, + 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x07, 0x73, 0x65, + 0x74, 0x74, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x73, 0x65, + 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, + 0x67, 0x52, 0x07, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x22, 0x53, 0x0a, 0x07, 0x53, 0x65, + 0x74, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, + 0x1e, 0x0a, 0x0a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x41, 0x74, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x0a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x41, 0x74, 0x22, + 0xf1, 0x02, 0x0a, 0x0e, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x75, + 0x6c, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, + 0x69, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6c, 0x61, 0x62, + 0x65, 0x6c, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x12, 0x21, 0x0a, 0x09, 0x73, 0x65, 0x70, 0x61, 0x72, + 0x61, 0x74, 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x09, 0x73, 0x65, + 0x70, 0x61, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x88, 0x01, 0x01, 0x12, 0x19, 0x0a, 0x05, 0x72, 0x65, + 0x67, 0x65, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x05, 0x72, 0x65, 0x67, + 0x65, 0x78, 0x88, 0x01, 0x01, 0x12, 0x1d, 0x0a, 0x07, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x75, 0x73, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x48, 0x02, 0x52, 0x07, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x75, + 0x73, 0x88, 0x01, 0x01, 0x12, 0x26, 0x0a, 0x0c, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x6c, + 0x61, 0x62, 0x65, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x48, 0x03, 0x52, 0x0b, 0x74, 0x61, + 0x72, 0x67, 0x65, 0x74, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x88, 0x01, 0x01, 0x12, 0x25, 0x0a, 0x0b, + 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, + 0x09, 0x48, 0x04, 0x52, 0x0b, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x6e, 0x74, + 0x88, 0x01, 0x01, 0x12, 0x39, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x08, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x21, 0x2e, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2e, 0x76, + 0x31, 0x2e, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x75, 0x6c, 0x65, + 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x0c, + 0x0a, 0x0a, 0x5f, 0x73, 0x65, 0x70, 0x61, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x42, 0x08, 0x0a, 0x06, + 0x5f, 0x72, 0x65, 0x67, 0x65, 0x78, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, + 0x75, 0x73, 0x42, 0x0f, 0x0a, 0x0d, 0x5f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x6c, 0x61, + 0x62, 0x65, 0x6c, 0x42, 0x0e, 0x0a, 0x0c, 0x5f, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x6d, + 0x65, 0x6e, 0x74, 0x22, 0x6b, 0x0a, 0x13, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x52, 0x75, 0x6c, 0x65, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x12, 0x31, 0x0a, 0x05, 0x72, 0x75, + 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x73, 0x65, 0x74, 0x74, + 0x69, 0x6e, 0x67, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x21, 0x0a, + 0x0c, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, + 0x22, 0x3f, 0x0a, 0x10, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x61, + 0x72, 0x67, 0x65, 0x74, 0x12, 0x2b, 0x0a, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, + 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x50, 0x61, 0x69, 0x72, 0x52, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, + 0x73, 0x22, 0x8c, 0x01, 0x0a, 0x12, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x68, 0x6f, 0x73, 0x74, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x68, 0x6f, 0x73, 0x74, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x37, 0x0a, 0x07, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, + 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x61, + 0x72, 0x67, 0x65, 0x74, 0x52, 0x07, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x12, 0x21, 0x0a, + 0x0c, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, + 0x22, 0xcc, 0x03, 0x0a, 0x11, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x2b, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x13, 0x2e, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, + 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x12, 0x1d, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x88, + 0x01, 0x01, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, + 0x69, 0x64, 0x12, 0x54, 0x0a, 0x11, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x73, 0x75, + 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, + 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6c, 0x6c, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x75, 0x62, + 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x10, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x53, + 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, 0x45, 0x0a, 0x0c, 0x70, 0x61, 0x79, 0x6c, + 0x6f, 0x61, 0x64, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, + 0x2e, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6c, + 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x61, + 0x74, 0x61, 0x52, 0x0b, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x61, 0x74, 0x61, 0x12, + 0x58, 0x0a, 0x13, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x5f, + 0x69, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x73, + 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6c, 0x6c, 0x65, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x75, 0x6c, 0x65, + 0x49, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x52, 0x11, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x52, + 0x75, 0x6c, 0x65, 0x49, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x12, 0x58, 0x0a, 0x13, 0x70, 0x61, 0x79, + 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x5f, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, + 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x50, + 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x75, 0x6c, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x52, 0x11, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x75, 0x6c, 0x65, 0x44, 0x65, 0x6c, + 0x65, 0x74, 0x65, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, + 0x34, 0x0a, 0x1a, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, + 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, 0x16, 0x0a, + 0x06, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x74, + 0x6f, 0x70, 0x69, 0x63, 0x73, 0x22, 0x89, 0x01, 0x0a, 0x15, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x61, 0x74, 0x61, 0x12, + 0x31, 0x0a, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, + 0x2e, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6c, + 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x05, 0x72, 0x75, 0x6c, + 0x65, 0x73, 0x12, 0x3d, 0x0a, 0x09, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, + 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, + 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x09, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, + 0x73, 0x22, 0x73, 0x0a, 0x1b, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x50, + 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x75, 0x6c, 0x65, 0x49, 0x6e, 0x73, 0x65, 0x72, 0x74, + 0x12, 0x2f, 0x0a, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, + 0x2e, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6c, + 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x04, 0x72, 0x75, 0x6c, + 0x65, 0x12, 0x19, 0x0a, 0x05, 0x61, 0x66, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, + 0x48, 0x00, 0x52, 0x05, 0x61, 0x66, 0x74, 0x65, 0x72, 0x88, 0x01, 0x01, 0x42, 0x08, 0x0a, 0x06, + 0x5f, 0x61, 0x66, 0x74, 0x65, 0x72, 0x22, 0x2d, 0x0a, 0x1b, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x75, 0x6c, 0x65, 0x44, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x02, 0x69, 0x64, 0x2a, 0xd3, 0x03, 0x0a, 0x14, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x75, 0x6c, 0x65, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x26, + 0x0a, 0x22, 0x43, 0x4f, 0x4c, 0x4c, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x52, 0x55, 0x4c, + 0x45, 0x5f, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, + 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x22, 0x0a, 0x1e, 0x43, 0x4f, 0x4c, 0x4c, 0x45, 0x43, + 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x52, 0x55, 0x4c, 0x45, 0x5f, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, + 0x5f, 0x52, 0x45, 0x50, 0x4c, 0x41, 0x43, 0x45, 0x10, 0x01, 0x12, 0x1f, 0x0a, 0x1b, 0x43, 0x4f, + 0x4c, 0x4c, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x52, 0x55, 0x4c, 0x45, 0x5f, 0x41, 0x43, + 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x4b, 0x45, 0x45, 0x50, 0x10, 0x02, 0x12, 0x1f, 0x0a, 0x1b, 0x43, + 0x4f, 0x4c, 0x4c, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x52, 0x55, 0x4c, 0x45, 0x5f, 0x41, + 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x44, 0x52, 0x4f, 0x50, 0x10, 0x03, 0x12, 0x25, 0x0a, 0x21, + 0x43, 0x4f, 0x4c, 0x4c, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x52, 0x55, 0x4c, 0x45, 0x5f, + 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x4b, 0x45, 0x45, 0x50, 0x5f, 0x45, 0x51, 0x55, 0x41, + 0x4c, 0x10, 0x04, 0x12, 0x25, 0x0a, 0x21, 0x43, 0x4f, 0x4c, 0x4c, 0x45, 0x43, 0x54, 0x49, 0x4f, + 0x4e, 0x5f, 0x52, 0x55, 0x4c, 0x45, 0x5f, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x44, 0x52, + 0x4f, 0x50, 0x5f, 0x45, 0x51, 0x55, 0x41, 0x4c, 0x10, 0x05, 0x12, 0x22, 0x0a, 0x1e, 0x43, 0x4f, + 0x4c, 0x4c, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x52, 0x55, 0x4c, 0x45, 0x5f, 0x41, 0x43, + 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x48, 0x41, 0x53, 0x48, 0x4d, 0x4f, 0x44, 0x10, 0x06, 0x12, 0x23, + 0x0a, 0x1f, 0x43, 0x4f, 0x4c, 0x4c, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x52, 0x55, 0x4c, + 0x45, 0x5f, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x4c, 0x41, 0x42, 0x45, 0x4c, 0x4d, 0x41, + 0x50, 0x10, 0x07, 0x12, 0x24, 0x0a, 0x20, 0x43, 0x4f, 0x4c, 0x4c, 0x45, 0x43, 0x54, 0x49, 0x4f, + 0x4e, 0x5f, 0x52, 0x55, 0x4c, 0x45, 0x5f, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x4c, 0x41, + 0x42, 0x45, 0x4c, 0x44, 0x52, 0x4f, 0x50, 0x10, 0x08, 0x12, 0x24, 0x0a, 0x20, 0x43, 0x4f, 0x4c, + 0x4c, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x52, 0x55, 0x4c, 0x45, 0x5f, 0x41, 0x43, 0x54, + 0x49, 0x4f, 0x4e, 0x5f, 0x4c, 0x41, 0x42, 0x45, 0x4c, 0x4b, 0x45, 0x45, 0x50, 0x10, 0x09, 0x12, + 0x24, 0x0a, 0x20, 0x43, 0x4f, 0x4c, 0x4c, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x52, 0x55, + 0x4c, 0x45, 0x5f, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x4c, 0x4f, 0x57, 0x45, 0x52, 0x43, + 0x41, 0x53, 0x45, 0x10, 0x0a, 0x12, 0x24, 0x0a, 0x20, 0x43, 0x4f, 0x4c, 0x4c, 0x45, 0x43, 0x54, + 0x49, 0x4f, 0x4e, 0x5f, 0x52, 0x55, 0x4c, 0x45, 0x5f, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, + 0x55, 0x50, 0x50, 0x45, 0x52, 0x43, 0x41, 0x53, 0x45, 0x10, 0x0b, 0x2a, 0x41, 0x0a, 0x06, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, + 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0d, 0x0a, + 0x09, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x4f, 0x4b, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, + 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x02, 0x32, 0xa9, + 0x01, 0x0a, 0x0f, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x12, 0x4a, 0x0a, 0x03, 0x47, 0x65, 0x74, 0x12, 0x1f, 0x2e, 0x73, 0x65, 0x74, 0x74, + 0x69, 0x6e, 0x67, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, + 0x6e, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x73, 0x65, 0x74, + 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x74, 0x74, + 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4a, + 0x0a, 0x03, 0x53, 0x65, 0x74, 0x12, 0x1f, 0x2e, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, + 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, + 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0xb2, 0x01, 0x0a, 0x0f, 0x63, + 0x6f, 0x6d, 0x2e, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2e, 0x76, 0x31, 0x42, 0x0c, + 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x44, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x61, 0x66, 0x61, + 0x6e, 0x61, 0x2f, 0x70, 0x79, 0x72, 0x6f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x73, 0x65, + 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, + 0x67, 0x73, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x53, 0x58, 0x58, 0xaa, 0x02, 0x0b, 0x53, 0x65, 0x74, + 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0b, 0x53, 0x65, 0x74, 0x74, 0x69, + 0x6e, 0x67, 0x73, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x17, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, + 0x73, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0xea, 0x02, 0x0c, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x3a, 0x3a, 0x56, 0x31, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -325,27 +1173,52 @@ func file_settings_v1_setting_proto_rawDescGZIP() []byte { return file_settings_v1_setting_proto_rawDescData } -var file_settings_v1_setting_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_settings_v1_setting_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_settings_v1_setting_proto_msgTypes = make([]protoimpl.MessageInfo, 14) var file_settings_v1_setting_proto_goTypes = []any{ - (*GetSettingsRequest)(nil), // 0: settings.v1.GetSettingsRequest - (*GetSettingsResponse)(nil), // 1: settings.v1.GetSettingsResponse - (*SetSettingsRequest)(nil), // 2: settings.v1.SetSettingsRequest - (*SetSettingsResponse)(nil), // 3: settings.v1.SetSettingsResponse - (*Setting)(nil), // 4: settings.v1.Setting + (CollectionRuleAction)(0), // 0: settings.v1.CollectionRuleAction + (Status)(0), // 1: settings.v1.Status + (*GetSettingsRequest)(nil), // 2: settings.v1.GetSettingsRequest + (*GetSettingsResponse)(nil), // 3: settings.v1.GetSettingsResponse + (*SetSettingsRequest)(nil), // 4: settings.v1.SetSettingsRequest + (*SetSettingsResponse)(nil), // 5: settings.v1.SetSettingsResponse + (*Setting)(nil), // 6: settings.v1.Setting + (*CollectionRule)(nil), // 7: settings.v1.CollectionRule + (*CollectionRuleStore)(nil), // 8: settings.v1.CollectionRuleStore + (*CollectionTarget)(nil), // 9: settings.v1.CollectionTarget + (*CollectionInstance)(nil), // 10: settings.v1.CollectionInstance + (*CollectionMessage)(nil), // 11: settings.v1.CollectionMessage + (*CollectionPayloadSubscribe)(nil), // 12: settings.v1.CollectionPayloadSubscribe + (*CollectionPayloadData)(nil), // 13: settings.v1.CollectionPayloadData + (*CollectionPayloadRuleInsert)(nil), // 14: settings.v1.CollectionPayloadRuleInsert + (*CollectionPayloadRuleDelete)(nil), // 15: settings.v1.CollectionPayloadRuleDelete + (*v1.LabelPair)(nil), // 16: types.v1.LabelPair } var file_settings_v1_setting_proto_depIdxs = []int32{ - 4, // 0: settings.v1.GetSettingsResponse.settings:type_name -> settings.v1.Setting - 4, // 1: settings.v1.SetSettingsRequest.setting:type_name -> settings.v1.Setting - 4, // 2: settings.v1.SetSettingsResponse.setting:type_name -> settings.v1.Setting - 0, // 3: settings.v1.SettingsService.Get:input_type -> settings.v1.GetSettingsRequest - 2, // 4: settings.v1.SettingsService.Set:input_type -> settings.v1.SetSettingsRequest - 1, // 5: settings.v1.SettingsService.Get:output_type -> settings.v1.GetSettingsResponse - 3, // 6: settings.v1.SettingsService.Set:output_type -> settings.v1.SetSettingsResponse - 5, // [5:7] is the sub-list for method output_type - 3, // [3:5] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 6, // 0: settings.v1.GetSettingsResponse.settings:type_name -> settings.v1.Setting + 6, // 1: settings.v1.SetSettingsRequest.setting:type_name -> settings.v1.Setting + 6, // 2: settings.v1.SetSettingsResponse.setting:type_name -> settings.v1.Setting + 0, // 3: settings.v1.CollectionRule.action:type_name -> settings.v1.CollectionRuleAction + 7, // 4: settings.v1.CollectionRuleStore.rules:type_name -> settings.v1.CollectionRule + 16, // 5: settings.v1.CollectionTarget.labels:type_name -> types.v1.LabelPair + 9, // 6: settings.v1.CollectionInstance.targets:type_name -> settings.v1.CollectionTarget + 1, // 7: settings.v1.CollectionMessage.status:type_name -> settings.v1.Status + 12, // 8: settings.v1.CollectionMessage.payload_subscribe:type_name -> settings.v1.CollectionPayloadSubscribe + 13, // 9: settings.v1.CollectionMessage.payload_data:type_name -> settings.v1.CollectionPayloadData + 14, // 10: settings.v1.CollectionMessage.payload_rule_insert:type_name -> settings.v1.CollectionPayloadRuleInsert + 15, // 11: settings.v1.CollectionMessage.payload_rule_delete:type_name -> settings.v1.CollectionPayloadRuleDelete + 7, // 12: settings.v1.CollectionPayloadData.rules:type_name -> settings.v1.CollectionRule + 10, // 13: settings.v1.CollectionPayloadData.instances:type_name -> settings.v1.CollectionInstance + 7, // 14: settings.v1.CollectionPayloadRuleInsert.rule:type_name -> settings.v1.CollectionRule + 2, // 15: settings.v1.SettingsService.Get:input_type -> settings.v1.GetSettingsRequest + 4, // 16: settings.v1.SettingsService.Set:input_type -> settings.v1.SetSettingsRequest + 3, // 17: settings.v1.SettingsService.Get:output_type -> settings.v1.GetSettingsResponse + 5, // 18: settings.v1.SettingsService.Set:output_type -> settings.v1.SetSettingsResponse + 17, // [17:19] is the sub-list for method output_type + 15, // [15:17] 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 } func init() { file_settings_v1_setting_proto_init() } @@ -414,19 +1287,131 @@ func file_settings_v1_setting_proto_init() { return nil } } + file_settings_v1_setting_proto_msgTypes[5].Exporter = func(v any, i int) any { + switch v := v.(*CollectionRule); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_settings_v1_setting_proto_msgTypes[6].Exporter = func(v any, i int) any { + switch v := v.(*CollectionRuleStore); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_settings_v1_setting_proto_msgTypes[7].Exporter = func(v any, i int) any { + switch v := v.(*CollectionTarget); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_settings_v1_setting_proto_msgTypes[8].Exporter = func(v any, i int) any { + switch v := v.(*CollectionInstance); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_settings_v1_setting_proto_msgTypes[9].Exporter = func(v any, i int) any { + switch v := v.(*CollectionMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_settings_v1_setting_proto_msgTypes[10].Exporter = func(v any, i int) any { + switch v := v.(*CollectionPayloadSubscribe); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_settings_v1_setting_proto_msgTypes[11].Exporter = func(v any, i int) any { + switch v := v.(*CollectionPayloadData); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_settings_v1_setting_proto_msgTypes[12].Exporter = func(v any, i int) any { + switch v := v.(*CollectionPayloadRuleInsert); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_settings_v1_setting_proto_msgTypes[13].Exporter = func(v any, i int) any { + switch v := v.(*CollectionPayloadRuleDelete); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } + file_settings_v1_setting_proto_msgTypes[5].OneofWrappers = []any{} + file_settings_v1_setting_proto_msgTypes[9].OneofWrappers = []any{} + file_settings_v1_setting_proto_msgTypes[12].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_settings_v1_setting_proto_rawDesc, - NumEnums: 0, - NumMessages: 5, + NumEnums: 2, + NumMessages: 14, NumExtensions: 0, NumServices: 1, }, GoTypes: file_settings_v1_setting_proto_goTypes, DependencyIndexes: file_settings_v1_setting_proto_depIdxs, + EnumInfos: file_settings_v1_setting_proto_enumTypes, MessageInfos: file_settings_v1_setting_proto_msgTypes, }.Build() File_settings_v1_setting_proto = out.File diff --git a/api/gen/proto/go/settings/v1/setting_vtproto.pb.go b/api/gen/proto/go/settings/v1/setting_vtproto.pb.go index ce4853fd6b..d14037c83a 100644 --- a/api/gen/proto/go/settings/v1/setting_vtproto.pb.go +++ b/api/gen/proto/go/settings/v1/setting_vtproto.pb.go @@ -7,6 +7,7 @@ package settingsv1 import ( context "context" fmt "fmt" + v1 "github.com/grafana/pyroscope/api/gen/proto/go/types/v1" protohelpers "github.com/planetscale/vtprotobuf/protohelpers" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" @@ -115,6 +116,240 @@ func (m *Setting) CloneMessageVT() proto.Message { return m.CloneVT() } +func (m *CollectionRule) CloneVT() *CollectionRule { + if m == nil { + return (*CollectionRule)(nil) + } + r := new(CollectionRule) + r.Id = m.Id + r.Action = m.Action + if rhs := m.SourceLabels; rhs != nil { + tmpContainer := make([]string, len(rhs)) + copy(tmpContainer, rhs) + r.SourceLabels = tmpContainer + } + if rhs := m.Separator; rhs != nil { + tmpVal := *rhs + r.Separator = &tmpVal + } + if rhs := m.Regex; rhs != nil { + tmpVal := *rhs + r.Regex = &tmpVal + } + if rhs := m.Modulus; rhs != nil { + tmpVal := *rhs + r.Modulus = &tmpVal + } + if rhs := m.TargetLabel; rhs != nil { + tmpVal := *rhs + r.TargetLabel = &tmpVal + } + if rhs := m.Replacement; rhs != nil { + tmpVal := *rhs + r.Replacement = &tmpVal + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *CollectionRule) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *CollectionRuleStore) CloneVT() *CollectionRuleStore { + if m == nil { + return (*CollectionRuleStore)(nil) + } + r := new(CollectionRuleStore) + r.LastUpdated = m.LastUpdated + if rhs := m.Rules; rhs != nil { + tmpContainer := make([]*CollectionRule, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.Rules = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *CollectionRuleStore) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *CollectionTarget) CloneVT() *CollectionTarget { + if m == nil { + return (*CollectionTarget)(nil) + } + r := new(CollectionTarget) + if rhs := m.Labels; rhs != nil { + tmpContainer := make([]*v1.LabelPair, len(rhs)) + for k, v := range rhs { + if vtpb, ok := interface{}(v).(interface{ CloneVT() *v1.LabelPair }); ok { + tmpContainer[k] = vtpb.CloneVT() + } else { + tmpContainer[k] = proto.Clone(v).(*v1.LabelPair) + } + } + r.Labels = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *CollectionTarget) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *CollectionInstance) CloneVT() *CollectionInstance { + if m == nil { + return (*CollectionInstance)(nil) + } + r := new(CollectionInstance) + r.Hostname = m.Hostname + r.LastUpdated = m.LastUpdated + if rhs := m.Targets; rhs != nil { + tmpContainer := make([]*CollectionTarget, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.Targets = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *CollectionInstance) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *CollectionMessage) CloneVT() *CollectionMessage { + if m == nil { + return (*CollectionMessage)(nil) + } + r := new(CollectionMessage) + r.Status = m.Status + r.Id = m.Id + r.PayloadSubscribe = m.PayloadSubscribe.CloneVT() + r.PayloadData = m.PayloadData.CloneVT() + r.PayloadRuleInsert = m.PayloadRuleInsert.CloneVT() + r.PayloadRuleDelete = m.PayloadRuleDelete.CloneVT() + if rhs := m.Message; rhs != nil { + tmpVal := *rhs + r.Message = &tmpVal + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *CollectionMessage) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *CollectionPayloadSubscribe) CloneVT() *CollectionPayloadSubscribe { + if m == nil { + return (*CollectionPayloadSubscribe)(nil) + } + r := new(CollectionPayloadSubscribe) + if rhs := m.Topics; rhs != nil { + tmpContainer := make([]string, len(rhs)) + copy(tmpContainer, rhs) + r.Topics = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *CollectionPayloadSubscribe) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *CollectionPayloadData) CloneVT() *CollectionPayloadData { + if m == nil { + return (*CollectionPayloadData)(nil) + } + r := new(CollectionPayloadData) + if rhs := m.Rules; rhs != nil { + tmpContainer := make([]*CollectionRule, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.Rules = tmpContainer + } + if rhs := m.Instances; rhs != nil { + tmpContainer := make([]*CollectionInstance, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.Instances = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *CollectionPayloadData) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *CollectionPayloadRuleInsert) CloneVT() *CollectionPayloadRuleInsert { + if m == nil { + return (*CollectionPayloadRuleInsert)(nil) + } + r := new(CollectionPayloadRuleInsert) + r.Rule = m.Rule.CloneVT() + if rhs := m.After; rhs != nil { + tmpVal := *rhs + r.After = &tmpVal + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *CollectionPayloadRuleInsert) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *CollectionPayloadRuleDelete) CloneVT() *CollectionPayloadRuleDelete { + if m == nil { + return (*CollectionPayloadRuleDelete)(nil) + } + r := new(CollectionPayloadRuleDelete) + r.Id = m.Id + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *CollectionPayloadRuleDelete) CloneMessageVT() proto.Message { + return m.CloneVT() +} + func (this *GetSettingsRequest) EqualVT(that *GetSettingsRequest) bool { if this == that { return true @@ -227,508 +462,2730 @@ func (this *Setting) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -// SettingsServiceClient is the client API for SettingsService 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 SettingsServiceClient interface { - Get(ctx context.Context, in *GetSettingsRequest, opts ...grpc.CallOption) (*GetSettingsResponse, error) - Set(ctx context.Context, in *SetSettingsRequest, opts ...grpc.CallOption) (*SetSettingsResponse, error) -} - -type settingsServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewSettingsServiceClient(cc grpc.ClientConnInterface) SettingsServiceClient { - return &settingsServiceClient{cc} -} - -func (c *settingsServiceClient) Get(ctx context.Context, in *GetSettingsRequest, opts ...grpc.CallOption) (*GetSettingsResponse, error) { - out := new(GetSettingsResponse) - err := c.cc.Invoke(ctx, "/settings.v1.SettingsService/Get", in, out, opts...) - if err != nil { - return nil, err +func (this *CollectionRule) EqualVT(that *CollectionRule) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false } - return out, nil -} - -func (c *settingsServiceClient) Set(ctx context.Context, in *SetSettingsRequest, opts ...grpc.CallOption) (*SetSettingsResponse, error) { - out := new(SetSettingsResponse) - err := c.cc.Invoke(ctx, "/settings.v1.SettingsService/Set", in, out, opts...) - if err != nil { - return nil, err + if this.Id != that.Id { + return false } - return out, nil -} - -// SettingsServiceServer is the server API for SettingsService service. -// All implementations must embed UnimplementedSettingsServiceServer -// for forward compatibility -type SettingsServiceServer interface { - Get(context.Context, *GetSettingsRequest) (*GetSettingsResponse, error) - Set(context.Context, *SetSettingsRequest) (*SetSettingsResponse, error) - mustEmbedUnimplementedSettingsServiceServer() -} - -// UnimplementedSettingsServiceServer must be embedded to have forward compatible implementations. -type UnimplementedSettingsServiceServer struct { -} - -func (UnimplementedSettingsServiceServer) Get(context.Context, *GetSettingsRequest) (*GetSettingsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Get not implemented") -} -func (UnimplementedSettingsServiceServer) Set(context.Context, *SetSettingsRequest) (*SetSettingsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Set not implemented") -} -func (UnimplementedSettingsServiceServer) mustEmbedUnimplementedSettingsServiceServer() {} - -// UnsafeSettingsServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to SettingsServiceServer will -// result in compilation errors. -type UnsafeSettingsServiceServer interface { - mustEmbedUnimplementedSettingsServiceServer() -} - -func RegisterSettingsServiceServer(s grpc.ServiceRegistrar, srv SettingsServiceServer) { - s.RegisterService(&SettingsService_ServiceDesc, srv) -} - -func _SettingsService_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetSettingsRequest) - if err := dec(in); err != nil { - return nil, err + if len(this.SourceLabels) != len(that.SourceLabels) { + return false } - if interceptor == nil { - return srv.(SettingsServiceServer).Get(ctx, in) + for i, vx := range this.SourceLabels { + vy := that.SourceLabels[i] + if vx != vy { + return false + } } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/settings.v1.SettingsService/Get", + if p, q := this.Separator, that.Separator; (p == nil && q != nil) || (p != nil && (q == nil || *p != *q)) { + return false } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(SettingsServiceServer).Get(ctx, req.(*GetSettingsRequest)) + if p, q := this.Regex, that.Regex; (p == nil && q != nil) || (p != nil && (q == nil || *p != *q)) { + return false } - return interceptor(ctx, in, info, handler) -} - -func _SettingsService_Set_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(SetSettingsRequest) - if err := dec(in); err != nil { - return nil, err + if p, q := this.Modulus, that.Modulus; (p == nil && q != nil) || (p != nil && (q == nil || *p != *q)) { + return false } - if interceptor == nil { - return srv.(SettingsServiceServer).Set(ctx, in) + if p, q := this.TargetLabel, that.TargetLabel; (p == nil && q != nil) || (p != nil && (q == nil || *p != *q)) { + return false } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/settings.v1.SettingsService/Set", + if p, q := this.Replacement, that.Replacement; (p == nil && q != nil) || (p != nil && (q == nil || *p != *q)) { + return false } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(SettingsServiceServer).Set(ctx, req.(*SetSettingsRequest)) + if this.Action != that.Action { + return false } - return interceptor(ctx, in, info, handler) + return string(this.unknownFields) == string(that.unknownFields) } -// SettingsService_ServiceDesc is the grpc.ServiceDesc for SettingsService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var SettingsService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "settings.v1.SettingsService", - HandlerType: (*SettingsServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Get", - Handler: _SettingsService_Get_Handler, - }, - { - MethodName: "Set", - Handler: _SettingsService_Set_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "settings/v1/setting.proto", -} - -func (m *GetSettingsRequest) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err +func (this *CollectionRule) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*CollectionRule) + if !ok { + return false } - return dAtA[:n], nil -} - -func (m *GetSettingsRequest) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) + return this.EqualVT(that) } - -func (m *GetSettingsRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil +func (this *CollectionRuleStore) EqualVT(that *CollectionRuleStore) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) + if len(this.Rules) != len(that.Rules) { + return false } - return len(dAtA) - i, nil -} - -func (m *GetSettingsResponse) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil + for i, vx := range this.Rules { + vy := that.Rules[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &CollectionRule{} + } + if q == nil { + q = &CollectionRule{} + } + if !p.EqualVT(q) { + return false + } + } } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err + if this.LastUpdated != that.LastUpdated { + return false } - return dAtA[:n], nil + return string(this.unknownFields) == string(that.unknownFields) } -func (m *GetSettingsResponse) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) +func (this *CollectionRuleStore) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*CollectionRuleStore) + if !ok { + return false + } + return this.EqualVT(that) } - -func (m *GetSettingsResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil +func (this *CollectionTarget) EqualVT(that *CollectionTarget) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) + if len(this.Labels) != len(that.Labels) { + return false } - if len(m.Settings) > 0 { - for iNdEx := len(m.Settings) - 1; iNdEx >= 0; iNdEx-- { - size, err := m.Settings[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err + for i, vx := range this.Labels { + vy := that.Labels[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &v1.LabelPair{} + } + if q == nil { + q = &v1.LabelPair{} + } + if equal, ok := interface{}(p).(interface{ EqualVT(*v1.LabelPair) bool }); ok { + if !equal.EqualVT(q) { + return false + } + } else if !proto.Equal(p, q) { + return false } - i -= size - i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) - i-- - dAtA[i] = 0xa } } - return len(dAtA) - i, nil + return string(this.unknownFields) == string(that.unknownFields) } -func (m *SetSettingsRequest) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err +func (this *CollectionTarget) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*CollectionTarget) + if !ok { + return false } - return dAtA[:n], nil -} - -func (m *SetSettingsRequest) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) + return this.EqualVT(that) } - -func (m *SetSettingsRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil +func (this *CollectionInstance) EqualVT(that *CollectionInstance) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) + if this.Hostname != that.Hostname { + return false } - if m.Setting != nil { - size, err := m.Setting.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err + if len(this.Targets) != len(that.Targets) { + return false + } + for i, vx := range this.Targets { + vy := that.Targets[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &CollectionTarget{} + } + if q == nil { + q = &CollectionTarget{} + } + if !p.EqualVT(q) { + return false + } } - i -= size - i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) - i-- - dAtA[i] = 0xa } - return len(dAtA) - i, nil + if this.LastUpdated != that.LastUpdated { + return false + } + return string(this.unknownFields) == string(that.unknownFields) } -func (m *SetSettingsResponse) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil +func (this *CollectionInstance) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*CollectionInstance) + if !ok { + return false } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err + return this.EqualVT(that) +} +func (this *CollectionMessage) EqualVT(that *CollectionMessage) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false } - return dAtA[:n], nil + if this.Status != that.Status { + return false + } + if p, q := this.Message, that.Message; (p == nil && q != nil) || (p != nil && (q == nil || *p != *q)) { + return false + } + if this.Id != that.Id { + return false + } + if !this.PayloadSubscribe.EqualVT(that.PayloadSubscribe) { + return false + } + if !this.PayloadData.EqualVT(that.PayloadData) { + return false + } + if !this.PayloadRuleInsert.EqualVT(that.PayloadRuleInsert) { + return false + } + if !this.PayloadRuleDelete.EqualVT(that.PayloadRuleDelete) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) } -func (m *SetSettingsResponse) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) +func (this *CollectionMessage) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*CollectionMessage) + if !ok { + return false + } + return this.EqualVT(that) } - -func (m *SetSettingsResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil +func (this *CollectionPayloadSubscribe) EqualVT(that *CollectionPayloadSubscribe) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) + if len(this.Topics) != len(that.Topics) { + return false } - if m.Setting != nil { - size, err := m.Setting.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err + for i, vx := range this.Topics { + vy := that.Topics[i] + if vx != vy { + return false } - i -= size - i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) - i-- - dAtA[i] = 0xa } - return len(dAtA) - i, nil + return string(this.unknownFields) == string(that.unknownFields) } -func (m *Setting) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err +func (this *CollectionPayloadSubscribe) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*CollectionPayloadSubscribe) + if !ok { + return false } - return dAtA[:n], nil -} - -func (m *Setting) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) + return this.EqualVT(that) } - -func (m *Setting) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil +func (this *CollectionPayloadData) EqualVT(that *CollectionPayloadData) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) + if len(this.Rules) != len(that.Rules) { + return false } - if m.ModifiedAt != 0 { - i = protohelpers.EncodeVarint(dAtA, i, uint64(m.ModifiedAt)) - i-- - dAtA[i] = 0x18 + for i, vx := range this.Rules { + vy := that.Rules[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &CollectionRule{} + } + if q == nil { + q = &CollectionRule{} + } + if !p.EqualVT(q) { + return false + } + } } - if len(m.Value) > 0 { - i -= len(m.Value) - copy(dAtA[i:], m.Value) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Value))) - i-- - dAtA[i] = 0x12 + if len(this.Instances) != len(that.Instances) { + return false } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0xa + for i, vx := range this.Instances { + vy := that.Instances[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &CollectionInstance{} + } + if q == nil { + q = &CollectionInstance{} + } + if !p.EqualVT(q) { + return false + } + } } - return len(dAtA) - i, nil + return string(this.unknownFields) == string(that.unknownFields) } -func (m *GetSettingsRequest) SizeVT() (n int) { - if m == nil { - return 0 +func (this *CollectionPayloadData) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*CollectionPayloadData) + if !ok { + return false } - var l int - _ = l - n += len(m.unknownFields) - return n + return this.EqualVT(that) +} +func (this *CollectionPayloadRuleInsert) EqualVT(that *CollectionPayloadRuleInsert) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if !this.Rule.EqualVT(that.Rule) { + return false + } + if p, q := this.After, that.After; (p == nil && q != nil) || (p != nil && (q == nil || *p != *q)) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) } -func (m *GetSettingsResponse) SizeVT() (n int) { - if m == nil { - return 0 +func (this *CollectionPayloadRuleInsert) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*CollectionPayloadRuleInsert) + if !ok { + return false } - var l int - _ = l - if len(m.Settings) > 0 { - for _, e := range m.Settings { - l = e.SizeVT() - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } + return this.EqualVT(that) +} +func (this *CollectionPayloadRuleDelete) EqualVT(that *CollectionPayloadRuleDelete) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false } - n += len(m.unknownFields) - return n + if this.Id != that.Id { + return false + } + return string(this.unknownFields) == string(that.unknownFields) } -func (m *SetSettingsRequest) SizeVT() (n int) { - if m == nil { - return 0 +func (this *CollectionPayloadRuleDelete) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*CollectionPayloadRuleDelete) + if !ok { + return false } - var l int - _ = l - if m.Setting != nil { - l = m.Setting.SizeVT() - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + return this.EqualVT(that) +} + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// SettingsServiceClient is the client API for SettingsService 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 SettingsServiceClient interface { + Get(ctx context.Context, in *GetSettingsRequest, opts ...grpc.CallOption) (*GetSettingsResponse, error) + Set(ctx context.Context, in *SetSettingsRequest, opts ...grpc.CallOption) (*SetSettingsResponse, error) +} + +type settingsServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewSettingsServiceClient(cc grpc.ClientConnInterface) SettingsServiceClient { + return &settingsServiceClient{cc} +} + +func (c *settingsServiceClient) Get(ctx context.Context, in *GetSettingsRequest, opts ...grpc.CallOption) (*GetSettingsResponse, error) { + out := new(GetSettingsResponse) + err := c.cc.Invoke(ctx, "/settings.v1.SettingsService/Get", in, out, opts...) + if err != nil { + return nil, err } - n += len(m.unknownFields) - return n + return out, nil } -func (m *SetSettingsResponse) SizeVT() (n int) { - if m == nil { - return 0 +func (c *settingsServiceClient) Set(ctx context.Context, in *SetSettingsRequest, opts ...grpc.CallOption) (*SetSettingsResponse, error) { + out := new(SetSettingsResponse) + err := c.cc.Invoke(ctx, "/settings.v1.SettingsService/Set", in, out, opts...) + if err != nil { + return nil, err } - var l int - _ = l - if m.Setting != nil { - l = m.Setting.SizeVT() - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + return out, nil +} + +// SettingsServiceServer is the server API for SettingsService service. +// All implementations must embed UnimplementedSettingsServiceServer +// for forward compatibility +type SettingsServiceServer interface { + Get(context.Context, *GetSettingsRequest) (*GetSettingsResponse, error) + Set(context.Context, *SetSettingsRequest) (*SetSettingsResponse, error) + mustEmbedUnimplementedSettingsServiceServer() +} + +// UnimplementedSettingsServiceServer must be embedded to have forward compatible implementations. +type UnimplementedSettingsServiceServer struct { +} + +func (UnimplementedSettingsServiceServer) Get(context.Context, *GetSettingsRequest) (*GetSettingsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Get not implemented") +} +func (UnimplementedSettingsServiceServer) Set(context.Context, *SetSettingsRequest) (*SetSettingsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Set not implemented") +} +func (UnimplementedSettingsServiceServer) mustEmbedUnimplementedSettingsServiceServer() {} + +// UnsafeSettingsServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to SettingsServiceServer will +// result in compilation errors. +type UnsafeSettingsServiceServer interface { + mustEmbedUnimplementedSettingsServiceServer() +} + +func RegisterSettingsServiceServer(s grpc.ServiceRegistrar, srv SettingsServiceServer) { + s.RegisterService(&SettingsService_ServiceDesc, srv) +} + +func _SettingsService_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetSettingsRequest) + if err := dec(in); err != nil { + return nil, err } - n += len(m.unknownFields) - return n + if interceptor == nil { + return srv.(SettingsServiceServer).Get(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/settings.v1.SettingsService/Get", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SettingsServiceServer).Get(ctx, req.(*GetSettingsRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *Setting) SizeVT() (n int) { - if m == nil { - return 0 +func _SettingsService_Set_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SetSettingsRequest) + if err := dec(in); err != nil { + return nil, err } - var l int - _ = l - l = len(m.Name) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + if interceptor == nil { + return srv.(SettingsServiceServer).Set(ctx, in) } - l = len(m.Value) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/settings.v1.SettingsService/Set", } - if m.ModifiedAt != 0 { - n += 1 + protohelpers.SizeOfVarint(uint64(m.ModifiedAt)) + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SettingsServiceServer).Set(ctx, req.(*SetSettingsRequest)) } - n += len(m.unknownFields) - return n + return interceptor(ctx, in, info, handler) } -func (m *GetSettingsRequest) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow +// SettingsService_ServiceDesc is the grpc.ServiceDesc for SettingsService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var SettingsService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "settings.v1.SettingsService", + HandlerType: (*SettingsServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Get", + Handler: _SettingsService_Get_Handler, + }, + { + MethodName: "Set", + Handler: _SettingsService_Set_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "settings/v1/setting.proto", +} + +func (m *GetSettingsRequest) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GetSettingsRequest) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *GetSettingsRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + return len(dAtA) - i, nil +} + +func (m *GetSettingsResponse) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GetSettingsResponse) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *GetSettingsResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Settings) > 0 { + for iNdEx := len(m.Settings) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.Settings[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *SetSettingsRequest) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SetSettingsRequest) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *SetSettingsRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Setting != nil { + size, err := m.Setting.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SetSettingsResponse) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SetSettingsResponse) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *SetSettingsResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Setting != nil { + size, err := m.Setting.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Setting) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Setting) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Setting) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.ModifiedAt != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.ModifiedAt)) + i-- + dAtA[i] = 0x18 + } + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0x12 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *CollectionRule) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CollectionRule) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CollectionRule) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Action != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Action)) + i-- + dAtA[i] = 0x40 + } + if m.Replacement != nil { + i -= len(*m.Replacement) + copy(dAtA[i:], *m.Replacement) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(*m.Replacement))) + i-- + dAtA[i] = 0x3a + } + if m.TargetLabel != nil { + i -= len(*m.TargetLabel) + copy(dAtA[i:], *m.TargetLabel) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(*m.TargetLabel))) + i-- + dAtA[i] = 0x32 + } + if m.Modulus != nil { + i = protohelpers.EncodeVarint(dAtA, i, uint64(*m.Modulus)) + i-- + dAtA[i] = 0x28 + } + if m.Regex != nil { + i -= len(*m.Regex) + copy(dAtA[i:], *m.Regex) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(*m.Regex))) + i-- + dAtA[i] = 0x22 + } + if m.Separator != nil { + i -= len(*m.Separator) + copy(dAtA[i:], *m.Separator) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(*m.Separator))) + i-- + dAtA[i] = 0x1a + } + if len(m.SourceLabels) > 0 { + for iNdEx := len(m.SourceLabels) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.SourceLabels[iNdEx]) + copy(dAtA[i:], m.SourceLabels[iNdEx]) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.SourceLabels[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if m.Id != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *CollectionRuleStore) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CollectionRuleStore) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CollectionRuleStore) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.LastUpdated != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.LastUpdated)) + i-- + dAtA[i] = 0x10 + } + if len(m.Rules) > 0 { + for iNdEx := len(m.Rules) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.Rules[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *CollectionTarget) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CollectionTarget) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CollectionTarget) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Labels) > 0 { + for iNdEx := len(m.Labels) - 1; iNdEx >= 0; iNdEx-- { + if vtmsg, ok := interface{}(m.Labels[iNdEx]).(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.Labels[iNdEx]) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded))) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *CollectionInstance) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CollectionInstance) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CollectionInstance) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.LastUpdated != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.LastUpdated)) + i-- + dAtA[i] = 0x18 + } + if len(m.Targets) > 0 { + for iNdEx := len(m.Targets) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.Targets[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Hostname) > 0 { + i -= len(m.Hostname) + copy(dAtA[i:], m.Hostname) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Hostname))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *CollectionMessage) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CollectionMessage) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CollectionMessage) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.PayloadRuleDelete != nil { + size, err := m.PayloadRuleDelete.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x3a + } + if m.PayloadRuleInsert != nil { + size, err := m.PayloadRuleInsert.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x32 + } + if m.PayloadData != nil { + size, err := m.PayloadData.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x2a + } + if m.PayloadSubscribe != nil { + size, err := m.PayloadSubscribe.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x22 + } + if m.Id != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x18 + } + if m.Message != nil { + i -= len(*m.Message) + copy(dAtA[i:], *m.Message) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(*m.Message))) + i-- + dAtA[i] = 0x12 + } + if m.Status != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *CollectionPayloadSubscribe) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CollectionPayloadSubscribe) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CollectionPayloadSubscribe) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Topics) > 0 { + for iNdEx := len(m.Topics) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Topics[iNdEx]) + copy(dAtA[i:], m.Topics[iNdEx]) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Topics[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *CollectionPayloadData) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CollectionPayloadData) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CollectionPayloadData) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Instances) > 0 { + for iNdEx := len(m.Instances) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.Instances[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Rules) > 0 { + for iNdEx := len(m.Rules) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.Rules[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *CollectionPayloadRuleInsert) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CollectionPayloadRuleInsert) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CollectionPayloadRuleInsert) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.After != nil { + i = protohelpers.EncodeVarint(dAtA, i, uint64(*m.After)) + i-- + dAtA[i] = 0x10 + } + if m.Rule != nil { + size, err := m.Rule.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *CollectionPayloadRuleDelete) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CollectionPayloadRuleDelete) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CollectionPayloadRuleDelete) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Id != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *GetSettingsRequest) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += len(m.unknownFields) + return n +} + +func (m *GetSettingsResponse) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Settings) > 0 { + for _, e := range m.Settings { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *SetSettingsRequest) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Setting != nil { + l = m.Setting.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *SetSettingsResponse) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Setting != nil { + l = m.Setting.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *Setting) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.ModifiedAt != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.ModifiedAt)) + } + n += len(m.unknownFields) + return n +} + +func (m *CollectionRule) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Id != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Id)) + } + if len(m.SourceLabels) > 0 { + for _, s := range m.SourceLabels { + l = len(s) + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + if m.Separator != nil { + l = len(*m.Separator) + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.Regex != nil { + l = len(*m.Regex) + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.Modulus != nil { + n += 1 + protohelpers.SizeOfVarint(uint64(*m.Modulus)) + } + if m.TargetLabel != nil { + l = len(*m.TargetLabel) + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.Replacement != nil { + l = len(*m.Replacement) + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.Action != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Action)) + } + n += len(m.unknownFields) + return n +} + +func (m *CollectionRuleStore) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Rules) > 0 { + for _, e := range m.Rules { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + if m.LastUpdated != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.LastUpdated)) + } + n += len(m.unknownFields) + return n +} + +func (m *CollectionTarget) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Labels) > 0 { + for _, e := range m.Labels { + if size, ok := interface{}(e).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(e) + } + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *CollectionInstance) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Hostname) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if len(m.Targets) > 0 { + for _, e := range m.Targets { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + if m.LastUpdated != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.LastUpdated)) + } + n += len(m.unknownFields) + return n +} + +func (m *CollectionMessage) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Status != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Status)) + } + if m.Message != nil { + l = len(*m.Message) + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.Id != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Id)) + } + if m.PayloadSubscribe != nil { + l = m.PayloadSubscribe.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.PayloadData != nil { + l = m.PayloadData.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.PayloadRuleInsert != nil { + l = m.PayloadRuleInsert.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.PayloadRuleDelete != nil { + l = m.PayloadRuleDelete.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *CollectionPayloadSubscribe) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Topics) > 0 { + for _, s := range m.Topics { + l = len(s) + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *CollectionPayloadData) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Rules) > 0 { + for _, e := range m.Rules { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + if len(m.Instances) > 0 { + for _, e := range m.Instances { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *CollectionPayloadRuleInsert) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Rule != nil { + l = m.Rule.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.After != nil { + n += 1 + protohelpers.SizeOfVarint(uint64(*m.After)) + } + n += len(m.unknownFields) + return n +} + +func (m *CollectionPayloadRuleDelete) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Id != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Id)) + } + n += len(m.unknownFields) + return n +} + +func (m *GetSettingsRequest) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetSettingsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetSettingsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GetSettingsResponse) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetSettingsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetSettingsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Settings", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Settings = append(m.Settings, &Setting{}) + if err := m.Settings[len(m.Settings)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SetSettingsRequest) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SetSettingsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SetSettingsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Setting", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Setting == nil { + m.Setting = &Setting{} + } + if err := m.Setting.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SetSettingsResponse) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SetSettingsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SetSettingsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Setting", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Setting == nil { + m.Setting = &Setting{} + } + if err := m.Setting.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Setting) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Setting: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Setting: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ModifiedAt", wireType) + } + m.ModifiedAt = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ModifiedAt |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CollectionRule) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CollectionRule: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CollectionRule: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + m.Id = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Id |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourceLabels", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SourceLabels = append(m.SourceLabels, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Separator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + s := string(dAtA[iNdEx:postIndex]) + m.Separator = &s + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Regex", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + s := string(dAtA[iNdEx:postIndex]) + m.Regex = &s + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Modulus", wireType) + } + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Modulus = &v + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TargetLabel", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + s := string(dAtA[iNdEx:postIndex]) + m.TargetLabel = &s + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Replacement", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + s := string(dAtA[iNdEx:postIndex]) + m.Replacement = &s + iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Action", wireType) + } + m.Action = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Action |= CollectionRuleAction(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CollectionRuleStore) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CollectionRuleStore: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CollectionRuleStore: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Rules", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Rules = append(m.Rules, &CollectionRule{}) + if err := m.Rules[len(m.Rules)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LastUpdated", wireType) + } + m.LastUpdated = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LastUpdated |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CollectionTarget) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CollectionTarget: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CollectionTarget: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Labels", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Labels = append(m.Labels, &v1.LabelPair{}) + if unmarshal, ok := interface{}(m.Labels[len(m.Labels)-1]).(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.Labels[len(m.Labels)-1]); err != nil { + return err + } + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CollectionInstance) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CollectionInstance: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CollectionInstance: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hostname", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Hostname = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Targets", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Targets = append(m.Targets, &CollectionTarget{}) + if err := m.Targets[len(m.Targets)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LastUpdated", wireType) + } + m.LastUpdated = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LastUpdated |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CollectionMessage) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CollectionMessage: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CollectionMessage: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= Status(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + s := string(dAtA[iNdEx:postIndex]) + m.Message = &s + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + m.Id = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Id |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PayloadSubscribe", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength } - if iNdEx >= l { + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + if m.PayloadSubscribe == nil { + m.PayloadSubscribe = &CollectionPayloadSubscribe{} } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: GetSettingsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetSettingsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { + if err := m.PayloadSubscribe.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { return err } - if (skippy < 0) || (iNdEx+skippy) < 0 { + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PayloadData", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { return protohelpers.ErrInvalidLength } - if (iNdEx + skippy) > l { + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > 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 *GetSettingsResponse) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow + if m.PayloadData == nil { + m.PayloadData = &CollectionPayloadData{} } - if iNdEx >= l { + if err := m.PayloadData.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PayloadRuleInsert", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + if m.PayloadRuleInsert == nil { + m.PayloadRuleInsert = &CollectionPayloadRuleInsert{} } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: GetSettingsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetSettingsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + if err := m.PayloadRuleInsert.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Settings", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PayloadRuleDelete", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -755,8 +3212,10 @@ func (m *GetSettingsResponse) UnmarshalVT(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Settings = append(m.Settings, &Setting{}) - if err := m.Settings[len(m.Settings)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + if m.PayloadRuleDelete == nil { + m.PayloadRuleDelete = &CollectionPayloadRuleDelete{} + } + if err := m.PayloadRuleDelete.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -782,7 +3241,7 @@ func (m *GetSettingsResponse) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *SetSettingsRequest) UnmarshalVT(dAtA []byte) error { +func (m *CollectionPayloadSubscribe) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -805,17 +3264,17 @@ func (m *SetSettingsRequest) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: SetSettingsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: CollectionPayloadSubscribe: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: SetSettingsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: CollectionPayloadSubscribe: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Setting", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Topics", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return protohelpers.ErrIntOverflow @@ -825,27 +3284,23 @@ func (m *SetSettingsRequest) 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 protohelpers.ErrInvalidLength } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return protohelpers.ErrInvalidLength } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Setting == nil { - m.Setting = &Setting{} - } - if err := m.Setting.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Topics = append(m.Topics, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex default: iNdEx = preIndex @@ -869,7 +3324,7 @@ func (m *SetSettingsRequest) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *SetSettingsResponse) UnmarshalVT(dAtA []byte) error { +func (m *CollectionPayloadData) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -892,15 +3347,15 @@ func (m *SetSettingsResponse) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: SetSettingsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: CollectionPayloadData: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: SetSettingsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: CollectionPayloadData: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Setting", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Rules", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -927,10 +3382,42 @@ func (m *SetSettingsResponse) UnmarshalVT(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Setting == nil { - m.Setting = &Setting{} + m.Rules = append(m.Rules, &CollectionRule{}) + if err := m.Rules[len(m.Rules)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } - if err := m.Setting.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Instances", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Instances = append(m.Instances, &CollectionInstance{}) + if err := m.Instances[len(m.Instances)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -956,7 +3443,7 @@ func (m *SetSettingsResponse) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *Setting) UnmarshalVT(dAtA []byte) error { +func (m *CollectionPayloadRuleInsert) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -979,17 +3466,17 @@ func (m *Setting) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Setting: wiretype end group for non-group") + return fmt.Errorf("proto: CollectionPayloadRuleInsert: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Setting: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: CollectionPayloadRuleInsert: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Rule", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return protohelpers.ErrIntOverflow @@ -999,29 +3486,33 @@ func (m *Setting) 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 protohelpers.ErrInvalidLength } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return protohelpers.ErrInvalidLength } if postIndex > l { return io.ErrUnexpectedEOF } - m.Name = string(dAtA[iNdEx:postIndex]) + if m.Rule == nil { + m.Rule = &CollectionRule{} + } + if err := m.Rule.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field After", wireType) } - var stringLen uint64 + var v int64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return protohelpers.ErrIntOverflow @@ -1031,29 +3522,68 @@ func (m *Setting) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + v |= int64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protohelpers.ErrInvalidLength + m.After = &v + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err } - postIndex := iNdEx + intStringLen - if postIndex < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return protohelpers.ErrInvalidLength } - if postIndex > l { + if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } - m.Value = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CollectionPayloadRuleDelete) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CollectionPayloadRuleDelete: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CollectionPayloadRuleDelete: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ModifiedAt", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) } - m.ModifiedAt = 0 + m.Id = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return protohelpers.ErrIntOverflow @@ -1063,7 +3593,7 @@ func (m *Setting) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ModifiedAt |= int64(b&0x7F) << shift + m.Id |= int64(b&0x7F) << shift if b < 0x80 { break } diff --git a/api/openapiv2/gen/phlare.swagger.json b/api/openapiv2/gen/phlare.swagger.json index 5e3391dede..be50cd6e5d 100644 --- a/api/openapiv2/gen/phlare.swagger.json +++ b/api/openapiv2/gen/phlare.swagger.json @@ -66,7 +66,7 @@ "default": { "description": "An unexpected error response.", "schema": { - "$ref": "#/definitions/rpcStatus" + "$ref": "#/definitions/googlerpcStatus" } } }, @@ -89,7 +89,7 @@ "default": { "description": "An unexpected error response.", "schema": { - "$ref": "#/definitions/rpcStatus" + "$ref": "#/definitions/googlerpcStatus" } } }, @@ -111,7 +111,7 @@ "default": { "description": "An unexpected error response.", "schema": { - "$ref": "#/definitions/rpcStatus" + "$ref": "#/definitions/googlerpcStatus" } } }, @@ -134,7 +134,7 @@ "default": { "description": "An unexpected error response.", "schema": { - "$ref": "#/definitions/rpcStatus" + "$ref": "#/definitions/googlerpcStatus" } } }, @@ -168,6 +168,25 @@ }, "description": "Message that represents an arbitrary HTTP body. It should only be used for\npayload formats that can't be represented as JSON, such as raw binary or\nan HTML page.\n\n\nThis message can be used both in streaming and non-streaming API methods in\nthe request as well as the response.\n\nIt can be used as a top-level request field, which is convenient if one\nwants to extract parameters from either the URL or HTTP template into the\nrequest fields and also want access to the raw HTTP body.\n\nExample:\n\n message GetResourceRequest {\n // A unique request id.\n string request_id = 1;\n\n // The raw HTTP body is bound to this field.\n google.api.HttpBody http_body = 2;\n\n }\n\n service ResourceService {\n rpc GetResource(GetResourceRequest)\n returns (google.api.HttpBody);\n rpc UpdateResource(google.api.HttpBody)\n returns (google.protobuf.Empty);\n\n }\n\nExample with streaming methods:\n\n service CaldavService {\n rpc GetCalendar(stream google.api.HttpBody)\n returns (stream google.api.HttpBody);\n rpc UpdateCalendar(stream google.api.HttpBody)\n returns (stream google.api.HttpBody);\n\n }\n\nUse of this type only changes how the request and response bodies are\nhandled, all other features will continue to work unchanged." }, + "googlerpcStatus": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + }, + "details": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/protobufAny" + } + } + } + }, "googlev1Label": { "type": "object", "properties": { @@ -419,25 +438,6 @@ } } }, - "rpcStatus": { - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - }, - "details": { - "type": "array", - "items": { - "type": "object", - "$ref": "#/definitions/protobufAny" - } - } - } - }, "segmentwriterv1PushResponse": { "type": "object" }, diff --git a/api/settings/v1/setting.proto b/api/settings/v1/setting.proto index fb7375bfb9..82cd458434 100644 --- a/api/settings/v1/setting.proto +++ b/api/settings/v1/setting.proto @@ -2,6 +2,8 @@ syntax = "proto3"; package settings.v1; +import "types/v1/types.proto"; + service SettingsService { rpc Get(GetSettingsRequest) returns (GetSettingsResponse) {} rpc Set(SetSettingsRequest) returns (SetSettingsResponse) {} @@ -26,3 +28,104 @@ message Setting { string value = 2; int64 modifiedAt = 3; } + +// CollectionRuleAction is the action to be performed on relabeling. +// aligns to https://github.com/prometheus/prometheus/blob/f24ce00320f8605add7c7c5e69f722193c066672/model/relabel/relabel.go#L40-L66 +enum CollectionRuleAction { + COLLECTION_RULE_ACTION_UNSPECIFIED = 0; + // Replace performs a regex replacement. + COLLECTION_RULE_ACTION_REPLACE = 1; + // Keep drops targets for which the input does not match the regex. + COLLECTION_RULE_ACTION_KEEP = 2; + // Drop drops targets for which the input does match the regex. + COLLECTION_RULE_ACTION_DROP = 3; + // KeepEqual drops targets for which the input does not match the target. + COLLECTION_RULE_ACTION_KEEP_EQUAL = 4; + // DropEqual drops targets for which the input does match the target. + COLLECTION_RULE_ACTION_DROP_EQUAL = 5; + // HashMod sets a label to the modulus of a hash of labels. + COLLECTION_RULE_ACTION_HASHMOD = 6; + // LabelMap copies labels to other labelnames based on a regex. + COLLECTION_RULE_ACTION_LABELMAP = 7; + // LabelDrop drops any label matching the regex. + COLLECTION_RULE_ACTION_LABELDROP = 8; + // LabelKeep drops any label not matching the regex. + COLLECTION_RULE_ACTION_LABELKEEP = 9; + // Lowercase maps input letters to their lower case. + COLLECTION_RULE_ACTION_LOWERCASE = 10; + // Uppercase maps input letters to their upper case. + COLLECTION_RULE_ACTION_UPPERCASE = 11; +} + +// CollectionRule is the configuration for relabeling of target label sets. +// aligns to https://github.com/prometheus/prometheus/blob/f24ce00320f8605add7c7c5e69f722193c066672/model/relabel/relabel.go#L82C1-L100C2 +message CollectionRule { + int64 id = 1; + // A list of labels from which values are taken and concatenated + // with the configured separator in order. + repeated string source_labels = 2; + // separator is the string between concatenated values from the source labels. + optional string separator = 3; + // regex against which the concatenation is matched. + optional string regex = 4; + // modulus to take of the hash of concatenated values from the source labels. + optional uint64 modulus = 5; + // target_label is the label to which the resulting string is written in a replacement. + // Regexp interpolation is allowed for the replace action. + optional string target_label = 6; + // replacement is the regex replacement pattern to be used. + optional string replacement = 7; + // action is the action to be performed for the relabeling. + CollectionRuleAction action = 8; +} + +// CollectionRuleStore is how the message gets stored in object store +message CollectionRuleStore { + repeated CollectionRule rules = 1; + int64 last_updated = 2; // milliseconds unix time +} + +message CollectionTarget { + repeated types.v1.LabelPair labels = 1; +} + +// CollectionInstance represents a single instance of the collection agent (generally Grafana Alloy) +message CollectionInstance { + string hostname = 1; + repeated CollectionTarget targets = 2; + int64 last_updated = 3; // milliseconds unix time +} + +enum Status { + STATUS_UNSPECIFIED = 0; + STATUS_OK = 1; + STATUS_ERROR = 2; +} + +message CollectionMessage { + Status status = 1; + optional string message = 2; + int64 id = 3; + CollectionPayloadSubscribe payload_subscribe = 4; + CollectionPayloadData payload_data = 5; + CollectionPayloadRuleInsert payload_rule_insert = 6; + CollectionPayloadRuleDelete payload_rule_delete = 7; +} + +message CollectionPayloadSubscribe { + repeated string topics = 1; +} + +message CollectionPayloadData { + repeated CollectionRule rules = 1; + repeated CollectionInstance instances = 2; +} + +message CollectionPayloadRuleInsert { + CollectionRule rule = 1; + optional int64 after = 2; +} + +message CollectionPayloadRuleDelete { + int64 id = 1; +} diff --git a/cmd/profilecli/collection_rules.go b/cmd/profilecli/collection_rules.go new file mode 100644 index 0000000000..d516850c88 --- /dev/null +++ b/cmd/profilecli/collection_rules.go @@ -0,0 +1,369 @@ +package main + +import ( + "context" + "fmt" + "net/http" + "path/filepath" + "strings" + "time" + + "github.com/go-kit/log/level" + "github.com/gorilla/websocket" + jsoniter "github.com/json-iterator/go" + "github.com/prometheus/prometheus/model/relabel" + "golang.org/x/exp/rand" + "gopkg.in/yaml.v3" + + settingsv1 "github.com/grafana/pyroscope/api/gen/proto/go/settings/v1" + "github.com/grafana/pyroscope/pkg/settings/collection" +) + +type collectionRulesParams struct { + *phlareClient + Scope string +} + +func addCollectionRulesParams(collectionRuleCmd commander) *collectionRulesParams { + params := new(collectionRulesParams) + params.phlareClient = addPhlareClient(collectionRuleCmd) + collectionRuleCmd.Flag("scope", "Collection rule scope.").Default("alloy").StringVar(¶ms.Scope) + return params +} + +type noopRoundTripper struct{} + +func (n *noopRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { + return new(http.Response), nil +} + +type rulesClient struct { + conn *websocket.Conn + id int64 +} + +func (c *rulesClient) msgID() int64 { + if c.id == 0 { + randomId := rand.Int63() + c.id = randomId + return randomId + } + c.id++ + return c.id +} + +func msgType(msg *settingsv1.CollectionMessage) string { + if msg.PayloadRuleInsert != nil { + return "settings.v1.CollectionPayloadRuleInsert" + } + if msg.PayloadSubscribe != nil { + return "settings.v1.CollectionPayloadSubscribe" + } + if msg.PayloadData != nil { + return "settings.v1.CollectionPayloadData" + } + if msg.PayloadRuleDelete != nil { + return "settings.v1.CollectionPayloadRuleDelete" + } + return "" +} + +func (c *rulesClient) request(ctx context.Context, req *settingsv1.CollectionMessage) error { + ctx, cancel := context.WithTimeout(ctx, time.Second*5) + defer cancel() + + if req.Id == 0 { + req.Id = c.msgID() + } + level.Debug(logger).Log("msg", "request", "msg.id", req.Id, "msg.type", msgType(req)) + + if err := c.conn.WriteJSON(req); err != nil { + return err + } + + errChan := make(chan error) + resp := new(settingsv1.CollectionMessage) + + go func() { + for { + resp.Reset() + if err := c.conn.ReadJSON(resp); err != nil { + errChan <- err + return + } + if req.Id != resp.Id { + continue + } + errChan <- nil + return + } + }() + + select { + case err := <-errChan: + if err != nil { + return err + } + level.Debug(logger).Log("msg", "received resp", "msg.id", resp.Id, "msg.type", msgType(req)) + + if resp.Status != settingsv1.Status_STATUS_OK { + if resp.Message != nil { + return fmt.Errorf("status: %s message: %s", resp.Status.String(), *resp.Message) + } + return fmt.Errorf("status: %s", resp.Status.String()) + } + + case <-ctx.Done(): + return ctx.Err() + } + + return nil +} + +func (c *rulesClient) Insert(ctx context.Context, rule *settingsv1.CollectionRule, after *int64) error { + return c.request(ctx, &settingsv1.CollectionMessage{ + Id: c.msgID(), + PayloadRuleInsert: &settingsv1.CollectionPayloadRuleInsert{ + After: after, + Rule: rule, + }, + }) +} + +func (c *rulesClient) Delete(ctx context.Context, id int64) error { + return c.request(ctx, &settingsv1.CollectionMessage{ + Id: c.msgID(), + PayloadRuleDelete: &settingsv1.CollectionPayloadRuleDelete{ + Id: id, + }, + }) +} + +func (c *rulesClient) List(ctx context.Context) ([]*settingsv1.CollectionRule, error) { + ctx, cancel := context.WithTimeout(ctx, time.Second*5) + defer cancel() + + req := &settingsv1.CollectionMessage{ + Id: c.msgID(), + PayloadSubscribe: &settingsv1.CollectionPayloadSubscribe{ + Topics: []string{"rules"}, + }, + } + level.Debug(logger).Log("msg", "subscribed to rules", "id", req.Id) + + if err := c.conn.WriteJSON(req); err != nil { + return nil, err + } + + errChan := make(chan error) + resp := new(settingsv1.CollectionMessage) + + go func() { + for { + resp.Reset() + if err := c.conn.ReadJSON(resp); err != nil { + errChan <- err + return + } + if resp.PayloadData == nil { + continue + } + errChan <- nil + return + } + }() + + select { + case err := <-errChan: + if err != nil { + return nil, err + } + + level.Debug(logger).Log("msg", "received rules", "rules", len(resp.PayloadData.Rules)) + return resp.PayloadData.Rules, nil + case <-ctx.Done(): + return nil, ctx.Err() + } +} + +func (p *phlareClient) collectionRulesConn(endpoint string, scope string) (*rulesClient, error) { + req, err := http.NewRequest("GET", p.URL, nil) + if err != nil { + return nil, err + } + + // replace http with ws and https with wss + if strings.HasPrefix(req.URL.Scheme, "http") { + req.URL.Scheme = "ws" + req.URL.Scheme[4:] + } + + req.URL.Path = filepath.Join( + req.URL.Path, + endpoint, + ) + query := req.URL.Query() + query.Add("scope", scope) + req.URL.RawQuery = query.Encode() + + // go through roundtripper to add auth headers + r := &authRoundTripper{ + client: p, + next: &noopRoundTripper{}, + } + _, err = r.RoundTrip(req) + if err != nil { + return nil, err + } + + level.Debug(logger).Log("msg", "opening websocket", "url", req.URL.String()) + c, resp, err := websocket.DefaultDialer.Dial(req.URL.String(), req.Header) + if err != nil { + return nil, fmt.Errorf("failed to open websocket status_code=%d message=%s: %w", resp.StatusCode, resp.Status, err) + } + return &rulesClient{conn: c}, nil +} + +func (p *phlareClient) collectionRulesUpdater(scope string) (*rulesClient, error) { + return p.collectionRulesConn("settings.v1.SettingsService/UpdateCollectionRules", scope) +} + +func (p *phlareClient) CollectionRulesGetter(scope string) (*rulesClient, error) { + return p.collectionRulesConn("settings.v1.SettingsService/GetCollectionRules", scope) +} + +func collectionRulesList(ctx context.Context, params *collectionRulesParams) error { + c, err := params.collectionRulesUpdater(params.Scope) + if err != nil { + return err + } + + rules, err := c.List(ctx) + if err != nil { + return err + } + + bytes, err := jsoniter.Marshal(rules) + if err != nil { + return err + } + + var yamlIntf []interface{} + err = yaml.Unmarshal(bytes, &yamlIntf) + if err != nil { + return err + } + + yamlBytes, err := yaml.Marshal(yamlIntf) + if err != nil { + return err + } + + fmt.Fprintln(output(ctx), string(yamlBytes)) + + return nil +} + +type collectionRulesInsertParams struct { + *collectionRulesParams + afterRuleID *int64 + sourceLabels []string + separator *string + regex *string + modulus *uint64 + targetLabel *string + replacement *string + action string +} + +func addCollectionRulesInsertParams(collectionRuleCmd commander) *collectionRulesInsertParams { + params := new(collectionRulesInsertParams) + params.collectionRulesParams = addCollectionRulesParams(collectionRuleCmd) + collectionRuleCmd.Flag("after-rule-id", "The rule id after which this rule should be inserted.").Int64Var(params.afterRuleID) + collectionRuleCmd.Flag("source-label", "A list of labels from which values are taken and concatenatedwith the configured separator in order.").StringsVar(¶ms.sourceLabels) + collectionRuleCmd.Flag("separator", "Separator is the string between concatenated values from the source labels.").StringVar(params.separator) + collectionRuleCmd.Flag("regex", "Regex against which the concatenation is matched.").StringVar(params.regex) + collectionRuleCmd.Flag("modulus", "Modulus to take of the hash of concatenated values from the source labels.").Uint64Var(params.modulus) + collectionRuleCmd.Flag("target-label", "TargetLabel is the label to which the resulting string is written in a replacement. Regexp interpolation is allowed for the replace action.").StringVar(params.targetLabel) + collectionRuleCmd.Flag("replacement", "Replacement is the regex replacement pattern to be used.").StringVar(params.replacement) + collectionRuleCmd.Flag("action", "Action is the action to be performed for the relabeling.").Required().EnumVar( + ¶ms.action, + string(relabel.Replace), + string(relabel.Keep), + string(relabel.Drop), + string(relabel.KeepEqual), + string(relabel.DropEqual), + string(relabel.HashMod), + string(relabel.LabelMap), + string(relabel.LabelDrop), + string(relabel.LabelKeep), + string(relabel.Lowercase), + string(relabel.Uppercase), + ) + return params +} + +func ruleStringToCollectionRule(rule string) (settingsv1.CollectionRuleAction, error) { + key := "COLLECTION_RULE_ACTION_" + strings.ToUpper(rule) + + x, ok := settingsv1.CollectionRuleAction_value[key] + if !ok { + return settingsv1.CollectionRuleAction_COLLECTION_RULE_ACTION_UNSPECIFIED, fmt.Errorf("invalid action: %s", rule) + } + + return settingsv1.CollectionRuleAction(x), nil +} + +func collectionRulesInsert(ctx context.Context, params *collectionRulesInsertParams) error { + action, err := ruleStringToCollectionRule(params.action) + if err != nil { + return err + } + + rule := &settingsv1.CollectionRule{ + SourceLabels: params.sourceLabels, + Separator: params.separator, + Regex: params.regex, + Modulus: params.modulus, + TargetLabel: params.targetLabel, + Replacement: params.replacement, + Action: action, + } + + x, err := collection.CollectionRuleToRelabelConfig(rule) + if err != nil { + return err + } + + err = x.Validate() + if err != nil { + return err + } + + c, err := params.collectionRulesUpdater(params.Scope) + if err != nil { + return err + } + + return c.Insert(ctx, rule, params.afterRuleID) +} + +type collectionRulesDeleteParams struct { + *collectionRulesParams + ruleID int64 +} + +func addCollectionRulesDeleteParams(collectionRuleCmd commander) *collectionRulesDeleteParams { + params := new(collectionRulesDeleteParams) + params.collectionRulesParams = addCollectionRulesParams(collectionRuleCmd) + collectionRuleCmd.Flag("rule-id", "The rule id to be deleted.").Required().Int64Var(¶ms.ruleID) + return params +} + +func collectionRulesDelete(ctx context.Context, params *collectionRulesDeleteParams) error { + c, err := params.collectionRulesUpdater(params.Scope) + if err != nil { + return err + } + + return c.Delete(ctx, params.ruleID) +} diff --git a/cmd/profilecli/main.go b/cmd/profilecli/main.go index f88f69424c..283b6a72ea 100644 --- a/cmd/profilecli/main.go +++ b/cmd/profilecli/main.go @@ -92,6 +92,14 @@ func main() { readyCmd := app.Command("ready", "Check Pyroscope health.") readyParams := addReadyParams(readyCmd) + collectionRulesCmd := app.Command("collection-rules", "Operate on collection rules.") + collectionRulesListCmd := collectionRulesCmd.Command("list", "List collection rules.") + collectionRulesListParams := addCollectionRulesParams(collectionRulesListCmd) + collectionRulesInsertCmd := collectionRulesCmd.Command("insert", "Insert collection rule.") + collectionRulesInsertParams := addCollectionRulesInsertParams(collectionRulesInsertCmd) + collectionRulesDeleteCmd := collectionRulesCmd.Command("delete", "Delete collection rule.") + collectionRulesDeleteParams := addCollectionRulesDeleteParams(collectionRulesDeleteCmd) + // parse command line arguments parsedCmd := kingpin.MustParse(app.Parse(os.Args[1:])) @@ -158,6 +166,18 @@ func main() { if err := ready(ctx, readyParams); err != nil { os.Exit(checkError(err)) } + case collectionRulesListCmd.FullCommand(): + if err := collectionRulesList(ctx, collectionRulesListParams); err != nil { + os.Exit(checkError(err)) + } + case collectionRulesInsertCmd.FullCommand(): + if err := collectionRulesInsert(ctx, collectionRulesInsertParams); err != nil { + os.Exit(checkError(err)) + } + case collectionRulesDeleteCmd.FullCommand(): + if err := collectionRulesDelete(ctx, collectionRulesDeleteParams); err != nil { + os.Exit(checkError(err)) + } default: level.Error(logger).Log("msg", "unknown command", "cmd", parsedCmd) } diff --git a/go.mod b/go.mod index 52cfbdde70..c25c484efb 100644 --- a/go.mod +++ b/go.mod @@ -27,6 +27,7 @@ require ( github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7 github.com/google/uuid v1.6.0 github.com/gorilla/mux v1.8.0 + github.com/gorilla/websocket v1.5.0 github.com/grafana/alloy/syntax v0.1.0 github.com/grafana/dskit v0.0.0-20231221015914-de83901bf4d6 github.com/grafana/jfr-parser/pprof v0.0.0-20240228024232-8abcb81c304c diff --git a/pkg/api/api.go b/pkg/api/api.go index aeca3c9298..778fe31abc 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -55,6 +55,7 @@ import ( "github.com/grafana/pyroscope/pkg/scheduler" "github.com/grafana/pyroscope/pkg/scheduler/schedulerpb/schedulerpbconnect" "github.com/grafana/pyroscope/pkg/settings" + "github.com/grafana/pyroscope/pkg/settings/collection" "github.com/grafana/pyroscope/pkg/storegateway" "github.com/grafana/pyroscope/pkg/util" "github.com/grafana/pyroscope/pkg/util/gziphandler" @@ -212,6 +213,8 @@ func (a *API) RegisterRuntimeConfig(runtimeConfigHandler http.HandlerFunc, userL func (a *API) RegisterTenantSettings(ts *settings.TenantSettings) { settingsv1connect.RegisterSettingsServiceHandler(a.server.HTTP, ts, a.connectOptionsAuthRecovery()...) + a.RegisterRoute("/settings.v1.SettingsService/GetCollectionRules", ts.HandleCollectionSettings(collection.RuleReceiver), true, false, "GET") + a.RegisterRoute("/settings.v1.SettingsService/UpdateCollectionRules", ts.HandleCollectionSettings(collection.RuleManager), true, false, "GET") } // RegisterOverridesExporter registers the endpoints associated with the overrides exporter. diff --git a/pkg/phlare/modules.go b/pkg/phlare/modules.go index 0fe7b78ded..dea217d25d 100644 --- a/pkg/phlare/modules.go +++ b/pkg/phlare/modules.go @@ -148,21 +148,7 @@ func (f *Phlare) initRuntimeConfig() (services.Service, error) { } func (f *Phlare) initTenantSettings() (services.Service, error) { - var store settings.Store - var err error - - switch { - case f.storageBucket != nil: - store, err = settings.NewBucketStore(f.storageBucket) - default: - store, err = settings.NewMemoryStore() - level.Warn(f.logger).Log("msg", "using in-memory settings store, changes will be lost after shutdown") - } - if err != nil { - return nil, errors.Wrap(err, "failed to init settings store") - } - - settings, err := settings.New(store, log.With(f.logger, "component", TenantSettings)) + settings, err := settings.New(f.storageBucket, log.With(f.logger, "component", TenantSettings)) if err != nil { return nil, errors.Wrap(err, "failed to init settings service") } diff --git a/pkg/settings/bucket.go b/pkg/settings/bucket.go index 10105131f3..b8e9957c89 100644 --- a/pkg/settings/bucket.go +++ b/pkg/settings/bucket.go @@ -19,20 +19,17 @@ var ( settingsFilename = "tenant_settings.json" ) -// NewMemoryStore will create a settings store with an in-memory objstore -// bucket. -func NewMemoryStore() (Store, error) { - return NewBucketStore(objstore.NewInMemBucket()) +// newMemoryStore will create a settings store with an in-memory bucket. +func newMemoryStore() store { + return newBucketStore(objstore.NewInMemBucket()) } // NewBucketStore will create a settings store with an objstore bucket. -func NewBucketStore(bucket objstore.Bucket) (Store, error) { - store := &bucketStore{ +func newBucketStore(bucket objstore.Bucket) store { + return &bucketStore{ store: make(map[string]map[string]*settingsv1.Setting), bucket: bucket, } - - return store, nil } type bucketStore struct { diff --git a/pkg/settings/bucket_test.go b/pkg/settings/bucket_test.go index 9aec3b480f..f5db0ac8a6 100644 --- a/pkg/settings/bucket_test.go +++ b/pkg/settings/bucket_test.go @@ -15,15 +15,14 @@ func TestMemoryBucket_Get(t *testing.T) { tenantID := "[anonymous]" t.Run("get settings are sorted", func(t *testing.T) { - mem, err := NewMemoryStore() - assert.NoError(t, err) + mem := newMemoryStore() settings := []*settingsv1.Setting{ {Name: "key1", Value: "val1"}, {Name: "key2", Value: "val2"}, } for _, s := range settings { - _, err = mem.Set(ctx, tenantID, s) + _, err := mem.Set(ctx, tenantID, s) assert.NoError(t, err) } got, err := mem.Get(ctx, tenantID) @@ -35,8 +34,8 @@ func TestMemoryBucket_Get(t *testing.T) { }) t.Run("don't get settings from another tenant", func(t *testing.T) { - mem, err := NewMemoryStore() - assert.NoError(t, err) + var err error + mem := newMemoryStore() otherTenantID := "other" @@ -69,8 +68,7 @@ func TestMemoryBucket_Set(t *testing.T) { tenantID := "[anonymous]" t.Run("set a new key", func(t *testing.T) { - mem, err := NewMemoryStore() - assert.NoError(t, err) + mem := newMemoryStore() setting := &settingsv1.Setting{ Name: "key1", @@ -82,8 +80,7 @@ func TestMemoryBucket_Set(t *testing.T) { }) t.Run("update a key", func(t *testing.T) { - mem, err := NewMemoryStore() - assert.NoError(t, err) + mem := newMemoryStore() setting := &settingsv1.Setting{ Name: "key1", @@ -103,8 +100,7 @@ func TestMemoryBucket_Set(t *testing.T) { }) t.Run("don't update a key that's too old", func(t *testing.T) { - mem, err := NewMemoryStore() - assert.NoError(t, err) + mem := newMemoryStore() setting := &settingsv1.Setting{ Name: "key1", diff --git a/pkg/settings/collection/collection.go b/pkg/settings/collection/collection.go new file mode 100644 index 0000000000..313d42aa56 --- /dev/null +++ b/pkg/settings/collection/collection.go @@ -0,0 +1,166 @@ +package collection + +import ( + "context" + "fmt" + "net/http" + "regexp" + "sync" + + "github.com/go-kit/log" + "github.com/go-kit/log/level" + "github.com/gorilla/websocket" + "github.com/grafana/dskit/tenant" + "github.com/thanos-io/objstore" +) + +type Config struct{} + +const ( + // topic for rule updates + topicRules = "rules" + // topic for instance updates + topicInstances = "instances" +) + +// Collection handles the communication with Grafana Alloy, and ensures that subscribed instance received updates to rules. +// For each tenant and scope a new hub is created. +type Collection struct { + cfg Config + bucket objstore.Bucket + logger log.Logger + wg sync.WaitGroup + stopCh chan struct{} + + lck sync.RWMutex + + upgrader websocket.Upgrader + hubs map[hubKey]*hub +} + +func New(cfg Config, bucket objstore.Bucket, logger log.Logger) *Collection { + return &Collection{ + cfg: cfg, + bucket: bucket, + logger: logger, + upgrader: websocket.Upgrader{ + ReadBufferSize: 1024, + WriteBufferSize: 1024, + CheckOrigin: func(r *http.Request) bool { return true }, // TODO: check origin + }, + hubs: make(map[hubKey]*hub), + stopCh: make(chan struct{}), + } +} + +type Role int + +const ( + RuleReceiver Role = 1 << iota + RuleManager +) + +var ( + validScopeName = regexp.MustCompile(`^[a-zA-Z0-9_-]+$`) + errInvalidScopeName = fmt.Errorf("invalid scope name, must match %s", validScopeName) +) + +func (c *Collection) Stop(ctx context.Context) { + close(c.stopCh) + c.wg.Wait() +} + +func (c *Collection) HandleSettings(role Role) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + c.handleWS(w, req, role) + }) +} + +func (c *Collection) handleWS(w http.ResponseWriter, r *http.Request, role Role) { + tenantID, err := tenant.TenantID(r.Context()) + if err != nil { + level.Warn(c.logger).Log("error getting tenant ID", "err", err) + return + } + + // get request parameter scope from r + scope := defaultScope + if r.URL.Query().Has("scope") { + paramScope := r.URL.Query().Get("scope") + if validScopeName.MatchString(paramScope) { + scope = paramScope + } else { + level.Warn(c.logger).Log("err", errInvalidScopeName, "scope", paramScope) + http.Error(w, errInvalidScopeName.Error(), http.StatusBadRequest) + return + } + } + + conn, err := c.upgrader.Upgrade(w, r, nil) + if err != nil { + level.Warn(c.logger).Log("error upgrading websocket", "err", err) + return + } + + hub := c.getHub(hubKey{tenantID: tenantID, scope: scope}) + + client := &client{ + hub: hub, + conn: conn, + send: make(chan []byte, 256), + role: role, + } + client.logger = log.With(hub.logger, "remote", r.RemoteAddr, "user-agent", r.Header.Get("user-agent"), "client", fmt.Sprintf("%p", client)) + level.Debug(client.logger).Log("msg", "new websocket client", "is-rule-manager", client.isRuleManager()) + hub.registerCh <- client + + // Allow collection of memory referenced by the caller by doing all work in + // new goroutines. + c.wg.Add(2) + go func() { + defer c.wg.Done() + client.writePump() + }() + go func() { + defer c.wg.Done() + client.readPump() + }() +} + +func defaultTopics(h *hub) []*topic { + return []*topic{ + newTopic(topicInstances, h.updateInstancesPayload), + newTopic(topicRules, h.updateRulesPayload), + } +} + +func (c *Collection) getHub(k hubKey) *hub { + c.lck.RLock() + h, ok := c.hubs[k] + if ok { + c.lck.RUnlock() + return h + } + c.lck.RUnlock() + + // now get write lock and recheck + c.lck.Lock() + defer c.lck.Unlock() + h, ok = c.hubs[k] + if ok { + return h + } + + h = newHub( + log.With(c.logger, "tenant", k.tenantID, "scope", k.scope), + newBucketStore(c.bucket, k), + defaultTopics, + ) + c.wg.Add(1) + go func() { + defer c.wg.Done() + h.run(c.stopCh) + }() + c.hubs[k] = h + return h +} diff --git a/pkg/settings/collection/collection_test.go b/pkg/settings/collection/collection_test.go new file mode 100644 index 0000000000..9db70c5d3f --- /dev/null +++ b/pkg/settings/collection/collection_test.go @@ -0,0 +1,158 @@ +package collection + +import ( + "context" + "encoding/json" + "net/http" + "net/http/httptest" + "os" + "strings" + "sync" + "testing" + "time" + + "github.com/go-kit/log" + "github.com/gorilla/websocket" + "github.com/grafana/dskit/user" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/thanos-io/objstore" + "go.uber.org/goleak" + "gopkg.in/yaml.v3" + + settingsv1 "github.com/grafana/pyroscope/api/gen/proto/go/settings/v1" +) + +var ( + payloadSubscribeRules = []byte(`{"payload_subscribe":{"topics":["rules"]}}`) +) + +func ruleMsg(rule *settingsv1.CollectionRule, after int64) *settingsv1.CollectionMessage { + var afterPtr *int64 + if after != 0 { + afterPtr = &after + } + return &settingsv1.CollectionMessage{ + PayloadRuleInsert: &settingsv1.CollectionPayloadRuleInsert{ + Rule: rule, + After: afterPtr, + }, + } +} + +func stringPtr(s string) *string { + return &s +} + +func rulesToJson(t *testing.T, rules []*settingsv1.CollectionRule) string { + rc, err := CollectionRulesToRelabelConfigs(rules) + require.NoError(t, err) + + // first we need to convert to yaml, to ensure the marshalling is correct + bYAML, err := yaml.Marshal(&rc) + require.NoError(t, err) + + var m []interface{} + err = yaml.Unmarshal(bYAML, &m) + require.NoError(t, err) + + // now finally time for json + bJSON, err := json.Marshal(m) + require.NoError(t, err) + return string(bJSON) +} + +func TestCollection_TwoCollectionInstances_OneRuleManager(t *testing.T) { + defer goleak.VerifyNone(t, goleak.IgnoreCurrent()) + + // Setup code here + var logger = log.NewNopLogger() + if testing.Verbose() { + logger = log.NewLogfmtLogger(os.Stderr) + } + c := New(Config{}, objstore.NewInMemBucket(), logger) + defer c.Stop(context.Background()) + + // Create test server with the echo handler. + mux := http.NewServeMux() + mux.Handle("/collection", c.HandleSettings(RuleReceiver)) + mux.Handle("/manager", c.HandleSettings(RuleManager)) + s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + r = r.WithContext(user.InjectOrgID(r.Context(), "my-tenant")) + mux.ServeHTTP(w, r) + })) + defer s.Close() + + u := "ws" + strings.TrimPrefix(s.URL, "http") + + // setup rules + ruleManager, _, err := websocket.DefaultDialer.Dial(u+"/manager", nil) + require.NoError(t, err) + // drop everything else + require.NoError(t, ruleManager.WriteJSON(ruleMsg( + &settingsv1.CollectionRule{ + Action: settingsv1.CollectionRuleAction_COLLECTION_RULE_ACTION_DROP, + }, 0))) + + // keep loki service + require.NoError(t, ruleManager.WriteJSON(ruleMsg( + &settingsv1.CollectionRule{ + Action: settingsv1.CollectionRuleAction_COLLECTION_RULE_ACTION_KEEP, + SourceLabels: []string{"service_name"}, + Regex: stringPtr("loki-.*"), + }, 0))) + + // validate rules have been updated + require.Eventually(t, func() bool { + c.lck.RLock() + h, ok := c.hubs[hubKey{tenantID: "my-tenant", scope: defaultScope}] + if !ok { + c.lck.RUnlock() + return false + } + c.lck.RUnlock() + + rules, err := h.store.list(context.Background()) + if err != nil { + assert.NoError(t, err) + return false + } + + return len(rules) == 2 + }, 500000*time.Millisecond, time.Millisecond) + + // setup clients + collection1, _, err := websocket.DefaultDialer.Dial(u+"/collection", nil) + require.NoError(t, err) + collection2, _, err := websocket.DefaultDialer.Dial(u+"/collection", nil) + require.NoError(t, err) + + require.NoError(t, collection1.WriteMessage(websocket.TextMessage, payloadSubscribeRules)) + require.NoError(t, collection2.WriteMessage(websocket.TextMessage, payloadSubscribeRules)) + + var wg sync.WaitGroup + receiveRules := func(c *websocket.Conn) { + defer wg.Done() + var msg settingsv1.CollectionMessage + for { + err := c.ReadJSON(&msg) + require.NoError(t, err) + + if p := msg.PayloadData; p != nil { + // validate rules + require.JSONEq(t, `[ + {"action":"keep","regex":"loki-.*","replacement":"$1","separator":";","source_labels":["service_name"]}, + {"action":"drop","regex":"(.*)","replacement":"$1","separator":";"} + ]`, rulesToJson(t, p.Rules)) + + break + } + } + } + wg.Add(2) + receiveRules(collection1) + receiveRules(collection2) + + wg.Wait() + +} diff --git a/pkg/settings/collection/hub.go b/pkg/settings/collection/hub.go new file mode 100644 index 0000000000..9c66dbdc2f --- /dev/null +++ b/pkg/settings/collection/hub.go @@ -0,0 +1,364 @@ +package collection + +import ( + "context" + "encoding/json" + "fmt" + "log/slog" + "sync" + "time" + + "github.com/cespare/xxhash/v2" + "github.com/go-kit/log" + "github.com/go-kit/log/level" + + settingsv1 "github.com/grafana/pyroscope/api/gen/proto/go/settings/v1" +) + +const defaultScope = "profiles-collection" + +type topic struct { + name string + ch chan struct{} + update func(context.Context, *settingsv1.CollectionPayloadData) error + err error + content *settingsv1.CollectionPayloadData + hash uint64 + clients map[*client]uint64 +} + +func newTopic(name string, f func(context.Context, *settingsv1.CollectionPayloadData) error) *topic { + return &topic{ + name: name, + ch: make(chan struct{}), + update: f, + hash: 0, + clients: make(map[*client]uint64), + content: &settingsv1.CollectionPayloadData{}, + } +} + +type buf struct { + data []byte + hasher xxhash.Digest +} + +func (t *topic) get(ctx context.Context, b *buf) { + t.err = t.update(ctx, t.content) + if t.err != nil { + return + } + + n := t.content.SizeVT() + if cap(b.data) < n { + b.data = make([]byte, n) + } else { + b.data = b.data[:n] + } + _, t.err = t.content.MarshalToSizedBufferVT(b.data) + if t.err != nil { + return + } + + b.hasher.Reset() + _, t.err = b.hasher.Write(b.data) + if t.err != nil { + return + } + t.hash = b.hasher.Sum64() +} + +type hubKey struct { + tenantID string + scope string +} + +func (k hubKey) path() string { + return fmt.Sprintf("%s/settings/collection.%s", k.tenantID, k.scope) +} + +type hub struct { + logger log.Logger + + store *bucketStore + + lck sync.RWMutex // TODO: Figure out why? + topics map[string]*topic + + clients map[*client]struct{} + + instancesPublishing map[*client]bool // are particular instances publishing their targets + instancesPublishingActive bool // is instance targets publishing requested + instances map[string]*settingsv1.CollectionInstance + + // Register requests from the clients. + registerCh chan *client + + // Unregister requests from clients. + unregisterCh chan *client + + // Update instance targets + instanceCh chan *settingsv1.CollectionInstance + + // Update rules + rulesCh chan func(*hub) + + // keep data and hash buffer around + buf buf +} + +func newHub(logger log.Logger, store *bucketStore, topicsF func(*hub) []*topic) *hub { + h := &hub{ + logger: logger, + store: store, + topics: make(map[string]*topic), + clients: make(map[*client]struct{}), + instancesPublishing: make(map[*client]bool), + instances: make(map[string]*settingsv1.CollectionInstance), + instanceCh: make(chan *settingsv1.CollectionInstance), + registerCh: make(chan *client), + unregisterCh: make(chan *client), + rulesCh: make(chan func(*hub), 32), + } + + for _, topic := range topicsF(h) { + h.topics[topic.name] = topic + } + + return h +} + +// check data for topics to sent +func (h *hub) updateClientTopicsToPublish(ctx context.Context, client *client) error { + var payload []*settingsv1.CollectionPayloadData + for _, t := range h.topics { + clientHash, ok := t.clients[client] + if !ok { + continue + } + + if t.hash == 0 { + t.get(ctx, &h.buf) + } + + if clientHash == t.hash { + continue + } + + // need update + payload = append(payload, t.content) + t.clients[client] = t.hash + } + + if len(payload) > 0 { + merged := mergePayloads(payload...) + data, err := json.Marshal(&settingsv1.CollectionMessage{ + PayloadData: merged, + }) + if err != nil { + return fmt.Errorf("error generation JSON: %w", err) + } + client.send <- data + } + return nil +} + +// check if instance needs toggle publishing +func (h *hub) updateClientToggleInstanceSubscription(_ context.Context, client *client) error { + active, ok := h.instancesPublishing[client] + if !ok { + return nil + } + if active != h.instancesPublishingActive { + + msg := settingsv1.CollectionMessage{ + PayloadSubscribe: &settingsv1.CollectionPayloadSubscribe{}, + } + if !active { + msg.PayloadSubscribe.Topics = []string{topicInstances} + } + + data, err := json.Marshal(&msg) + if err != nil { + return err + } + + level.Debug(client.logger).Log("request instance target publishing", "client", fmt.Sprintf("%p", client), "data", string(data)) + client.send <- data + + h.instancesPublishing[client] = h.instancesPublishingActive + } + return nil +} + +func (h *hub) updateClient(ctx context.Context, client *client) { + if err := h.updateClientTopicsToPublish(ctx, client); err != nil { + level.Error(client.logger).Log("msg", "error updating client topics to publish", "err", err) + } + if err := h.updateClientToggleInstanceSubscription(ctx, client); err != nil { + level.Error(client.logger).Log("msg", "error updating client to subscribe to instances", "err", err) + } +} + +func (h *hub) updateInstances(ctx context.Context) { + t, ok := h.topics[topicInstances] + if !ok { + return + } + t.get(ctx, &h.buf) + + // update frontend with new instance data + for client := range t.clients { + h.updateClient(ctx, client) + } +} + +func (a *hub) insertRule(ctx context.Context, data *settingsv1.CollectionPayloadRuleInsert) error { + rc, err := CollectionRuleToRelabelConfig(data.Rule) + if err != nil { + return err + } + if err := rc.Validate(); err != nil { + return err + } + + return a.store.insertRule(ctx, data) +} + +func (h *hub) deleteRule(ctx context.Context, id int64) error { + return h.store.deleteRule(ctx, id) +} + +func (h *hub) run(stopCh <-chan struct{}) { + ctx := context.Background() + for { + select { + case client := <-h.registerCh: + h.clients[client] = struct{}{} + for _, topic := range client.SubscribedTopics() { + t, ok := h.topics[topic] + if !ok { + continue + } + _, ok = t.clients[client] + if ok { + continue + } + t.clients[client] = 0 + + } + if client.isRuleManager() { + h.instancesPublishing[client] = false + } + + // check if instance need toggle publishing + instanceTopic, ok := h.topics[topicInstances] + instancesPublishingRequested := false + if ok { + instancesPublishingRequested = len(instanceTopic.clients) != 0 + } + if instancesPublishingRequested != h.instancesPublishingActive { + if instancesPublishingRequested { + slog.Debug("instance targets publishing has been enabled") + } else { + slog.Debug("instance targets publishing has been disabled") + } + h.instancesPublishingActive = instancesPublishingRequested + // send message to all instances + for instance := range h.instancesPublishing { + h.updateClient(ctx, instance) + } + } + h.updateClient(ctx, client) + case instance := <-h.instanceCh: + instance.LastUpdated = time.Now().UnixMilli() + h.instances[instance.Hostname] = instance + h.updateInstances(ctx) + case client := <-h.unregisterCh: + delete(h.clients, client) + for _, topic := range h.topics { + delete(topic.clients, client) + } + case <-stopCh: + // let all clients know + for client := range h.clients { + client.close() + } + timeout := time.NewTicker(5 * time.Second) + for { + select { + case client := <-h.unregisterCh: + delete(h.clients, client) + case <-timeout.C: + level.Error(h.logger).Log("msg", "timeout waiting for clients to disconnect", "clients", fmt.Sprintf("%+#v", h.clients)) + return + } + + if len(h.clients) == 0 { + return + } + } + case f := <-h.rulesCh: + f(h) + t, ok := h.topics[topicRules] + if !ok { + continue + } + t.get(ctx, &h.buf) + // update all clients + for client := range t.clients { + h.updateClient(ctx, client) + } + } + } +} + +func (h *hub) updateRulesPayload(ctx context.Context, p *settingsv1.CollectionPayloadData) error { + rules, err := h.store.list(ctx) + if err != nil { + return fmt.Errorf("error reading rules from store: %w", err) + } + if cap(p.Rules) < len(rules) { + p.Rules = make([]*settingsv1.CollectionRule, 0, len(rules)) + } else { + p.Rules = p.Rules[:0] + } + for _, r := range rules { + p.Rules = append(p.Rules, r.CloneVT()) + } + return nil +} + +func (h *hub) updateInstancesPayload(ctx context.Context, p *settingsv1.CollectionPayloadData) error { + h.lck.RLock() + defer h.lck.RUnlock() + + if cap(p.Instances) < len(h.instances) { + p.Instances = make([]*settingsv1.CollectionInstance, 0, len(h.instances)) + } else { + p.Instances = p.Instances[:0] + } + for _, a := range h.instances { + p.Instances = append(p.Instances, a.CloneVT()) + } + return nil +} + +func mergePayloads(in ...*settingsv1.CollectionPayloadData) *settingsv1.CollectionPayloadData { + var lenRules, lenInstances int + for _, x := range in { + lenRules += len(x.Rules) + lenInstances += len(x.Instances) + } + + res := &settingsv1.CollectionPayloadData{ + Rules: make([]*settingsv1.CollectionRule, 0, lenRules), + Instances: make([]*settingsv1.CollectionInstance, 0, lenInstances), + } + + for _, x := range in { + res.Rules = append(res.Rules, x.Rules...) + res.Instances = append(res.Instances, x.Instances...) + } + return res +} diff --git a/pkg/settings/collection/rules.go b/pkg/settings/collection/rules.go new file mode 100644 index 0000000000..978fe47414 --- /dev/null +++ b/pkg/settings/collection/rules.go @@ -0,0 +1,79 @@ +package collection + +import ( + "fmt" + "strings" + "unsafe" + + jsoniter "github.com/json-iterator/go" + "github.com/prometheus/prometheus/model/relabel" + "gopkg.in/yaml.v3" + + settingsv1 "github.com/grafana/pyroscope/api/gen/proto/go/settings/v1" +) + +func init() { + jsoniter.RegisterTypeEncoder("settingsv1.CollectionRuleAction", actionCodec{}) +} + +type actionCodec struct{} + +func (actionCodec) IsEmpty(ptr unsafe.Pointer) bool { + // handle action (which is a protobuf enum) as string and as the decoder expects it + return *(*settingsv1.CollectionRuleAction)(ptr) == 0 +} + +func (actionCodec) Encode(ptr unsafe.Pointer, stream *jsoniter.Stream) { + action := (*settingsv1.CollectionRuleAction)(ptr).String() + action = strings.TrimPrefix(action, "COLLECTION_RULE_ACTION_") + action = strings.ToLower(action) + stream.WriteString(action) +} + +func collectionRuleToRelabelConfig(in *settingsv1.CollectionRule, out *relabel.Config) error { + bytes, err := jsoniter.Marshal(in) + if err != nil { + return err + } + err = yaml.Unmarshal(bytes, out) + if err != nil { + return err + } + return err +} + +func CollectionRuleToRelabelConfig(in *settingsv1.CollectionRule) (*relabel.Config, error) { + var out relabel.Config + if err := collectionRuleToRelabelConfig(in, &out); err != nil { + return nil, err + } + return &out, nil +} + +func ValidateCollectionRule(rule *settingsv1.CollectionRule) error { + out, err := CollectionRuleToRelabelConfig(rule) + if err != nil { + return err + } + return out.Validate() +} + +func CollectionRulesToRelabelConfigs(rules []*settingsv1.CollectionRule) ([]*relabel.Config, error) { + if len(rules) == 0 { + return nil, nil + } + + configs := make([]relabel.Config, len(rules)) + result := make([]*relabel.Config, len(rules)) + for idx := range rules { + if err := collectionRuleToRelabelConfig(rules[idx], &configs[idx]); err != nil { + return nil, fmt.Errorf("error validating rule %d: %w", idx, err) + } + if err := configs[idx].Validate(); err != nil { + return nil, fmt.Errorf("error validating rule %d: %w", idx, err) + } + result[idx] = &configs[idx] + } + + return result, nil +} diff --git a/pkg/settings/collection/store.go b/pkg/settings/collection/store.go new file mode 100644 index 0000000000..fa497f72d8 --- /dev/null +++ b/pkg/settings/collection/store.go @@ -0,0 +1,164 @@ +package collection + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "sync" + "time" + + "github.com/thanos-io/objstore" + + settingsv1 "github.com/grafana/pyroscope/api/gen/proto/go/settings/v1" +) + +// write through cache for the bucket +type bucketStore struct { + bucket objstore.Bucket + key hubKey + path string + + cacheLock sync.RWMutex + cache *settingsv1.CollectionRuleStore +} + +func newBucketStore(bucket objstore.Bucket, key hubKey) *bucketStore { + return &bucketStore{ + bucket: bucket, + key: key, + path: key.path() + ".json", + } +} + +// unsafeLoad reads from bucket into the cache, only call with write lock held +func (b *bucketStore) unsafeLoad(ctx context.Context) error { + // fetch from bucket + r, err := b.bucket.Get(ctx, b.path) + if b.bucket.IsObjNotFoundErr(err) { + b.cache = &settingsv1.CollectionRuleStore{} + return nil + } else if err != nil { + return err + } + + // unmarshal the data + var data settingsv1.CollectionRuleStore + if err := json.NewDecoder(r).Decode(&data); err != nil { + return err + } + b.cache = &data + + return nil +} + +// unsafeFlush writes from cache into the bucket, only call with write lock held +func (b *bucketStore) unsafeFlush(ctx context.Context) error { + // update last modified time + b.cache.LastUpdated = time.Now().UnixMilli() + + // marshal the data + data, err := json.Marshal(b.cache) + if err != nil { + return err + } + + return b.bucket.Upload(ctx, b.path, bytes.NewReader(data)) +} + +func (b *bucketStore) insertRule(ctx context.Context, rule *settingsv1.CollectionPayloadRuleInsert) error { + // get write lock and fetch from bucket + b.cacheLock.Lock() + defer b.cacheLock.Unlock() + + // ensure we have the latest data + if err := b.unsafeLoad(ctx); err != nil { + return err + } + + var ( + nextId int64 = 1 // what id should the rule get + position = -1 // where should the rule be inserted + ) + // iterate over the rules to find next id + for idx, r := range b.cache.Rules { + if r.Id >= nextId { + nextId = r.Id + 1 + } + + // mark correct position + if rule.After != nil && r.Id == *rule.After { + position = idx + } + } + + if rule.After == nil { + position = 0 + } + + if position == -1 && rule.After != nil { + return fmt.Errorf("no rule with id %d found to insert after", *rule.After) + } + + // set the id + r := rule.Rule.CloneVT() + r.Id = nextId + + // insert the rule + b.cache.Rules = append(b.cache.Rules, nil) + copy(b.cache.Rules[position+1:], b.cache.Rules[position:]) + b.cache.Rules[position] = r + + // save the ruleset + return b.unsafeFlush(ctx) +} + +func (b *bucketStore) deleteRule(ctx context.Context, id int64) error { + // get write lock and fetch from bucket + b.cacheLock.Lock() + defer b.cacheLock.Unlock() + + // ensure we have the latest data + if err := b.unsafeLoad(ctx); err != nil { + return err + } + + // iterate over the rules to find the rule + for idx, r := range b.cache.Rules { + if r.Id == id { + // delete the rule + b.cache.Rules = append(b.cache.Rules[:idx], b.cache.Rules[idx+1:]...) + + // save the ruleset + return b.unsafeFlush(ctx) + } + } + return fmt.Errorf("no rule with id %d found", id) + +} + +func (b *bucketStore) list(ctx context.Context) ([]*settingsv1.CollectionRule, error) { + // serve from cache if available + b.cacheLock.RLock() + if b.cache != nil { + defer b.cacheLock.RUnlock() + return b.cache.Rules, nil + } + b.cacheLock.RUnlock() + + // get write lock and fetch from bucket + b.cacheLock.Lock() + defer b.cacheLock.Unlock() + + // check again if cache is available in the meantime + if b.cache != nil { + return b.cache.Rules, nil + } + + // load from bucket + if err := b.unsafeLoad(ctx); err != nil { + return nil, err + } + + return b.cache.Rules, nil +} diff --git a/pkg/settings/collection/websocket.go b/pkg/settings/collection/websocket.go new file mode 100644 index 0000000000..9177057085 --- /dev/null +++ b/pkg/settings/collection/websocket.go @@ -0,0 +1,182 @@ +package collection + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "net" + "sync" + + "github.com/go-kit/log" + "github.com/go-kit/log/level" + "github.com/gorilla/websocket" + + settingsv1 "github.com/grafana/pyroscope/api/gen/proto/go/settings/v1" +) + +// client is a middleman between the websocket connection and the hub. +type client struct { + hub *hub + logger log.Logger + + // The websocket connection. + conn *websocket.Conn + + role Role + + subscribedTopics []string + subscribedTopicsMtx sync.Mutex + + // Buffered channel of outbound messages. + send chan []byte + sendClose sync.Once +} + +func (c *client) close() { + c.sendClose.Do(func() { + close(c.send) + }) +} + +func (c *client) SubscribedTopics() []string { + c.subscribedTopicsMtx.Lock() + defer c.subscribedTopicsMtx.Unlock() + return c.subscribedTopics +} + +func (c *client) isRuleManager() bool { + return c.role&RuleManager == RuleManager +} + +// readPump pumps messages from the websocket connection to the hub. +// +// The application runs readPump in a per-connection goroutine. The application +// ensures that there is at most one reader on a connection by executing all +// reads from this goroutine. +func (c *client) readPump() { + defer func() { + c.hub.unregisterCh <- c + c.close() + c.conn.Close() + }() + var ( + msg settingsv1.CollectionMessage + ) + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + for { + msg.Reset() + if err := c.conn.ReadJSON(&msg); err != nil { + if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure) { + level.Warn(c.logger).Log("msg", "websocket abnormal", "error", err) + } else if errors.Is(err, net.ErrClosed) { + level.Debug(c.logger).Log("msg", "websocket underlying connection closed", "error", err) + } else { + level.Error(c.logger).Log("msg", "error reading json", "error", err) + } + break + } + + handleResult := func(messageID int64, err error) { + if messageID == 0 { + return + } + msg := &settingsv1.CollectionMessage{ + Id: messageID, + Status: settingsv1.Status_STATUS_OK, + } + if err != nil { + level.Error(c.logger).Log("error", err) + msg.Status = settingsv1.Status_STATUS_ERROR + errDetail := err.Error() + msg.Message = &errDetail + } + d, _ := json.Marshal(msg) + c.send <- d + } + + if p := msg.PayloadSubscribe; p != nil { + c.subscribedTopicsMtx.Lock() + c.subscribedTopics = make([]string, len(p.Topics)) + copy(c.subscribedTopics, p.Topics) + c.subscribedTopicsMtx.Unlock() + + level.Debug(c.logger).Log("msg", "client subscribing", "topics", fmt.Sprintf("%v", p.Topics)) + c.hub.registerCh <- c + } else if p := msg.PayloadData; p != nil { + + for idx := range p.Instances { + i := p.Instances[idx] + level.Debug(c.logger).Log("msg", "received collection instance targets", "hostname", i.Hostname, "targets", len(i.Targets)) + c.hub.instanceCh <- i + } + } else if p := msg.PayloadRuleDelete; p != nil { + if p.Id <= 0 { + level.Warn(c.logger).Log("msg", "received rule delete without id") + continue + } + if !c.isRuleManager() { + level.Warn(c.logger).Log("msg", "not allowed for collection instance") + continue + } + level.Info(c.logger).Log("msg", "received rule delete", "id", p.Id) + ruleID := p.Id + msgID := msg.Id + c.hub.rulesCh <- func(h *hub) { + handleResult(msgID, h.deleteRule(ctx, ruleID)) + } + } else if p := msg.PayloadRuleInsert; p != nil { + if !c.isRuleManager() { + level.Warn(c.logger).Log("msg", "not allowed without rule manager role") + continue + } + level.Info(c.logger).Log("msg", "received rule insert", "rule", p.Rule) + id := msg.Id + settings := p.CloneVT() + c.hub.rulesCh <- func(h *hub) { + handleResult(id, h.insertRule(ctx, settings)) + } + } else { + level.Warn(c.logger).Log("msg", "no known message type used") + } + } +} + +// writePump pumps messages from the hub to the websocket connection. +// +// A goroutine running writePump is started for each connection. The +// application ensures that there is at most one writer to a connection by +// executing all writes from this goroutine. +func (c *client) writePump() { + defer func() { + c.conn.Close() + }() + for message := range c.send { + + w, err := c.conn.NextWriter(websocket.TextMessage) + if err != nil { + level.Warn(c.logger).Log("msg", "failed creating writer for client", "error", err) + return + } + messageLen, err := w.Write(message) + if len(message) > 64 { + message = append(message[:64], []byte("...")...) + } + if err != nil { + level.Warn(c.logger).Log("msg", "failed writing message to client", "error", err) + return + } + + if err := w.Close(); err != nil { + level.Warn(c.logger).Log("msg", "failed closing message to client", "error", err) + return + } + level.Debug(c.logger).Log("msg", "sent message to client", "size", messageLen, "message", message) + } + + // The hub closed the channel. + _ = c.conn.WriteMessage(websocket.CloseMessage, []byte{}) +} diff --git a/pkg/settings/setting_test.go b/pkg/settings/setting_test.go index 58bf0d7a72..bdf53f423a 100644 --- a/pkg/settings/setting_test.go +++ b/pkg/settings/setting_test.go @@ -263,8 +263,8 @@ func TestTenantSettings_Set(t *testing.T) { func newTestTenantSettings(t *testing.T, initial map[string][]*settingsv1.Setting) (*TenantSettings, func()) { t.Helper() - store, err := NewMemoryStore() - require.NoError(t, err) + store := newMemoryStore() + var err error for tenant, settings := range initial { for _, setting := range settings { diff --git a/pkg/settings/settings.go b/pkg/settings/settings.go index be4c700b14..29134cd9fe 100644 --- a/pkg/settings/settings.go +++ b/pkg/settings/settings.go @@ -3,6 +3,7 @@ package settings import ( "context" "fmt" + "net/http" "time" "connectrpc.com/connect" @@ -11,14 +12,22 @@ import ( "github.com/grafana/dskit/services" "github.com/grafana/dskit/tenant" "github.com/pkg/errors" + "github.com/thanos-io/objstore" settingsv1 "github.com/grafana/pyroscope/api/gen/proto/go/settings/v1" + "github.com/grafana/pyroscope/pkg/settings/collection" ) -func New(store Store, logger log.Logger) (*TenantSettings, error) { +func New(bucket objstore.Bucket, logger log.Logger) (*TenantSettings, error) { + if bucket == nil { + bucket = objstore.NewInMemBucket() + level.Warn(logger).Log("msg", "using in-memory settings store, changes will be lost after shutdown") + } + ts := &TenantSettings{ - store: store, - logger: logger, + store: newBucketStore(bucket), + logger: logger, + collection: collection.New(collection.Config{}, bucket, logger), } ts.Service = services.NewBasicService(ts.starting, ts.running, ts.stopping) @@ -29,14 +38,20 @@ func New(store Store, logger log.Logger) (*TenantSettings, error) { type TenantSettings struct { services.Service - store Store + store store logger log.Logger + + collection *collection.Collection } func (ts *TenantSettings) starting(ctx context.Context) error { return nil } +func (ts *TenantSettings) HandleCollectionSettings(role collection.Role) http.Handler { + return ts.collection.HandleSettings(role) +} + func (ts *TenantSettings) running(ctx context.Context) error { ticker := time.NewTicker(24 * time.Hour) done := false @@ -64,6 +79,8 @@ func (ts *TenantSettings) stopping(_ error) error { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() + ts.collection.Stop(ctx) + err := ts.store.Flush(ctx) if err != nil { return err diff --git a/pkg/settings/store.go b/pkg/settings/store.go index 1c24291436..ea2f6a94d6 100644 --- a/pkg/settings/store.go +++ b/pkg/settings/store.go @@ -6,7 +6,7 @@ import ( settingsv1 "github.com/grafana/pyroscope/api/gen/proto/go/settings/v1" ) -type Store interface { +type store interface { // Get settings for a tenant. Get(ctx context.Context, tenantID string) ([]*settingsv1.Setting, error)