From 3e75afb8918d4cfebe7b569b315164c3c94c446b Mon Sep 17 00:00:00 2001 From: Christian Simon Date: Wed, 26 Jun 2024 10:36:44 +0100 Subject: [PATCH 01/10] Add model for collection rules --- api/buf.yaml | 1 + api/gen/proto/go/settings/v1/setting.pb.go | 1014 ++++- .../go/settings/v1/setting_vtproto.pb.go | 3359 +++++++++++++++-- api/settings/v1/setting.proto | 92 + 4 files changed, 3988 insertions(+), 478 deletions(-) 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..047ed48558 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,95 @@ 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 GetSettingsRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -262,55 +352,727 @@ 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 +} + +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[6] + 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[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 CollectionTarget.ProtoReflect.Descriptor instead. +func (*CollectionTarget) Descriptor() ([]byte, []int) { + return file_settings_v1_setting_proto_rawDescGZIP(), []int{6} +} + +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"` +} + +func (x *CollectionInstance) Reset() { + *x = CollectionInstance{} + if protoimpl.UnsafeEnabled { + mi := &file_settings_v1_setting_proto_msgTypes[7] + 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[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 CollectionInstance.ProtoReflect.Descriptor instead. +func (*CollectionInstance) Descriptor() ([]byte, []int) { + return file_settings_v1_setting_proto_rawDescGZIP(), []int{7} +} + +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 + + // TODO: Status, ID + // + // Types that are assignable to Payload: + // + // *CollectionMessage_PayloadSubscribe + // *CollectionMessage_PayloadUnsubscribe + // *CollectionMessage_PayloadData + // *CollectionMessage_PayloadRuleInsert + // *CollectionMessage_PayloadRuleDelete + Payload isCollectionMessage_Payload `protobuf_oneof:"payload"` +} + +func (x *CollectionMessage) Reset() { + *x = CollectionMessage{} + if protoimpl.UnsafeEnabled { + mi := &file_settings_v1_setting_proto_msgTypes[8] + 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[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 CollectionMessage.ProtoReflect.Descriptor instead. +func (*CollectionMessage) Descriptor() ([]byte, []int) { + return file_settings_v1_setting_proto_rawDescGZIP(), []int{8} +} + +func (m *CollectionMessage) GetPayload() isCollectionMessage_Payload { + if m != nil { + return m.Payload + } + return nil +} + +func (x *CollectionMessage) GetPayloadSubscribe() *CollectionPayloadSubscribe { + if x, ok := x.GetPayload().(*CollectionMessage_PayloadSubscribe); ok { + return x.PayloadSubscribe + } + return nil +} + +func (x *CollectionMessage) GetPayloadUnsubscribe() *CollectionPayloadSubscribe { + if x, ok := x.GetPayload().(*CollectionMessage_PayloadUnsubscribe); ok { + return x.PayloadUnsubscribe + } + return nil +} + +func (x *CollectionMessage) GetPayloadData() *CollectionPayloadData { + if x, ok := x.GetPayload().(*CollectionMessage_PayloadData); ok { + return x.PayloadData + } + return nil +} + +func (x *CollectionMessage) GetPayloadRuleInsert() *CollectionPayloadRuleInsert { + if x, ok := x.GetPayload().(*CollectionMessage_PayloadRuleInsert); ok { + return x.PayloadRuleInsert + } + return nil +} + +func (x *CollectionMessage) GetPayloadRuleDelete() *CollectionPayloadRuleDelete { + if x, ok := x.GetPayload().(*CollectionMessage_PayloadRuleDelete); ok { + return x.PayloadRuleDelete + } + return nil +} + +type isCollectionMessage_Payload interface { + isCollectionMessage_Payload() +} + +type CollectionMessage_PayloadSubscribe struct { + PayloadSubscribe *CollectionPayloadSubscribe `protobuf:"bytes,1,opt,name=payload_subscribe,json=payloadSubscribe,proto3,oneof"` +} + +type CollectionMessage_PayloadUnsubscribe struct { + PayloadUnsubscribe *CollectionPayloadSubscribe `protobuf:"bytes,2,opt,name=payload_unsubscribe,json=payloadUnsubscribe,proto3,oneof"` +} + +type CollectionMessage_PayloadData struct { + PayloadData *CollectionPayloadData `protobuf:"bytes,3,opt,name=payload_data,json=payloadData,proto3,oneof"` +} + +type CollectionMessage_PayloadRuleInsert struct { + PayloadRuleInsert *CollectionPayloadRuleInsert `protobuf:"bytes,4,opt,name=payload_rule_insert,json=payloadRuleInsert,proto3,oneof"` +} + +type CollectionMessage_PayloadRuleDelete struct { + PayloadRuleDelete *CollectionPayloadRuleDelete `protobuf:"bytes,5,opt,name=payload_rule_delete,json=payloadRuleDelete,proto3,oneof"` +} + +func (*CollectionMessage_PayloadSubscribe) isCollectionMessage_Payload() {} + +func (*CollectionMessage_PayloadUnsubscribe) isCollectionMessage_Payload() {} + +func (*CollectionMessage_PayloadData) isCollectionMessage_Payload() {} + +func (*CollectionMessage_PayloadRuleInsert) isCollectionMessage_Payload() {} + +func (*CollectionMessage_PayloadRuleDelete) isCollectionMessage_Payload() {} + +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[9] + 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[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 CollectionPayloadSubscribe.ProtoReflect.Descriptor instead. +func (*CollectionPayloadSubscribe) Descriptor() ([]byte, []int) { + return file_settings_v1_setting_proto_rawDescGZIP(), []int{9} +} + +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[10] + 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[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 CollectionPayloadData.ProtoReflect.Descriptor instead. +func (*CollectionPayloadData) Descriptor() ([]byte, []int) { + return file_settings_v1_setting_proto_rawDescGZIP(), []int{10} +} + +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[11] + 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[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 CollectionPayloadRuleInsert.ProtoReflect.Descriptor instead. +func (*CollectionPayloadRuleInsert) Descriptor() ([]byte, []int) { + return file_settings_v1_setting_proto_rawDescGZIP(), []int{11} +} + +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[12] + 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[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 CollectionPayloadRuleDelete.ProtoReflect.Descriptor instead. +func (*CollectionPayloadRuleDelete) Descriptor() ([]byte, []int) { + return file_settings_v1_setting_proto_rawDescGZIP(), []int{12} +} + +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, + 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, 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, 0xd3, 0x03, 0x0a, 0x11, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x56, 0x0a, 0x11, 0x70, 0x61, 0x79, + 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x18, 0x01, + 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, 0x48, 0x00, 0x52, + 0x10, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, + 0x65, 0x12, 0x5a, 0x0a, 0x13, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x75, 0x6e, 0x73, + 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x18, 0x02, 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, 0x48, 0x00, 0x52, 0x12, 0x70, 0x61, 0x79, 0x6c, 0x6f, + 0x61, 0x64, 0x55, 0x6e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, 0x47, 0x0a, + 0x0c, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 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, 0x48, 0x00, 0x52, 0x0b, 0x70, 0x61, 0x79, 0x6c, 0x6f, + 0x61, 0x64, 0x44, 0x61, 0x74, 0x61, 0x12, 0x5a, 0x0a, 0x13, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, + 0x64, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x5f, 0x69, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x18, 0x04, 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, 0x48, 0x00, 0x52, + 0x11, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x75, 0x6c, 0x65, 0x49, 0x6e, 0x73, 0x65, + 0x72, 0x74, 0x12, 0x5a, 0x0a, 0x13, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x72, 0x75, + 0x6c, 0x65, 0x5f, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x18, 0x05, 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, 0x48, 0x00, 0x52, 0x11, 0x70, 0x61, 0x79, + 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x75, 0x6c, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x09, + 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 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, 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, - 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, + 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 +1087,49 @@ 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, 1) +var file_settings_v1_setting_proto_msgTypes = make([]protoimpl.MessageInfo, 13) 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 + (*GetSettingsRequest)(nil), // 1: settings.v1.GetSettingsRequest + (*GetSettingsResponse)(nil), // 2: settings.v1.GetSettingsResponse + (*SetSettingsRequest)(nil), // 3: settings.v1.SetSettingsRequest + (*SetSettingsResponse)(nil), // 4: settings.v1.SetSettingsResponse + (*Setting)(nil), // 5: settings.v1.Setting + (*CollectionRule)(nil), // 6: settings.v1.CollectionRule + (*CollectionTarget)(nil), // 7: settings.v1.CollectionTarget + (*CollectionInstance)(nil), // 8: settings.v1.CollectionInstance + (*CollectionMessage)(nil), // 9: settings.v1.CollectionMessage + (*CollectionPayloadSubscribe)(nil), // 10: settings.v1.CollectionPayloadSubscribe + (*CollectionPayloadData)(nil), // 11: settings.v1.CollectionPayloadData + (*CollectionPayloadRuleInsert)(nil), // 12: settings.v1.CollectionPayloadRuleInsert + (*CollectionPayloadRuleDelete)(nil), // 13: settings.v1.CollectionPayloadRuleDelete + (*v1.LabelPair)(nil), // 14: 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 + 5, // 0: settings.v1.GetSettingsResponse.settings:type_name -> settings.v1.Setting + 5, // 1: settings.v1.SetSettingsRequest.setting:type_name -> settings.v1.Setting + 5, // 2: settings.v1.SetSettingsResponse.setting:type_name -> settings.v1.Setting + 0, // 3: settings.v1.CollectionRule.action:type_name -> settings.v1.CollectionRuleAction + 14, // 4: settings.v1.CollectionTarget.labels:type_name -> types.v1.LabelPair + 7, // 5: settings.v1.CollectionInstance.targets:type_name -> settings.v1.CollectionTarget + 10, // 6: settings.v1.CollectionMessage.payload_subscribe:type_name -> settings.v1.CollectionPayloadSubscribe + 10, // 7: settings.v1.CollectionMessage.payload_unsubscribe:type_name -> settings.v1.CollectionPayloadSubscribe + 11, // 8: settings.v1.CollectionMessage.payload_data:type_name -> settings.v1.CollectionPayloadData + 12, // 9: settings.v1.CollectionMessage.payload_rule_insert:type_name -> settings.v1.CollectionPayloadRuleInsert + 13, // 10: settings.v1.CollectionMessage.payload_rule_delete:type_name -> settings.v1.CollectionPayloadRuleDelete + 6, // 11: settings.v1.CollectionPayloadData.rules:type_name -> settings.v1.CollectionRule + 8, // 12: settings.v1.CollectionPayloadData.instances:type_name -> settings.v1.CollectionInstance + 6, // 13: settings.v1.CollectionPayloadRuleInsert.rule:type_name -> settings.v1.CollectionRule + 1, // 14: settings.v1.SettingsService.Get:input_type -> settings.v1.GetSettingsRequest + 3, // 15: settings.v1.SettingsService.Set:input_type -> settings.v1.SetSettingsRequest + 2, // 16: settings.v1.SettingsService.Get:output_type -> settings.v1.GetSettingsResponse + 4, // 17: settings.v1.SettingsService.Set:output_type -> settings.v1.SetSettingsResponse + 16, // [16:18] is the sub-list for method output_type + 14, // [14:16] is the sub-list for method input_type + 14, // [14:14] is the sub-list for extension type_name + 14, // [14:14] is the sub-list for extension extendee + 0, // [0:14] is the sub-list for field type_name } func init() { file_settings_v1_setting_proto_init() } @@ -414,19 +1198,125 @@ 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.(*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[7].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[8].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[9].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[10].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[11].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[12].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[8].OneofWrappers = []any{ + (*CollectionMessage_PayloadSubscribe)(nil), + (*CollectionMessage_PayloadUnsubscribe)(nil), + (*CollectionMessage_PayloadData)(nil), + (*CollectionMessage_PayloadRuleInsert)(nil), + (*CollectionMessage_PayloadRuleDelete)(nil), } + file_settings_v1_setting_proto_msgTypes[11].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: 1, + NumMessages: 13, 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..1ab2ba8432 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,256 @@ 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 *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) + if m.Payload != nil { + r.Payload = m.Payload.(interface { + CloneVT() isCollectionMessage_Payload + }).CloneVT() + } + 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 *CollectionMessage_PayloadSubscribe) CloneVT() isCollectionMessage_Payload { + if m == nil { + return (*CollectionMessage_PayloadSubscribe)(nil) + } + r := new(CollectionMessage_PayloadSubscribe) + r.PayloadSubscribe = m.PayloadSubscribe.CloneVT() + return r +} + +func (m *CollectionMessage_PayloadUnsubscribe) CloneVT() isCollectionMessage_Payload { + if m == nil { + return (*CollectionMessage_PayloadUnsubscribe)(nil) + } + r := new(CollectionMessage_PayloadUnsubscribe) + r.PayloadUnsubscribe = m.PayloadUnsubscribe.CloneVT() + return r +} + +func (m *CollectionMessage_PayloadData) CloneVT() isCollectionMessage_Payload { + if m == nil { + return (*CollectionMessage_PayloadData)(nil) + } + r := new(CollectionMessage_PayloadData) + r.PayloadData = m.PayloadData.CloneVT() + return r +} + +func (m *CollectionMessage_PayloadRuleInsert) CloneVT() isCollectionMessage_Payload { + if m == nil { + return (*CollectionMessage_PayloadRuleInsert)(nil) + } + r := new(CollectionMessage_PayloadRuleInsert) + r.PayloadRuleInsert = m.PayloadRuleInsert.CloneVT() + return r +} + +func (m *CollectionMessage_PayloadRuleDelete) CloneVT() isCollectionMessage_Payload { + if m == nil { + return (*CollectionMessage_PayloadRuleDelete)(nil) + } + r := new(CollectionMessage_PayloadRuleDelete) + r.PayloadRuleDelete = m.PayloadRuleDelete.CloneVT() + return r +} + +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,299 +478,526 @@ 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 (this *CollectionRule) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*CollectionRule) + if !ok { + return false + } + return this.EqualVT(that) } - -func (m *GetSettingsRequest) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil +func (this *CollectionTarget) EqualVT(that *CollectionTarget) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err + if len(this.Labels) != len(that.Labels) { + return false } - return dAtA[:n], nil + 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 + } + } + } + return string(this.unknownFields) == string(that.unknownFields) } -func (m *GetSettingsRequest) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) +func (this *CollectionTarget) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*CollectionTarget) + if !ok { + return false + } + return this.EqualVT(that) } - -func (m *GetSettingsRequest) 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 } - return len(dAtA) - i, nil + 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 + } + } + } + if this.LastUpdated != that.LastUpdated { + return false + } + return string(this.unknownFields) == string(that.unknownFields) } -func (m *GetSettingsResponse) 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.Payload == nil && that.Payload != nil { + return false + } else if this.Payload != nil { + if that.Payload == nil { + return false + } + if !this.Payload.(interface { + EqualVT(isCollectionMessage_Payload) bool + }).EqualVT(that.Payload) { + return false + } + } + 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 *CollectionMessage) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*CollectionMessage) + if !ok { + return false + } + return this.EqualVT(that) } - -func (m *GetSettingsResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil +func (this *CollectionMessage_PayloadSubscribe) EqualVT(thatIface isCollectionMessage_Payload) bool { + that, ok := thatIface.(*CollectionMessage_PayloadSubscribe) + if !ok { + 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 == that { + return true } - 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 + if this == nil && that != nil || this != nil && that == nil { + return false + } + if p, q := this.PayloadSubscribe, that.PayloadSubscribe; p != q { + if p == nil { + p = &CollectionPayloadSubscribe{} + } + if q == nil { + q = &CollectionPayloadSubscribe{} + } + if !p.EqualVT(q) { + return false } } - return len(dAtA) - i, nil + return true } -func (m *SetSettingsRequest) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil +func (this *CollectionMessage_PayloadUnsubscribe) EqualVT(thatIface isCollectionMessage_Payload) bool { + that, ok := thatIface.(*CollectionMessage_PayloadUnsubscribe) + if !ok { + return false } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err + if this == that { + return true } - return dAtA[:n], nil -} - -func (m *SetSettingsRequest) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) + if this == nil && that != nil || this != nil && that == nil { + return false + } + if p, q := this.PayloadUnsubscribe, that.PayloadUnsubscribe; p != q { + if p == nil { + p = &CollectionPayloadSubscribe{} + } + if q == nil { + q = &CollectionPayloadSubscribe{} + } + if !p.EqualVT(q) { + return false + } + } + return true } -func (m *SetSettingsRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil +func (this *CollectionMessage_PayloadData) EqualVT(thatIface isCollectionMessage_Payload) bool { + that, ok := thatIface.(*CollectionMessage_PayloadData) + if !ok { + 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 == that { + return true } - if m.Setting != nil { - size, err := m.Setting.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err + if this == nil && that != nil || this != nil && that == nil { + return false + } + if p, q := this.PayloadData, that.PayloadData; p != q { + if p == nil { + p = &CollectionPayloadData{} + } + if q == nil { + q = &CollectionPayloadData{} + } + if !p.EqualVT(q) { + return false } - i -= size - i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) - i-- - dAtA[i] = 0xa } - return len(dAtA) - i, nil + return true } -func (m *SetSettingsResponse) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil +func (this *CollectionMessage_PayloadRuleInsert) EqualVT(thatIface isCollectionMessage_Payload) bool { + that, ok := thatIface.(*CollectionMessage_PayloadRuleInsert) + if !ok { + return false } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err + if this == that { + return true } - return dAtA[:n], nil + if this == nil && that != nil || this != nil && that == nil { + return false + } + if p, q := this.PayloadRuleInsert, that.PayloadRuleInsert; p != q { + if p == nil { + p = &CollectionPayloadRuleInsert{} + } + if q == nil { + q = &CollectionPayloadRuleInsert{} + } + if !p.EqualVT(q) { + return false + } + } + return true } -func (m *SetSettingsResponse) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) +func (this *CollectionMessage_PayloadRuleDelete) EqualVT(thatIface isCollectionMessage_Payload) bool { + that, ok := thatIface.(*CollectionMessage_PayloadRuleDelete) + if !ok { + return false + } + if this == that { + return true + } + if this == nil && that != nil || this != nil && that == nil { + return false + } + if p, q := this.PayloadRuleDelete, that.PayloadRuleDelete; p != q { + if p == nil { + p = &CollectionPayloadRuleDelete{} + } + if q == nil { + q = &CollectionPayloadRuleDelete{} + } + if !p.EqualVT(q) { + return false + } + } + return true } -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) { +func (this *CollectionPayloadSubscribe) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*CollectionPayloadSubscribe) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *CollectionPayloadData) EqualVT(that *CollectionPayloadData) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if len(this.Rules) != len(that.Rules) { + return false + } + 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(this.Instances) != len(that.Instances) { + return false + } + 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 string(this.unknownFields) == string(that.unknownFields) +} + +func (this *CollectionPayloadData) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*CollectionPayloadData) + if !ok { + return false + } + 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 (this *CollectionPayloadRuleInsert) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*CollectionPayloadRuleInsert) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *CollectionPayloadRuleDelete) EqualVT(that *CollectionPayloadRuleDelete) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Id != that.Id { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *CollectionPayloadRuleDelete) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*CollectionPayloadRuleDelete) + if !ok { + return false + } + return this.EqualVT(that) +} + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// 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 + } + 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 + } + 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 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 _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 interceptor == nil { + return srv.(SettingsServiceServer).Set(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/settings.v1.SettingsService/Set", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SettingsServiceServer).Set(ctx, req.(*SetSettingsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// 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 } @@ -532,12 +1010,12 @@ func (m *Setting) MarshalVT() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *Setting) MarshalToVT(dAtA []byte) (int, error) { +func (m *GetSettingsRequest) MarshalToVT(dAtA []byte) (int, error) { size := m.SizeVT() return m.MarshalToSizedBufferVT(dAtA[:size]) } -func (m *Setting) MarshalToSizedBufferVT(dAtA []byte) (int, error) { +func (m *GetSettingsRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { if m == nil { return 0, nil } @@ -549,186 +1027,2157 @@ func (m *Setting) MarshalToSizedBufferVT(dAtA []byte) (int, error) { 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 *GetSettingsRequest) SizeVT() (n int) { +func (m *GetSettingsResponse) MarshalVT() (dAtA []byte, err error) { if m == nil { - return 0 + return nil, nil } - var l int - _ = l - n += len(m.unknownFields) - return n + 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) SizeVT() (n int) { +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 + return 0, nil } + i := len(dAtA) + _ = i var l int _ = l - if len(m.Settings) > 0 { - for _, e := range m.Settings { - l = e.SizeVT() - n += 1 + l + protohelpers.SizeOfVarint(uint64(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 } } - n += len(m.unknownFields) - return n + return len(dAtA) - i, nil } -func (m *SetSettingsRequest) SizeVT() (n int) { +func (m *SetSettingsRequest) MarshalVT() (dAtA []byte, err error) { if m == nil { - return 0 + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *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 { - l = m.Setting.SizeVT() - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + 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 } - n += len(m.unknownFields) - return n + return len(dAtA) - i, nil } -func (m *SetSettingsResponse) SizeVT() (n int) { +func (m *SetSettingsResponse) MarshalVT() (dAtA []byte, err error) { if m == nil { - return 0 + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *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 { - l = m.Setting.SizeVT() - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + 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 } - n += len(m.unknownFields) - return n + return len(dAtA) - i, nil } -func (m *Setting) SizeVT() (n int) { +func (m *Setting) MarshalVT() (dAtA []byte, err error) { if m == nil { - return 0 + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *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 - 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.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) } if m.ModifiedAt != 0 { - n += 1 + protohelpers.SizeOfVarint(uint64(m.ModifiedAt)) + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.ModifiedAt)) + i-- + dAtA[i] = 0x18 } - n += len(m.unknownFields) - return n + 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 *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 +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 *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))) } - if iNdEx >= l { + 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 vtmsg, ok := m.Payload.(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + } + return len(dAtA) - i, nil +} + +func (m *CollectionMessage_PayloadSubscribe) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CollectionMessage_PayloadSubscribe) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + i := len(dAtA) + 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] = 0xa + } + return len(dAtA) - i, nil +} +func (m *CollectionMessage_PayloadUnsubscribe) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CollectionMessage_PayloadUnsubscribe) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + i := len(dAtA) + if m.PayloadUnsubscribe != nil { + size, err := m.PayloadUnsubscribe.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} +func (m *CollectionMessage_PayloadData) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CollectionMessage_PayloadData) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + i := len(dAtA) + 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] = 0x1a + } + return len(dAtA) - i, nil +} +func (m *CollectionMessage_PayloadRuleInsert) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CollectionMessage_PayloadRuleInsert) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + i := len(dAtA) + 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] = 0x22 + } + return len(dAtA) - i, nil +} +func (m *CollectionMessage_PayloadRuleDelete) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CollectionMessage_PayloadRuleDelete) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + i := len(dAtA) + 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] = 0x2a + } + 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 *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 vtmsg, ok := m.Payload.(interface{ SizeVT() int }); ok { + n += vtmsg.SizeVT() + } + n += len(m.unknownFields) + return n +} + +func (m *CollectionMessage_PayloadSubscribe) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PayloadSubscribe != nil { + l = m.PayloadSubscribe.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + return n +} +func (m *CollectionMessage_PayloadUnsubscribe) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PayloadUnsubscribe != nil { + l = m.PayloadUnsubscribe.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + return n +} +func (m *CollectionMessage_PayloadData) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PayloadData != nil { + l = m.PayloadData.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + return n +} +func (m *CollectionMessage_PayloadRuleInsert) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PayloadRuleInsert != nil { + l = m.PayloadRuleInsert.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + return n +} +func (m *CollectionMessage_PayloadRuleDelete) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PayloadRuleDelete != nil { + l = m.PayloadRuleDelete.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + 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 *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 != 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 + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if oneof, ok := m.Payload.(*CollectionMessage_PayloadSubscribe); ok { + if err := oneof.PayloadSubscribe.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + v := &CollectionPayloadSubscribe{} + if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Payload = &CollectionMessage_PayloadSubscribe{PayloadSubscribe: v} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PayloadUnsubscribe", 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 oneof, ok := m.Payload.(*CollectionMessage_PayloadUnsubscribe); ok { + if err := oneof.PayloadUnsubscribe.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + v := &CollectionPayloadSubscribe{} + if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Payload = &CollectionMessage_PayloadUnsubscribe{PayloadUnsubscribe: v} } - } - 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 + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PayloadData", wireType) } - if (skippy < 0) || (iNdEx+skippy) < 0 { + 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 oneof, ok := m.Payload.(*CollectionMessage_PayloadData); ok { + if err := oneof.PayloadData.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + v := &CollectionPayloadData{} + if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Payload = &CollectionMessage_PayloadData{PayloadData: v} } - if iNdEx >= l { + iNdEx = postIndex + case 4: + 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 oneof, ok := m.Payload.(*CollectionMessage_PayloadRuleInsert); ok { + if err := oneof.PayloadRuleInsert.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + v := &CollectionPayloadRuleInsert{} + if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Payload = &CollectionMessage_PayloadRuleInsert{PayloadRuleInsert: v} } - } - 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: + iNdEx = postIndex + case 5: 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,9 +3204,16 @@ 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 { - return err + if oneof, ok := m.Payload.(*CollectionMessage_PayloadRuleDelete); ok { + if err := oneof.PayloadRuleDelete.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + v := &CollectionPayloadRuleDelete{} + if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Payload = &CollectionMessage_PayloadRuleDelete{PayloadRuleDelete: v} } iNdEx = postIndex default: @@ -782,7 +3238,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 +3261,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 +3281,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 +3321,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 +3344,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 +3379,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 +3440,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 +3463,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 +3483,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 +3519,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 +3590,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/settings/v1/setting.proto b/api/settings/v1/setting.proto index fb7375bfb9..19d385fcf7 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,93 @@ 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; +} + +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; +} + +message CollectionMessage { + // TODO: Status, ID + oneof payload { + CollectionPayloadSubscribe payload_subscribe = 1; + CollectionPayloadSubscribe payload_unsubscribe = 2; + CollectionPayloadData payload_data = 3; + CollectionPayloadRuleInsert payload_rule_insert = 4; + CollectionPayloadRuleDelete payload_rule_delete = 5; + } +} + +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; +} From 471a6ef069bcb69670915236cc8887facffa525c Mon Sep 17 00:00:00 2001 From: Christian Simon Date: Wed, 26 Jun 2024 15:28:39 +0100 Subject: [PATCH 02/10] Integrate websocket code Originally from https://github.com/simonswine/grafana-agent-cnc * Use proto defined API * Add tenants and within a tenant scopes * Write tests --- go.mod | 1 + pkg/settings/collection/collection.go | 123 ++++++++++++++ pkg/settings/collection/collection_test.go | 134 +++++++++++++++ pkg/settings/collection/hub.go | 125 ++++++++++++++ pkg/settings/collection/websocket.go | 185 +++++++++++++++++++++ 5 files changed, 568 insertions(+) create mode 100644 pkg/settings/collection/collection.go create mode 100644 pkg/settings/collection/collection_test.go create mode 100644 pkg/settings/collection/hub.go create mode 100644 pkg/settings/collection/websocket.go 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/settings/collection/collection.go b/pkg/settings/collection/collection.go new file mode 100644 index 0000000000..a94b9a4f60 --- /dev/null +++ b/pkg/settings/collection/collection.go @@ -0,0 +1,123 @@ +package collection + +import ( + "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" + settingsv1 "github.com/grafana/pyroscope/api/gen/proto/go/settings/v1" +) + +type Config struct { +} + +// 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 + logger log.Logger + wg sync.WaitGroup + + lck sync.RWMutex + Rules []settingsv1.CollectionRule + + upgrader websocket.Upgrader + hubs map[hubKey]*Hub +} + +func New(cfg Config, logger log.Logger) *Collection { + return &Collection{ + cfg: cfg, + 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), + } +} + +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) +) + +// serveWs handles websocket requests from the peer. +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(c.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") + + // Allow collection of memory referenced by the caller by doing all work in + // new goroutines. + go client.writePump() + go client.readPump() +} + +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 = &Hub{} + 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..275761db50 --- /dev/null +++ b/pkg/settings/collection/collection_test.go @@ -0,0 +1,134 @@ +package collection + +import ( + "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" + + settingsv1 "github.com/grafana/pyroscope/api/gen/proto/go/settings/v1" +) + +var ( + payloadSubscribeRules = []byte(`{"Payload":{"PayloadSubscribe":{"topics":["rules"]}}}`) +) + +func ruleMsg(rule settingsv1.CollectionRule, after int64) *settingsv1.CollectionMessage { + var afterPtr *int64 + if after != 0 { + afterPtr = &after + } + return &settingsv1.CollectionMessage{ + Payload: &settingsv1.CollectionMessage_PayloadRuleInsert{ + PayloadRuleInsert: &settingsv1.CollectionPayloadRuleInsert{ + Rule: &rule, + After: afterPtr, + }, + }, + } +} + +func stringPtr(s string) *string { + return &s +} + +func TestCollection_TwoCollectionInstances_OneRuleManager(t *testing.T) { + // Setup code here + var logger = log.NewNopLogger() + if testing.Verbose() { + logger = log.NewLogfmtLogger(os.Stderr) + } + c := New(Config{}, logger) + + // Create test server with the echo handler. + mux := http.NewServeMux() + mux.HandleFunc("/collection", func(w http.ResponseWriter, r *http.Request) { + c.handleWS(w, r, RuleReceiver) + }) + mux.HandleFunc("/manager", func(w http.ResponseWriter, r *http.Request) { + c.handleWS(w, r, 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) + + // 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))) + + // drop everything else + require.NoError(t, ruleManager.WriteJSON(ruleMsg( + settingsv1.CollectionRule{ + Action: settingsv1.CollectionRuleAction_COLLECTION_RULE_ACTION_DROP, + }, 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() + + h.lck.RLock() + defer h.lck.RUnlock() + + return len(h.rules) == 2 + }, 50*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) + + // TODO: Add some rules to the collection + + 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 := collection2.ReadJSON(&msg) + require.NoError(t, err) + + if p, ok := msg.GetPayload().(*settingsv1.CollectionMessage_PayloadData); ok { + // validate rules + assert.Equal(t, 2, len(p.PayloadData.Rules), "expect two 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..680271ef14 --- /dev/null +++ b/pkg/settings/collection/hub.go @@ -0,0 +1,125 @@ +package collection + +import ( + "sync" + + "github.com/cespare/xxhash/v2" + 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() ([]byte, error) + err error + content []byte + hasher xxhash.Digest + hash uint64 + clients map[*Client]uint64 +} + +func newTopic(name string, f func() ([]byte, error)) *topic { + return &topic{ + name: name, + ch: make(chan struct{}), + update: f, + hash: 0, + clients: make(map[*Client]uint64), + } +} + +func (t *topic) get() { + t.content, t.err = t.update() + if t.err != nil { + return + } + + t.hasher.Reset() + _, t.err = t.hasher.Write(t.content) + if t.err != nil { + return + } + t.hash = t.hasher.Sum64() +} + +type hubKey struct { + tenantID string + scope string +} + +type Hub struct { + lck sync.RWMutex + nextRuleID int64 + rules []*settingsv1.CollectionRule + + app *Collection + + topics map[string]*topic + + agentsPublishing map[*Client]bool // are particular grafana agents publishing their targets + agentsPublishingActive bool // is agent publishing requested + agents map[string]*settingsv1.CollectionInstance + + // Register requests from the clients. + registerCh chan *Client + + // Unregister requests from clients. + unregisterCh chan *Client + + // Update agent targets + agentCh chan *settingsv1.CollectionInstance + + // Update rules + rulesCh chan func(*Hub) +} + +func (a *Hub) insertRule(data *settingsv1.CollectionPayloadRuleInsert) { + a.lck.Lock() + defer a.lck.Unlock() + + if a.nextRuleID == 0 { + for _, r := range a.rules { + if r.Id > a.nextRuleID { + a.nextRuleID = r.Id + } + } + a.nextRuleID++ + } + + pos := 0 + // find position to insert + if data.After != nil { + after := *data.After + for i, r := range a.rules { + if r.Id == after { + pos = i + 1 + break + } + } + } + + // overwrite id + rule := data.Rule.CloneVT() + rule.Id = a.nextRuleID + a.nextRuleID++ + + // insert rule to correct position + a.rules = append(a.rules, nil) + copy(a.rules[pos+1:], a.rules[pos:]) + a.rules[pos] = rule + +} + +func (h *Hub) deleteRule(id int64) { + h.lck.Lock() + defer h.lck.Unlock() + + for i, r := range h.rules { + if r.Id == id { + h.rules = append(h.rules[:i], h.rules[i+1:]...) + break + } + } +} diff --git a/pkg/settings/collection/websocket.go b/pkg/settings/collection/websocket.go new file mode 100644 index 0000000000..b09a35b9b3 --- /dev/null +++ b/pkg/settings/collection/websocket.go @@ -0,0 +1,185 @@ +package collection + +import ( + "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" +) + +var ( + newline = []byte{'\n'} +) + +// 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 + + // Buffered channel of outbound messages. + send chan []byte +} + +type recvMsg = settingsv1.CollectionMessage + +/* +type recvMsg struct { + Type model.MessageType `json:"type"` + Data *model.PayloadData + Subscribe *model.PayloadSubscribe + RuleDelete *model.PayloadRuleDelete + RuleInsert *model.PayloadRuleInsert +} + +func (m *recvMsg) UnmarshalJSON(b []byte) error { + var header struct { + Type model.MessageType `json:"type"` + Payload json.RawMessage `json:"payload"` + } + json.Unmarshal(b, &header) + m.Type = header.Type + m.Data = nil + m.Subscribe = nil + + switch m.Type { + case model.MessageTypeData: + var data model.PayloadData + if err := json.Unmarshal(header.Payload, &data); err != nil { + return err + } + m.Data = &data + case model.MessageTypeSubscribe: + var subscribe model.PayloadSubscribe + if err := json.Unmarshal(header.Payload, &subscribe); err != nil { + return err + } + m.Subscribe = &subscribe + case model.MessageTypeRuleInsert: + var e model.PayloadRuleInsert + if err := json.Unmarshal(header.Payload, &e); err != nil { + return err + } + m.RuleInsert = &e + case model.MessageTypeRuleDelete: + var e model.PayloadRuleDelete + if err := json.Unmarshal(header.Payload, &e); err != nil { + return err + } + m.RuleDelete = &e + default: + return fmt.Errorf("unknown message type %s", m.Type) + } + return nil +} +*/ + +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.conn.Close() + }() + var ( + msg settingsv1.CollectionMessage + ) + + for { + if err := c.conn.ReadJSON(&msg); err != nil { + if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure) { + level.Error(c.logger).Log("msg", "error reading json", "error", err) + } + break + } + + switch p := msg.Payload.(type) { + case *settingsv1.CollectionMessage_PayloadSubscribe: + + c.subscribedTopics = p.PayloadSubscribe.Topics + level.Debug(c.logger).Log("msg", "client subscribing", "topics", p.PayloadSubscribe.Topics) + c.hub.registerCh <- c + case *settingsv1.CollectionMessage_PayloadData: + for idx := range p.PayloadData.Instances { + a := p.PayloadData.Instances[idx] + level.Debug(c.logger).Log("msg", "received collection instance targets", "hostname", a.Hostname, "targets", len(a.Targets)) + c.hub.agentCh <- a + } + case *settingsv1.CollectionMessage_PayloadRuleDelete: + if p.PayloadRuleDelete.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.Debug(c.logger).Log("msg", "received rule delete", "id", p.PayloadRuleDelete.Id) + id := p.PayloadRuleDelete.Id + c.hub.rulesCh <- func(h *Hub) { + h.deleteRule(id) + } + case *settingsv1.CollectionMessage_PayloadRuleInsert: + if !c.isRuleManager() { + level.Warn(c.logger).Log("msg", "not allowed without rule manager role") + continue + } + level.Debug(c.logger).Log("msg", "received rule insert", "rule", p.PayloadRuleInsert.Rule) + c.hub.rulesCh <- func(h *Hub) { + h.insertRule(p.PayloadRuleInsert) + } + + default: + level.Warn(c.logger).Log("msg", "unknown message type", "type", msg.Payload) + } + } +} + +// 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 { + select { + case message, ok := <-c.send: + if !ok { + // The hub closed the channel. + c.conn.WriteMessage(websocket.CloseMessage, []byte{}) + return + } + + w, err := c.conn.NextWriter(websocket.TextMessage) + if err != nil { + return + } + messageLen, _ := w.Write(message) + if len(message) > 64 { + message = append(message[:64], []byte("...")...) + } + level.Debug(c.logger).Log("msg", "sent message to client", "size", messageLen, "message", message) + + if err := w.Close(); err != nil { + return + } + } + } +} From 521518383d8853a3ba0e87d76c02e18c46ac8335 Mon Sep 17 00:00:00 2001 From: Christian Simon Date: Thu, 27 Jun 2024 09:00:41 +0100 Subject: [PATCH 03/10] Get rid of oneOf from model --- api/gen/proto/go/settings/v1/setting.pb.go | 267 +++++------- .../go/settings/v1/setting_vtproto.pb.go | 397 +++--------------- api/settings/v1/setting.proto | 2 - 3 files changed, 161 insertions(+), 505 deletions(-) diff --git a/api/gen/proto/go/settings/v1/setting.pb.go b/api/gen/proto/go/settings/v1/setting.pb.go index 047ed48558..f03dcd10b6 100644 --- a/api/gen/proto/go/settings/v1/setting.pb.go +++ b/api/gen/proto/go/settings/v1/setting.pb.go @@ -583,15 +583,11 @@ type CollectionMessage struct { unknownFields protoimpl.UnknownFields // TODO: Status, ID - // - // Types that are assignable to Payload: - // - // *CollectionMessage_PayloadSubscribe - // *CollectionMessage_PayloadUnsubscribe - // *CollectionMessage_PayloadData - // *CollectionMessage_PayloadRuleInsert - // *CollectionMessage_PayloadRuleDelete - Payload isCollectionMessage_Payload `protobuf_oneof:"payload"` + PayloadSubscribe *CollectionPayloadSubscribe `protobuf:"bytes,1,opt,name=payload_subscribe,json=payloadSubscribe,proto3" json:"payload_subscribe,omitempty"` + PayloadUnsubscribe *CollectionPayloadSubscribe `protobuf:"bytes,2,opt,name=payload_unsubscribe,json=payloadUnsubscribe,proto3" json:"payload_unsubscribe,omitempty"` + PayloadData *CollectionPayloadData `protobuf:"bytes,3,opt,name=payload_data,json=payloadData,proto3" json:"payload_data,omitempty"` + PayloadRuleInsert *CollectionPayloadRuleInsert `protobuf:"bytes,4,opt,name=payload_rule_insert,json=payloadRuleInsert,proto3" json:"payload_rule_insert,omitempty"` + PayloadRuleDelete *CollectionPayloadRuleDelete `protobuf:"bytes,5,opt,name=payload_rule_delete,json=payloadRuleDelete,proto3" json:"payload_rule_delete,omitempty"` } func (x *CollectionMessage) Reset() { @@ -626,82 +622,41 @@ func (*CollectionMessage) Descriptor() ([]byte, []int) { return file_settings_v1_setting_proto_rawDescGZIP(), []int{8} } -func (m *CollectionMessage) GetPayload() isCollectionMessage_Payload { - if m != nil { - return m.Payload - } - return nil -} - func (x *CollectionMessage) GetPayloadSubscribe() *CollectionPayloadSubscribe { - if x, ok := x.GetPayload().(*CollectionMessage_PayloadSubscribe); ok { + if x != nil { return x.PayloadSubscribe } return nil } func (x *CollectionMessage) GetPayloadUnsubscribe() *CollectionPayloadSubscribe { - if x, ok := x.GetPayload().(*CollectionMessage_PayloadUnsubscribe); ok { + if x != nil { return x.PayloadUnsubscribe } return nil } func (x *CollectionMessage) GetPayloadData() *CollectionPayloadData { - if x, ok := x.GetPayload().(*CollectionMessage_PayloadData); ok { + if x != nil { return x.PayloadData } return nil } func (x *CollectionMessage) GetPayloadRuleInsert() *CollectionPayloadRuleInsert { - if x, ok := x.GetPayload().(*CollectionMessage_PayloadRuleInsert); ok { + if x != nil { return x.PayloadRuleInsert } return nil } func (x *CollectionMessage) GetPayloadRuleDelete() *CollectionPayloadRuleDelete { - if x, ok := x.GetPayload().(*CollectionMessage_PayloadRuleDelete); ok { + if x != nil { return x.PayloadRuleDelete } return nil } -type isCollectionMessage_Payload interface { - isCollectionMessage_Payload() -} - -type CollectionMessage_PayloadSubscribe struct { - PayloadSubscribe *CollectionPayloadSubscribe `protobuf:"bytes,1,opt,name=payload_subscribe,json=payloadSubscribe,proto3,oneof"` -} - -type CollectionMessage_PayloadUnsubscribe struct { - PayloadUnsubscribe *CollectionPayloadSubscribe `protobuf:"bytes,2,opt,name=payload_unsubscribe,json=payloadUnsubscribe,proto3,oneof"` -} - -type CollectionMessage_PayloadData struct { - PayloadData *CollectionPayloadData `protobuf:"bytes,3,opt,name=payload_data,json=payloadData,proto3,oneof"` -} - -type CollectionMessage_PayloadRuleInsert struct { - PayloadRuleInsert *CollectionPayloadRuleInsert `protobuf:"bytes,4,opt,name=payload_rule_insert,json=payloadRuleInsert,proto3,oneof"` -} - -type CollectionMessage_PayloadRuleDelete struct { - PayloadRuleDelete *CollectionPayloadRuleDelete `protobuf:"bytes,5,opt,name=payload_rule_delete,json=payloadRuleDelete,proto3,oneof"` -} - -func (*CollectionMessage_PayloadSubscribe) isCollectionMessage_Payload() {} - -func (*CollectionMessage_PayloadUnsubscribe) isCollectionMessage_Payload() {} - -func (*CollectionMessage_PayloadData) isCollectionMessage_Payload() {} - -func (*CollectionMessage_PayloadRuleInsert) isCollectionMessage_Payload() {} - -func (*CollectionMessage_PayloadRuleDelete) isCollectionMessage_Payload() {} - type CollectionPayloadSubscribe struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -969,110 +924,109 @@ var file_settings_v1_setting_proto_rawDesc = []byte{ 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, 0xd3, 0x03, 0x0a, 0x11, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x56, 0x0a, 0x11, 0x70, 0x61, 0x79, + 0x74, 0x65, 0x64, 0x22, 0xbe, 0x03, 0x0a, 0x11, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x54, 0x0a, 0x11, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x18, 0x01, 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, 0x48, 0x00, 0x52, - 0x10, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, - 0x65, 0x12, 0x5a, 0x0a, 0x13, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x75, 0x6e, 0x73, - 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x18, 0x02, 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, 0x48, 0x00, 0x52, 0x12, 0x70, 0x61, 0x79, 0x6c, 0x6f, - 0x61, 0x64, 0x55, 0x6e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, 0x47, 0x0a, - 0x0c, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 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, 0x48, 0x00, 0x52, 0x0b, 0x70, 0x61, 0x79, 0x6c, 0x6f, - 0x61, 0x64, 0x44, 0x61, 0x74, 0x61, 0x12, 0x5a, 0x0a, 0x13, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, - 0x64, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x5f, 0x69, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x18, 0x04, 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, 0x48, 0x00, 0x52, - 0x11, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x75, 0x6c, 0x65, 0x49, 0x6e, 0x73, 0x65, - 0x72, 0x74, 0x12, 0x5a, 0x0a, 0x13, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x72, 0x75, - 0x6c, 0x65, 0x5f, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x18, 0x05, 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, 0x48, 0x00, 0x52, 0x11, 0x70, 0x61, 0x79, - 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x75, 0x6c, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x09, - 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 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, + 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, + 0x58, 0x0a, 0x13, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x75, 0x6e, 0x73, 0x75, 0x62, + 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x18, 0x02, 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, 0x12, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x55, 0x6e, + 0x73, 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, 0x03, 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, 0x04, 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, 0x05, 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, 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, - 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, + 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, 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, + 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, 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, 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, + 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, + 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 ( @@ -1296,13 +1250,6 @@ func file_settings_v1_setting_proto_init() { } } file_settings_v1_setting_proto_msgTypes[5].OneofWrappers = []any{} - file_settings_v1_setting_proto_msgTypes[8].OneofWrappers = []any{ - (*CollectionMessage_PayloadSubscribe)(nil), - (*CollectionMessage_PayloadUnsubscribe)(nil), - (*CollectionMessage_PayloadData)(nil), - (*CollectionMessage_PayloadRuleInsert)(nil), - (*CollectionMessage_PayloadRuleDelete)(nil), - } file_settings_v1_setting_proto_msgTypes[11].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ 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 1ab2ba8432..25a1b977a8 100644 --- a/api/gen/proto/go/settings/v1/setting_vtproto.pb.go +++ b/api/gen/proto/go/settings/v1/setting_vtproto.pb.go @@ -216,11 +216,11 @@ func (m *CollectionMessage) CloneVT() *CollectionMessage { return (*CollectionMessage)(nil) } r := new(CollectionMessage) - if m.Payload != nil { - r.Payload = m.Payload.(interface { - CloneVT() isCollectionMessage_Payload - }).CloneVT() - } + r.PayloadSubscribe = m.PayloadSubscribe.CloneVT() + r.PayloadUnsubscribe = m.PayloadUnsubscribe.CloneVT() + r.PayloadData = m.PayloadData.CloneVT() + r.PayloadRuleInsert = m.PayloadRuleInsert.CloneVT() + r.PayloadRuleDelete = m.PayloadRuleDelete.CloneVT() if len(m.unknownFields) > 0 { r.unknownFields = make([]byte, len(m.unknownFields)) copy(r.unknownFields, m.unknownFields) @@ -232,51 +232,6 @@ func (m *CollectionMessage) CloneMessageVT() proto.Message { return m.CloneVT() } -func (m *CollectionMessage_PayloadSubscribe) CloneVT() isCollectionMessage_Payload { - if m == nil { - return (*CollectionMessage_PayloadSubscribe)(nil) - } - r := new(CollectionMessage_PayloadSubscribe) - r.PayloadSubscribe = m.PayloadSubscribe.CloneVT() - return r -} - -func (m *CollectionMessage_PayloadUnsubscribe) CloneVT() isCollectionMessage_Payload { - if m == nil { - return (*CollectionMessage_PayloadUnsubscribe)(nil) - } - r := new(CollectionMessage_PayloadUnsubscribe) - r.PayloadUnsubscribe = m.PayloadUnsubscribe.CloneVT() - return r -} - -func (m *CollectionMessage_PayloadData) CloneVT() isCollectionMessage_Payload { - if m == nil { - return (*CollectionMessage_PayloadData)(nil) - } - r := new(CollectionMessage_PayloadData) - r.PayloadData = m.PayloadData.CloneVT() - return r -} - -func (m *CollectionMessage_PayloadRuleInsert) CloneVT() isCollectionMessage_Payload { - if m == nil { - return (*CollectionMessage_PayloadRuleInsert)(nil) - } - r := new(CollectionMessage_PayloadRuleInsert) - r.PayloadRuleInsert = m.PayloadRuleInsert.CloneVT() - return r -} - -func (m *CollectionMessage_PayloadRuleDelete) CloneVT() isCollectionMessage_Payload { - if m == nil { - return (*CollectionMessage_PayloadRuleDelete)(nil) - } - r := new(CollectionMessage_PayloadRuleDelete) - r.PayloadRuleDelete = m.PayloadRuleDelete.CloneVT() - return r -} - func (m *CollectionPayloadSubscribe) CloneVT() *CollectionPayloadSubscribe { if m == nil { return (*CollectionPayloadSubscribe)(nil) @@ -606,153 +561,31 @@ func (this *CollectionMessage) EqualVT(that *CollectionMessage) bool { } else if this == nil || that == nil { return false } - if this.Payload == nil && that.Payload != nil { - return false - } else if this.Payload != nil { - if that.Payload == nil { - return false - } - if !this.Payload.(interface { - EqualVT(isCollectionMessage_Payload) bool - }).EqualVT(that.Payload) { - return false - } - } - return string(this.unknownFields) == string(that.unknownFields) -} - -func (this *CollectionMessage) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*CollectionMessage) - if !ok { - return false - } - return this.EqualVT(that) -} -func (this *CollectionMessage_PayloadSubscribe) EqualVT(thatIface isCollectionMessage_Payload) bool { - that, ok := thatIface.(*CollectionMessage_PayloadSubscribe) - if !ok { - return false - } - if this == that { - return true - } - if this == nil && that != nil || this != nil && that == nil { - return false - } - if p, q := this.PayloadSubscribe, that.PayloadSubscribe; p != q { - if p == nil { - p = &CollectionPayloadSubscribe{} - } - if q == nil { - q = &CollectionPayloadSubscribe{} - } - if !p.EqualVT(q) { - return false - } - } - return true -} - -func (this *CollectionMessage_PayloadUnsubscribe) EqualVT(thatIface isCollectionMessage_Payload) bool { - that, ok := thatIface.(*CollectionMessage_PayloadUnsubscribe) - if !ok { - return false - } - if this == that { - return true - } - if this == nil && that != nil || this != nil && that == nil { + if !this.PayloadSubscribe.EqualVT(that.PayloadSubscribe) { return false } - if p, q := this.PayloadUnsubscribe, that.PayloadUnsubscribe; p != q { - if p == nil { - p = &CollectionPayloadSubscribe{} - } - if q == nil { - q = &CollectionPayloadSubscribe{} - } - if !p.EqualVT(q) { - return false - } - } - return true -} - -func (this *CollectionMessage_PayloadData) EqualVT(thatIface isCollectionMessage_Payload) bool { - that, ok := thatIface.(*CollectionMessage_PayloadData) - if !ok { + if !this.PayloadUnsubscribe.EqualVT(that.PayloadUnsubscribe) { return false } - if this == that { - return true - } - if this == nil && that != nil || this != nil && that == nil { + if !this.PayloadData.EqualVT(that.PayloadData) { return false } - if p, q := this.PayloadData, that.PayloadData; p != q { - if p == nil { - p = &CollectionPayloadData{} - } - if q == nil { - q = &CollectionPayloadData{} - } - if !p.EqualVT(q) { - return false - } - } - return true -} - -func (this *CollectionMessage_PayloadRuleInsert) EqualVT(thatIface isCollectionMessage_Payload) bool { - that, ok := thatIface.(*CollectionMessage_PayloadRuleInsert) - if !ok { + if !this.PayloadRuleInsert.EqualVT(that.PayloadRuleInsert) { return false } - if this == that { - return true - } - if this == nil && that != nil || this != nil && that == nil { + if !this.PayloadRuleDelete.EqualVT(that.PayloadRuleDelete) { return false } - if p, q := this.PayloadRuleInsert, that.PayloadRuleInsert; p != q { - if p == nil { - p = &CollectionPayloadRuleInsert{} - } - if q == nil { - q = &CollectionPayloadRuleInsert{} - } - if !p.EqualVT(q) { - return false - } - } - return true + return string(this.unknownFields) == string(that.unknownFields) } -func (this *CollectionMessage_PayloadRuleDelete) EqualVT(thatIface isCollectionMessage_Payload) bool { - that, ok := thatIface.(*CollectionMessage_PayloadRuleDelete) +func (this *CollectionMessage) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*CollectionMessage) if !ok { return false } - if this == that { - return true - } - if this == nil && that != nil || this != nil && that == nil { - return false - } - if p, q := this.PayloadRuleDelete, that.PayloadRuleDelete; p != q { - if p == nil { - p = &CollectionPayloadRuleDelete{} - } - if q == nil { - q = &CollectionPayloadRuleDelete{} - } - if !p.EqualVT(q) { - return false - } - } - return true + return this.EqualVT(that) } - func (this *CollectionPayloadSubscribe) EqualVT(that *CollectionPayloadSubscribe) bool { if this == that { return true @@ -1442,63 +1275,26 @@ func (m *CollectionMessage) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i -= len(m.unknownFields) copy(dAtA[i:], m.unknownFields) } - if vtmsg, ok := m.Payload.(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - } - return len(dAtA) - i, nil -} - -func (m *CollectionMessage_PayloadSubscribe) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *CollectionMessage_PayloadSubscribe) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - i := len(dAtA) - if m.PayloadSubscribe != nil { - size, err := m.PayloadSubscribe.MarshalToSizedBufferVT(dAtA[:i]) + 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] = 0xa + dAtA[i] = 0x2a } - return len(dAtA) - i, nil -} -func (m *CollectionMessage_PayloadUnsubscribe) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *CollectionMessage_PayloadUnsubscribe) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - i := len(dAtA) - if m.PayloadUnsubscribe != nil { - size, err := m.PayloadUnsubscribe.MarshalToSizedBufferVT(dAtA[:i]) + 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] = 0x12 + dAtA[i] = 0x22 } - return len(dAtA) - i, nil -} -func (m *CollectionMessage_PayloadData) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *CollectionMessage_PayloadData) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - i := len(dAtA) if m.PayloadData != nil { size, err := m.PayloadData.MarshalToSizedBufferVT(dAtA[:i]) if err != nil { @@ -1509,46 +1305,29 @@ func (m *CollectionMessage_PayloadData) MarshalToSizedBufferVT(dAtA []byte) (int i-- dAtA[i] = 0x1a } - return len(dAtA) - i, nil -} -func (m *CollectionMessage_PayloadRuleInsert) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *CollectionMessage_PayloadRuleInsert) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - i := len(dAtA) - if m.PayloadRuleInsert != nil { - size, err := m.PayloadRuleInsert.MarshalToSizedBufferVT(dAtA[:i]) + if m.PayloadUnsubscribe != nil { + size, err := m.PayloadUnsubscribe.MarshalToSizedBufferVT(dAtA[:i]) if err != nil { return 0, err } i -= size i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x12 } - return len(dAtA) - i, nil -} -func (m *CollectionMessage_PayloadRuleDelete) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *CollectionMessage_PayloadRuleDelete) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - i := len(dAtA) - if m.PayloadRuleDelete != nil { - size, err := m.PayloadRuleDelete.MarshalToSizedBufferVT(dAtA[:i]) + 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] = 0x2a + dAtA[i] = 0xa } return len(dAtA) - i, nil } + func (m *CollectionPayloadSubscribe) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil @@ -1896,19 +1675,6 @@ func (m *CollectionInstance) SizeVT() (n int) { } func (m *CollectionMessage) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if vtmsg, ok := m.Payload.(interface{ SizeVT() int }); ok { - n += vtmsg.SizeVT() - } - n += len(m.unknownFields) - return n -} - -func (m *CollectionMessage_PayloadSubscribe) SizeVT() (n int) { if m == nil { return 0 } @@ -1918,56 +1684,26 @@ func (m *CollectionMessage_PayloadSubscribe) SizeVT() (n int) { l = m.PayloadSubscribe.SizeVT() n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) } - return n -} -func (m *CollectionMessage_PayloadUnsubscribe) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l if m.PayloadUnsubscribe != nil { l = m.PayloadUnsubscribe.SizeVT() n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) } - return n -} -func (m *CollectionMessage_PayloadData) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l if m.PayloadData != nil { l = m.PayloadData.SizeVT() n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) } - return n -} -func (m *CollectionMessage_PayloadRuleInsert) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l if m.PayloadRuleInsert != nil { l = m.PayloadRuleInsert.SizeVT() n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) } - return n -} -func (m *CollectionMessage_PayloadRuleDelete) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = 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 @@ -3040,16 +2776,11 @@ func (m *CollectionMessage) UnmarshalVT(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if oneof, ok := m.Payload.(*CollectionMessage_PayloadSubscribe); ok { - if err := oneof.PayloadSubscribe.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - v := &CollectionPayloadSubscribe{} - if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Payload = &CollectionMessage_PayloadSubscribe{PayloadSubscribe: v} + if m.PayloadSubscribe == nil { + m.PayloadSubscribe = &CollectionPayloadSubscribe{} + } + if err := m.PayloadSubscribe.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 2: @@ -3081,16 +2812,11 @@ func (m *CollectionMessage) UnmarshalVT(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if oneof, ok := m.Payload.(*CollectionMessage_PayloadUnsubscribe); ok { - if err := oneof.PayloadUnsubscribe.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - v := &CollectionPayloadSubscribe{} - if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Payload = &CollectionMessage_PayloadUnsubscribe{PayloadUnsubscribe: v} + if m.PayloadUnsubscribe == nil { + m.PayloadUnsubscribe = &CollectionPayloadSubscribe{} + } + if err := m.PayloadUnsubscribe.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 3: @@ -3122,16 +2848,11 @@ func (m *CollectionMessage) UnmarshalVT(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if oneof, ok := m.Payload.(*CollectionMessage_PayloadData); ok { - if err := oneof.PayloadData.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - v := &CollectionPayloadData{} - if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Payload = &CollectionMessage_PayloadData{PayloadData: v} + if m.PayloadData == nil { + m.PayloadData = &CollectionPayloadData{} + } + if err := m.PayloadData.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 4: @@ -3163,16 +2884,11 @@ func (m *CollectionMessage) UnmarshalVT(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if oneof, ok := m.Payload.(*CollectionMessage_PayloadRuleInsert); ok { - if err := oneof.PayloadRuleInsert.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - v := &CollectionPayloadRuleInsert{} - if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Payload = &CollectionMessage_PayloadRuleInsert{PayloadRuleInsert: v} + if m.PayloadRuleInsert == nil { + m.PayloadRuleInsert = &CollectionPayloadRuleInsert{} + } + if err := m.PayloadRuleInsert.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 5: @@ -3204,16 +2920,11 @@ func (m *CollectionMessage) UnmarshalVT(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if oneof, ok := m.Payload.(*CollectionMessage_PayloadRuleDelete); ok { - if err := oneof.PayloadRuleDelete.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - } else { - v := &CollectionPayloadRuleDelete{} - if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Payload = &CollectionMessage_PayloadRuleDelete{PayloadRuleDelete: v} + if m.PayloadRuleDelete == nil { + m.PayloadRuleDelete = &CollectionPayloadRuleDelete{} + } + if err := m.PayloadRuleDelete.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex default: diff --git a/api/settings/v1/setting.proto b/api/settings/v1/setting.proto index 19d385fcf7..ddee54e1a0 100644 --- a/api/settings/v1/setting.proto +++ b/api/settings/v1/setting.proto @@ -92,13 +92,11 @@ message CollectionInstance { message CollectionMessage { // TODO: Status, ID - oneof payload { CollectionPayloadSubscribe payload_subscribe = 1; CollectionPayloadSubscribe payload_unsubscribe = 2; CollectionPayloadData payload_data = 3; CollectionPayloadRuleInsert payload_rule_insert = 4; CollectionPayloadRuleDelete payload_rule_delete = 5; - } } message CollectionPayloadSubscribe { From 019583513c0d7efc7f5a7088d8c31c6c9c53832a Mon Sep 17 00:00:00 2001 From: Christian Simon Date: Thu, 27 Jun 2024 11:21:21 +0100 Subject: [PATCH 04/10] Add some more fields to message struct --- api/gen/proto/go/settings/v1/setting.pb.go | 357 +++++++++++------- .../go/settings/v1/setting_vtproto.pb.go | 135 +++++-- api/openapiv2/gen/phlare.swagger.json | 46 +-- api/settings/v1/setting.proto | 19 +- 4 files changed, 347 insertions(+), 210 deletions(-) diff --git a/api/gen/proto/go/settings/v1/setting.pb.go b/api/gen/proto/go/settings/v1/setting.pb.go index f03dcd10b6..6132a701df 100644 --- a/api/gen/proto/go/settings/v1/setting.pb.go +++ b/api/gen/proto/go/settings/v1/setting.pb.go @@ -110,6 +110,55 @@ 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 @@ -582,12 +631,13 @@ type CollectionMessage struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // TODO: Status, ID - PayloadSubscribe *CollectionPayloadSubscribe `protobuf:"bytes,1,opt,name=payload_subscribe,json=payloadSubscribe,proto3" json:"payload_subscribe,omitempty"` - PayloadUnsubscribe *CollectionPayloadSubscribe `protobuf:"bytes,2,opt,name=payload_unsubscribe,json=payloadUnsubscribe,proto3" json:"payload_unsubscribe,omitempty"` - PayloadData *CollectionPayloadData `protobuf:"bytes,3,opt,name=payload_data,json=payloadData,proto3" json:"payload_data,omitempty"` - PayloadRuleInsert *CollectionPayloadRuleInsert `protobuf:"bytes,4,opt,name=payload_rule_insert,json=payloadRuleInsert,proto3" json:"payload_rule_insert,omitempty"` - PayloadRuleDelete *CollectionPayloadRuleDelete `protobuf:"bytes,5,opt,name=payload_rule_delete,json=payloadRuleDelete,proto3" json:"payload_rule_delete,omitempty"` + 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() { @@ -622,16 +672,30 @@ func (*CollectionMessage) Descriptor() ([]byte, []int) { return file_settings_v1_setting_proto_rawDescGZIP(), []int{8} } -func (x *CollectionMessage) GetPayloadSubscribe() *CollectionPayloadSubscribe { +func (x *CollectionMessage) GetStatus() Status { if x != nil { - return x.PayloadSubscribe + return x.Status } - return nil + return Status_STATUS_UNSPECIFIED } -func (x *CollectionMessage) GetPayloadUnsubscribe() *CollectionPayloadSubscribe { +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.PayloadUnsubscribe + return x.Id + } + return 0 +} + +func (x *CollectionMessage) GetPayloadSubscribe() *CollectionPayloadSubscribe { + if x != nil { + return x.PayloadSubscribe } return nil } @@ -924,109 +988,114 @@ var file_settings_v1_setting_proto_rawDesc = []byte{ 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, 0xbe, 0x03, 0x0a, 0x11, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x54, 0x0a, 0x11, 0x70, 0x61, 0x79, - 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x18, 0x01, - 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, - 0x58, 0x0a, 0x13, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x75, 0x6e, 0x73, 0x75, 0x62, - 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x18, 0x02, 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, 0x12, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x55, 0x6e, - 0x73, 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, 0x03, 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, 0x04, 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, 0x05, 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, 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, + 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, - 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, + 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, 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, - 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, + 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, 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, + 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, 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, + 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 ( @@ -1041,44 +1110,45 @@ func file_settings_v1_setting_proto_rawDescGZIP() []byte { return file_settings_v1_setting_proto_rawDescData } -var file_settings_v1_setting_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_settings_v1_setting_proto_enumTypes = make([]protoimpl.EnumInfo, 2) var file_settings_v1_setting_proto_msgTypes = make([]protoimpl.MessageInfo, 13) var file_settings_v1_setting_proto_goTypes = []any{ (CollectionRuleAction)(0), // 0: settings.v1.CollectionRuleAction - (*GetSettingsRequest)(nil), // 1: settings.v1.GetSettingsRequest - (*GetSettingsResponse)(nil), // 2: settings.v1.GetSettingsResponse - (*SetSettingsRequest)(nil), // 3: settings.v1.SetSettingsRequest - (*SetSettingsResponse)(nil), // 4: settings.v1.SetSettingsResponse - (*Setting)(nil), // 5: settings.v1.Setting - (*CollectionRule)(nil), // 6: settings.v1.CollectionRule - (*CollectionTarget)(nil), // 7: settings.v1.CollectionTarget - (*CollectionInstance)(nil), // 8: settings.v1.CollectionInstance - (*CollectionMessage)(nil), // 9: settings.v1.CollectionMessage - (*CollectionPayloadSubscribe)(nil), // 10: settings.v1.CollectionPayloadSubscribe - (*CollectionPayloadData)(nil), // 11: settings.v1.CollectionPayloadData - (*CollectionPayloadRuleInsert)(nil), // 12: settings.v1.CollectionPayloadRuleInsert - (*CollectionPayloadRuleDelete)(nil), // 13: settings.v1.CollectionPayloadRuleDelete - (*v1.LabelPair)(nil), // 14: types.v1.LabelPair + (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 + (*CollectionTarget)(nil), // 8: settings.v1.CollectionTarget + (*CollectionInstance)(nil), // 9: settings.v1.CollectionInstance + (*CollectionMessage)(nil), // 10: settings.v1.CollectionMessage + (*CollectionPayloadSubscribe)(nil), // 11: settings.v1.CollectionPayloadSubscribe + (*CollectionPayloadData)(nil), // 12: settings.v1.CollectionPayloadData + (*CollectionPayloadRuleInsert)(nil), // 13: settings.v1.CollectionPayloadRuleInsert + (*CollectionPayloadRuleDelete)(nil), // 14: settings.v1.CollectionPayloadRuleDelete + (*v1.LabelPair)(nil), // 15: types.v1.LabelPair } var file_settings_v1_setting_proto_depIdxs = []int32{ - 5, // 0: settings.v1.GetSettingsResponse.settings:type_name -> settings.v1.Setting - 5, // 1: settings.v1.SetSettingsRequest.setting:type_name -> settings.v1.Setting - 5, // 2: settings.v1.SetSettingsResponse.setting:type_name -> settings.v1.Setting + 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 - 14, // 4: settings.v1.CollectionTarget.labels:type_name -> types.v1.LabelPair - 7, // 5: settings.v1.CollectionInstance.targets:type_name -> settings.v1.CollectionTarget - 10, // 6: settings.v1.CollectionMessage.payload_subscribe:type_name -> settings.v1.CollectionPayloadSubscribe - 10, // 7: settings.v1.CollectionMessage.payload_unsubscribe:type_name -> settings.v1.CollectionPayloadSubscribe - 11, // 8: settings.v1.CollectionMessage.payload_data:type_name -> settings.v1.CollectionPayloadData - 12, // 9: settings.v1.CollectionMessage.payload_rule_insert:type_name -> settings.v1.CollectionPayloadRuleInsert - 13, // 10: settings.v1.CollectionMessage.payload_rule_delete:type_name -> settings.v1.CollectionPayloadRuleDelete - 6, // 11: settings.v1.CollectionPayloadData.rules:type_name -> settings.v1.CollectionRule - 8, // 12: settings.v1.CollectionPayloadData.instances:type_name -> settings.v1.CollectionInstance - 6, // 13: settings.v1.CollectionPayloadRuleInsert.rule:type_name -> settings.v1.CollectionRule - 1, // 14: settings.v1.SettingsService.Get:input_type -> settings.v1.GetSettingsRequest - 3, // 15: settings.v1.SettingsService.Set:input_type -> settings.v1.SetSettingsRequest - 2, // 16: settings.v1.SettingsService.Get:output_type -> settings.v1.GetSettingsResponse - 4, // 17: settings.v1.SettingsService.Set:output_type -> settings.v1.SetSettingsResponse + 15, // 4: settings.v1.CollectionTarget.labels:type_name -> types.v1.LabelPair + 8, // 5: settings.v1.CollectionInstance.targets:type_name -> settings.v1.CollectionTarget + 1, // 6: settings.v1.CollectionMessage.status:type_name -> settings.v1.Status + 11, // 7: settings.v1.CollectionMessage.payload_subscribe:type_name -> settings.v1.CollectionPayloadSubscribe + 12, // 8: settings.v1.CollectionMessage.payload_data:type_name -> settings.v1.CollectionPayloadData + 13, // 9: settings.v1.CollectionMessage.payload_rule_insert:type_name -> settings.v1.CollectionPayloadRuleInsert + 14, // 10: settings.v1.CollectionMessage.payload_rule_delete:type_name -> settings.v1.CollectionPayloadRuleDelete + 7, // 11: settings.v1.CollectionPayloadData.rules:type_name -> settings.v1.CollectionRule + 9, // 12: settings.v1.CollectionPayloadData.instances:type_name -> settings.v1.CollectionInstance + 7, // 13: settings.v1.CollectionPayloadRuleInsert.rule:type_name -> settings.v1.CollectionRule + 2, // 14: settings.v1.SettingsService.Get:input_type -> settings.v1.GetSettingsRequest + 4, // 15: settings.v1.SettingsService.Set:input_type -> settings.v1.SetSettingsRequest + 3, // 16: settings.v1.SettingsService.Get:output_type -> settings.v1.GetSettingsResponse + 5, // 17: settings.v1.SettingsService.Set:output_type -> settings.v1.SetSettingsResponse 16, // [16:18] is the sub-list for method output_type 14, // [14:16] is the sub-list for method input_type 14, // [14:14] is the sub-list for extension type_name @@ -1250,13 +1320,14 @@ func file_settings_v1_setting_proto_init() { } } file_settings_v1_setting_proto_msgTypes[5].OneofWrappers = []any{} + file_settings_v1_setting_proto_msgTypes[8].OneofWrappers = []any{} file_settings_v1_setting_proto_msgTypes[11].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_settings_v1_setting_proto_rawDesc, - NumEnums: 1, + NumEnums: 2, NumMessages: 13, NumExtensions: 0, NumServices: 1, 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 25a1b977a8..4815dfc372 100644 --- a/api/gen/proto/go/settings/v1/setting_vtproto.pb.go +++ b/api/gen/proto/go/settings/v1/setting_vtproto.pb.go @@ -216,11 +216,16 @@ func (m *CollectionMessage) CloneVT() *CollectionMessage { return (*CollectionMessage)(nil) } r := new(CollectionMessage) + r.Status = m.Status + r.Id = m.Id r.PayloadSubscribe = m.PayloadSubscribe.CloneVT() - r.PayloadUnsubscribe = m.PayloadUnsubscribe.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) @@ -561,10 +566,16 @@ func (this *CollectionMessage) EqualVT(that *CollectionMessage) bool { } else if this == nil || that == nil { return false } - if !this.PayloadSubscribe.EqualVT(that.PayloadSubscribe) { + 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.PayloadUnsubscribe.EqualVT(that.PayloadUnsubscribe) { + if !this.PayloadSubscribe.EqualVT(that.PayloadSubscribe) { return false } if !this.PayloadData.EqualVT(that.PayloadData) { @@ -1283,7 +1294,7 @@ func (m *CollectionMessage) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i -= size i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) i-- - dAtA[i] = 0x2a + dAtA[i] = 0x3a } if m.PayloadRuleInsert != nil { size, err := m.PayloadRuleInsert.MarshalToSizedBufferVT(dAtA[:i]) @@ -1293,7 +1304,7 @@ func (m *CollectionMessage) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i -= size i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x32 } if m.PayloadData != nil { size, err := m.PayloadData.MarshalToSizedBufferVT(dAtA[:i]) @@ -1303,27 +1314,34 @@ func (m *CollectionMessage) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i -= size i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x2a } - if m.PayloadUnsubscribe != nil { - size, err := m.PayloadUnsubscribe.MarshalToSizedBufferVT(dAtA[:i]) + 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.PayloadSubscribe != nil { - size, err := m.PayloadSubscribe.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + if m.Status != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Status)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -1680,12 +1698,18 @@ func (m *CollectionMessage) SizeVT() (n int) { } var l int _ = l - if m.PayloadSubscribe != nil { - l = m.PayloadSubscribe.SizeVT() + 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.PayloadUnsubscribe != nil { - l = m.PayloadUnsubscribe.SizeVT() + 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 { @@ -2748,10 +2772,29 @@ func (m *CollectionMessage) UnmarshalVT(dAtA []byte) error { } 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 PayloadSubscribe", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return protohelpers.ErrIntOverflow @@ -2761,31 +2804,47 @@ func (m *CollectionMessage) 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.PayloadSubscribe == nil { - m.PayloadSubscribe = &CollectionPayloadSubscribe{} + 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) } - if err := m.PayloadSubscribe.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err + 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 + } } - iNdEx = postIndex - case 2: + case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PayloadUnsubscribe", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PayloadSubscribe", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2812,14 +2871,14 @@ func (m *CollectionMessage) UnmarshalVT(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.PayloadUnsubscribe == nil { - m.PayloadUnsubscribe = &CollectionPayloadSubscribe{} + if m.PayloadSubscribe == nil { + m.PayloadSubscribe = &CollectionPayloadSubscribe{} } - if err := m.PayloadUnsubscribe.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + if err := m.PayloadSubscribe.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 3: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PayloadData", wireType) } @@ -2855,7 +2914,7 @@ func (m *CollectionMessage) UnmarshalVT(dAtA []byte) error { return err } iNdEx = postIndex - case 4: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PayloadRuleInsert", wireType) } @@ -2891,7 +2950,7 @@ func (m *CollectionMessage) UnmarshalVT(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PayloadRuleDelete", wireType) } 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 ddee54e1a0..ac88271768 100644 --- a/api/settings/v1/setting.proto +++ b/api/settings/v1/setting.proto @@ -90,13 +90,20 @@ message CollectionInstance { int64 last_updated = 3; } +enum Status { + STATUS_UNSPECIFIED = 0; + STATUS_OK = 1; + STATUS_ERROR = 2; +} + message CollectionMessage { - // TODO: Status, ID - CollectionPayloadSubscribe payload_subscribe = 1; - CollectionPayloadSubscribe payload_unsubscribe = 2; - CollectionPayloadData payload_data = 3; - CollectionPayloadRuleInsert payload_rule_insert = 4; - CollectionPayloadRuleDelete payload_rule_delete = 5; + 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 { From b88fc9349e6080326b368597be277658ae9ca5b8 Mon Sep 17 00:00:00 2001 From: Christian Simon Date: Thu, 27 Jun 2024 11:23:20 +0100 Subject: [PATCH 05/10] Make initial test pass --- pkg/settings/collection/collection.go | 63 ++++- pkg/settings/collection/collection_test.go | 64 +++-- pkg/settings/collection/hub.go | 304 +++++++++++++++++++-- pkg/settings/collection/rules.go | 79 ++++++ pkg/settings/collection/websocket.go | 166 +++++------ 5 files changed, 516 insertions(+), 160 deletions(-) create mode 100644 pkg/settings/collection/rules.go diff --git a/pkg/settings/collection/collection.go b/pkg/settings/collection/collection.go index a94b9a4f60..fd59587a1c 100644 --- a/pkg/settings/collection/collection.go +++ b/pkg/settings/collection/collection.go @@ -9,13 +9,17 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" "github.com/gorilla/websocket" - "github.com/grafana/dskit/tenant" - settingsv1 "github.com/grafana/pyroscope/api/gen/proto/go/settings/v1" ) -type Config struct { -} +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. @@ -23,12 +27,12 @@ type Collection struct { cfg Config logger log.Logger wg sync.WaitGroup + stopCh chan struct{} - lck sync.RWMutex - Rules []settingsv1.CollectionRule + lck sync.RWMutex upgrader websocket.Upgrader - hubs map[hubKey]*Hub + hubs map[hubKey]*hub } func New(cfg Config, logger log.Logger) *Collection { @@ -40,7 +44,8 @@ func New(cfg Config, logger log.Logger) *Collection { WriteBufferSize: 1024, CheckOrigin: func(r *http.Request) bool { return true }, // TODO: check origin }, - hubs: make(map[hubKey]*Hub), + hubs: make(map[hubKey]*hub), + stopCh: make(chan struct{}), } } @@ -56,6 +61,11 @@ var ( errInvalidScopeName = fmt.Errorf("invalid scope name, must match %s", validScopeName) ) +func (c *Collection) Stop() { + close(c.stopCh) + c.wg.Wait() +} + // serveWs handles websocket requests from the peer. func (c *Collection) handleWS(w http.ResponseWriter, r *http.Request, role Role) { tenantID, err := tenant.TenantID(r.Context()) @@ -85,22 +95,37 @@ func (c *Collection) handleWS(w http.ResponseWriter, r *http.Request, role Role) hub := c.getHub(hubKey{tenantID: tenantID, scope: scope}) - client := &Client{ + client := &client{ hub: hub, conn: conn, send: make(chan []byte, 256), role: role, } - client.logger = log.With(c.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") + 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. - go client.writePump() - go client.readPump() + 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 { +func (c *Collection) getHub(k hubKey) *hub { c.lck.RLock() h, ok := c.hubs[k] if ok { @@ -117,7 +142,15 @@ func (c *Collection) getHub(k hubKey) *Hub { return h } - h = &Hub{} + h = newHub( + log.With(c.logger, "tenant", k.tenantID, "scope", k.scope), + 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 index 275761db50..b044fcc772 100644 --- a/pkg/settings/collection/collection_test.go +++ b/pkg/settings/collection/collection_test.go @@ -1,6 +1,7 @@ package collection import ( + "encoding/json" "net/http" "net/http/httptest" "os" @@ -12,27 +13,26 @@ import ( "github.com/go-kit/log" "github.com/gorilla/websocket" "github.com/grafana/dskit/user" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.uber.org/goleak" + "gopkg.in/yaml.v3" settingsv1 "github.com/grafana/pyroscope/api/gen/proto/go/settings/v1" ) var ( - payloadSubscribeRules = []byte(`{"Payload":{"PayloadSubscribe":{"topics":["rules"]}}}`) + payloadSubscribeRules = []byte(`{"payload_subscribe":{"topics":["rules"]}}`) ) -func ruleMsg(rule settingsv1.CollectionRule, after int64) *settingsv1.CollectionMessage { +func ruleMsg(rule *settingsv1.CollectionRule, after int64) *settingsv1.CollectionMessage { var afterPtr *int64 if after != 0 { afterPtr = &after } return &settingsv1.CollectionMessage{ - Payload: &settingsv1.CollectionMessage_PayloadRuleInsert{ - PayloadRuleInsert: &settingsv1.CollectionPayloadRuleInsert{ - Rule: &rule, - After: afterPtr, - }, + PayloadRuleInsert: &settingsv1.CollectionPayloadRuleInsert{ + Rule: rule, + After: afterPtr, }, } } @@ -41,13 +41,34 @@ 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{}, logger) + defer c.Stop() // Create test server with the echo handler. mux := http.NewServeMux() @@ -68,21 +89,20 @@ func TestCollection_TwoCollectionInstances_OneRuleManager(t *testing.T) { // 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{ + &settingsv1.CollectionRule{ Action: settingsv1.CollectionRuleAction_COLLECTION_RULE_ACTION_KEEP, SourceLabels: []string{"service_name"}, Regex: stringPtr("loki-.*"), }, 0))) - // drop everything else - require.NoError(t, ruleManager.WriteJSON(ruleMsg( - settingsv1.CollectionRule{ - Action: settingsv1.CollectionRuleAction_COLLECTION_RULE_ACTION_DROP, - }, 0))) - // validate rules have been updated require.Eventually(t, func() bool { c.lck.RLock() @@ -97,7 +117,7 @@ func TestCollection_TwoCollectionInstances_OneRuleManager(t *testing.T) { defer h.lck.RUnlock() return len(h.rules) == 2 - }, 50*time.Millisecond, time.Millisecond) + }, 500000*time.Millisecond, time.Millisecond) // setup clients collection1, _, err := websocket.DefaultDialer.Dial(u+"/collection", nil) @@ -105,8 +125,6 @@ func TestCollection_TwoCollectionInstances_OneRuleManager(t *testing.T) { collection2, _, err := websocket.DefaultDialer.Dial(u+"/collection", nil) require.NoError(t, err) - // TODO: Add some rules to the collection - require.NoError(t, collection1.WriteMessage(websocket.TextMessage, payloadSubscribeRules)) require.NoError(t, collection2.WriteMessage(websocket.TextMessage, payloadSubscribeRules)) @@ -115,12 +133,16 @@ func TestCollection_TwoCollectionInstances_OneRuleManager(t *testing.T) { defer wg.Done() var msg settingsv1.CollectionMessage for { - err := collection2.ReadJSON(&msg) + err := c.ReadJSON(&msg) require.NoError(t, err) - if p, ok := msg.GetPayload().(*settingsv1.CollectionMessage_PayloadData); ok { + if p := msg.PayloadData; p != nil { // validate rules - assert.Equal(t, 2, len(p.PayloadData.Rules), "expect two 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 } } diff --git a/pkg/settings/collection/hub.go b/pkg/settings/collection/hub.go index 680271ef14..11e022f1d7 100644 --- a/pkg/settings/collection/hub.go +++ b/pkg/settings/collection/hub.go @@ -1,9 +1,16 @@ package collection import ( + "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" ) @@ -12,36 +19,52 @@ const defaultScope = "profiles-collection" type topic struct { name string ch chan struct{} - update func() ([]byte, error) + update func(*settingsv1.CollectionPayloadData) error err error - content []byte - hasher xxhash.Digest + content *settingsv1.CollectionPayloadData hash uint64 - clients map[*Client]uint64 + clients map[*client]uint64 } -func newTopic(name string, f func() ([]byte, error)) *topic { +func newTopic(name string, f func(*settingsv1.CollectionPayloadData) error) *topic { return &topic{ name: name, ch: make(chan struct{}), update: f, hash: 0, - clients: make(map[*Client]uint64), + clients: make(map[*client]uint64), + content: &settingsv1.CollectionPayloadData{}, } } -func (t *topic) get() { - t.content, t.err = t.update() +type buf struct { + data []byte + hasher xxhash.Digest +} + +func (t *topic) get(b *buf) { + t.err = t.update(t.content) if t.err != nil { return } - t.hasher.Reset() - _, t.err = t.hasher.Write(t.content) + 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 } - t.hash = t.hasher.Sum64() + + b.hasher.Reset() + _, t.err = b.hasher.Write(b.data) + if t.err != nil { + return + } + t.hash = b.hasher.Sum64() } type hubKey struct { @@ -49,33 +72,142 @@ type hubKey struct { scope string } -type Hub struct { +type hub struct { + logger log.Logger lck sync.RWMutex nextRuleID int64 rules []*settingsv1.CollectionRule - app *Collection - topics map[string]*topic - agentsPublishing map[*Client]bool // are particular grafana agents publishing their targets + clients map[*client]struct{} + + agentsPublishing map[*client]bool // are particular grafana agents publishing their targets agentsPublishingActive bool // is agent publishing requested agents map[string]*settingsv1.CollectionInstance // Register requests from the clients. - registerCh chan *Client + registerCh chan *client // Unregister requests from clients. - unregisterCh chan *Client + unregisterCh chan *client // Update agent targets agentCh chan *settingsv1.CollectionInstance // Update rules - rulesCh chan func(*Hub) + rulesCh chan func(*hub) + + // keep data and hash buffer around + buf buf +} + +func newHub(logger log.Logger, topicsF func(*hub) []*topic) *hub { + h := &hub{ + logger: logger, + topics: make(map[string]*topic), + clients: make(map[*client]struct{}), + agentsPublishing: make(map[*client]bool), + agents: make(map[string]*settingsv1.CollectionInstance), + agentCh: 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(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(&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 } -func (a *Hub) insertRule(data *settingsv1.CollectionPayloadRuleInsert) { +// check if agent needs toggle publishing +func (h *hub) updateClientToggleAgentSubscription(client *client) error { + active, ok := h.agentsPublishing[client] + if !ok { + return nil + } + if active != h.agentsPublishingActive { + + msg := settingsv1.CollectionMessage{ + PayloadSubscribe: &settingsv1.CollectionPayloadSubscribe{}, + } + if !active { + msg.PayloadSubscribe.Topics = []string{"agents"} + } + + data, err := json.Marshal(&msg) + if err != nil { + return err + } + + level.Debug(client.logger).Log("request agent publishing", "client", fmt.Sprintf("%p", client), "data", string(data)) + client.send <- data + + h.agentsPublishing[client] = h.agentsPublishingActive + } + return nil +} + +func (h *hub) updateClient(client *client) { + if err := h.updateClientTopicsToPublish(client); err != nil { + level.Error(client.logger).Log("msg", "error updating client topics to publish", "err", err) + } + if err := h.updateClientToggleAgentSubscription(client); err != nil { + level.Error(client.logger).Log("msg", "error updating client to subscribe to agents", "err", err) + } +} + +func (h *hub) updateAgents() { + t, ok := h.topics["agents"] + if !ok { + return + } + t.get(&h.buf) + + // update frontend with new agents data + for client := range t.clients { + h.updateClient(client) + } +} + +func (a *hub) insertRule(data *settingsv1.CollectionPayloadRuleInsert) { a.lck.Lock() defer a.lck.Unlock() @@ -112,7 +244,7 @@ func (a *Hub) insertRule(data *settingsv1.CollectionPayloadRuleInsert) { } -func (h *Hub) deleteRule(id int64) { +func (h *hub) deleteRule(id int64) { h.lck.Lock() defer h.lck.Unlock() @@ -123,3 +255,135 @@ func (h *Hub) deleteRule(id int64) { } } } + +func (h *hub) run(stopCh <-chan struct{}) { + 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.agentsPublishing[client] = false + } + + // check if agents need toggle publishing + agentsTopic, ok := h.topics["agents"] + agentsPublishingRequested := false + if ok { + agentsPublishingRequested = len(agentsTopic.clients) != 0 + } + if agentsPublishingRequested != h.agentsPublishingActive { + if agentsPublishingRequested { + slog.Debug("agents publishing has been enabled") + } else { + slog.Debug("agents publishing has been disabled") + } + h.agentsPublishingActive = agentsPublishingRequested + // send message to all agents + for agent := range h.agentsPublishing { + h.updateClient(agent) + } + } + h.updateClient(client) + case agent := <-h.agentCh: + agent.LastUpdated = time.Now().UnixMilli() + h.agents[agent.Hostname] = agent + h.updateAgents() + 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["rules"] + if !ok { + continue + } + t.get(&h.buf) + // update all clients + for client := range t.clients { + h.updateClient(client) + } + } + } +} + +func (h *hub) updateRulesPayload(p *settingsv1.CollectionPayloadData) error { + h.lck.RLock() + defer h.lck.RUnlock() + + if cap(p.Rules) < len(h.rules) { + p.Rules = make([]*settingsv1.CollectionRule, 0, len(h.rules)) + } else { + p.Rules = p.Rules[:0] + } + for _, r := range h.rules { + p.Rules = append(p.Rules, r.CloneVT()) + } + return nil +} + +func (h *hub) updateInstancesPayload(p *settingsv1.CollectionPayloadData) error { + h.lck.RLock() + defer h.lck.RUnlock() + + if cap(p.Instances) < len(h.agents) { + p.Instances = make([]*settingsv1.CollectionInstance, 0, len(h.agents)) + } else { + p.Instances = p.Instances[:0] + } + for _, a := range h.agents { + 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..fb3626199c --- /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.v2" + + 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/websocket.go b/pkg/settings/collection/websocket.go index b09a35b9b3..91d95c6334 100644 --- a/pkg/settings/collection/websocket.go +++ b/pkg/settings/collection/websocket.go @@ -1,6 +1,11 @@ package collection import ( + "errors" + "fmt" + "net" + "sync" + "github.com/go-kit/log" "github.com/go-kit/log/level" "github.com/gorilla/websocket" @@ -8,80 +13,29 @@ import ( settingsv1 "github.com/grafana/pyroscope/api/gen/proto/go/settings/v1" ) -var ( - newline = []byte{'\n'} -) - -// Client is a middleman between the websocket connection and the hub. -type Client struct { - hub *Hub +// 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 - + role Role subscribedTopics []string // Buffered channel of outbound messages. - send chan []byte -} - -type recvMsg = settingsv1.CollectionMessage - -/* -type recvMsg struct { - Type model.MessageType `json:"type"` - Data *model.PayloadData - Subscribe *model.PayloadSubscribe - RuleDelete *model.PayloadRuleDelete - RuleInsert *model.PayloadRuleInsert + send chan []byte + sendClose sync.Once } -func (m *recvMsg) UnmarshalJSON(b []byte) error { - var header struct { - Type model.MessageType `json:"type"` - Payload json.RawMessage `json:"payload"` - } - json.Unmarshal(b, &header) - m.Type = header.Type - m.Data = nil - m.Subscribe = nil - - switch m.Type { - case model.MessageTypeData: - var data model.PayloadData - if err := json.Unmarshal(header.Payload, &data); err != nil { - return err - } - m.Data = &data - case model.MessageTypeSubscribe: - var subscribe model.PayloadSubscribe - if err := json.Unmarshal(header.Payload, &subscribe); err != nil { - return err - } - m.Subscribe = &subscribe - case model.MessageTypeRuleInsert: - var e model.PayloadRuleInsert - if err := json.Unmarshal(header.Payload, &e); err != nil { - return err - } - m.RuleInsert = &e - case model.MessageTypeRuleDelete: - var e model.PayloadRuleDelete - if err := json.Unmarshal(header.Payload, &e); err != nil { - return err - } - m.RuleDelete = &e - default: - return fmt.Errorf("unknown message type %s", m.Type) - } - return nil +func (c *client) close() { + c.sendClose.Do(func() { + close(c.send) + }) } -*/ -func (c *Client) isRuleManager() bool { +func (c *client) isRuleManager() bool { return c.role&RuleManager == RuleManager } @@ -90,7 +44,7 @@ func (c *Client) isRuleManager() bool { // 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() { +func (c *client) readPump() { defer func() { c.hub.unregisterCh <- c c.conn.Close() @@ -100,27 +54,31 @@ func (c *Client) readPump() { ) 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 } - switch p := msg.Payload.(type) { - case *settingsv1.CollectionMessage_PayloadSubscribe: - - c.subscribedTopics = p.PayloadSubscribe.Topics - level.Debug(c.logger).Log("msg", "client subscribing", "topics", p.PayloadSubscribe.Topics) + if p := msg.PayloadSubscribe; p != nil { + c.subscribedTopics = p.Topics + level.Debug(c.logger).Log("msg", "client subscribing", "topics", fmt.Sprintf("%v", p.Topics)) c.hub.registerCh <- c - case *settingsv1.CollectionMessage_PayloadData: - for idx := range p.PayloadData.Instances { - a := p.PayloadData.Instances[idx] + } else if p := msg.PayloadData; p != nil { + + for idx := range p.Instances { + a := p.Instances[idx] level.Debug(c.logger).Log("msg", "received collection instance targets", "hostname", a.Hostname, "targets", len(a.Targets)) c.hub.agentCh <- a } - case *settingsv1.CollectionMessage_PayloadRuleDelete: - if p.PayloadRuleDelete.Id <= 0 { + } else if p := msg.PayloadRuleDelete; p != nil { + if p.Id <= 0 { level.Warn(c.logger).Log("msg", "received rule delete without id") continue } @@ -128,23 +86,22 @@ func (c *Client) readPump() { level.Warn(c.logger).Log("msg", "not allowed for collection instance") continue } - level.Debug(c.logger).Log("msg", "received rule delete", "id", p.PayloadRuleDelete.Id) - id := p.PayloadRuleDelete.Id - c.hub.rulesCh <- func(h *Hub) { + level.Info(c.logger).Log("msg", "received rule delete", "id", p.Id) + id := p.Id + c.hub.rulesCh <- func(h *hub) { h.deleteRule(id) } - case *settingsv1.CollectionMessage_PayloadRuleInsert: + } else if p := msg.PayloadRuleInsert; p != nil { if !c.isRuleManager() { level.Warn(c.logger).Log("msg", "not allowed without rule manager role") continue } - level.Debug(c.logger).Log("msg", "received rule insert", "rule", p.PayloadRuleInsert.Rule) - c.hub.rulesCh <- func(h *Hub) { - h.insertRule(p.PayloadRuleInsert) + level.Info(c.logger).Log("msg", "received rule insert", "rule", p.Rule) + c.hub.rulesCh <- func(h *hub) { + h.insertRule(p) } - - default: - level.Warn(c.logger).Log("msg", "unknown message type", "type", msg.Payload) + } else { + level.Warn(c.logger).Log("msg", "no known message type used") } } } @@ -154,32 +111,33 @@ func (c *Client) readPump() { // 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() { +func (c *client) writePump() { defer func() { c.conn.Close() }() - for { - select { - case message, ok := <-c.send: - if !ok { - // The hub closed the channel. - c.conn.WriteMessage(websocket.CloseMessage, []byte{}) - return - } + for message := range c.send { - w, err := c.conn.NextWriter(websocket.TextMessage) - if err != nil { - return - } - messageLen, _ := w.Write(message) - if len(message) > 64 { - message = append(message[:64], []byte("...")...) - } - level.Debug(c.logger).Log("msg", "sent message to client", "size", messageLen, "message", message) + 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 { - 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{}) } From b10bdcecca51313439395086e13f0ff333cdfb8b Mon Sep 17 00:00:00 2001 From: Christian Simon Date: Thu, 27 Jun 2024 16:24:14 +0100 Subject: [PATCH 06/10] Add rule store type to proto --- api/gen/proto/go/settings/v1/setting.pb.go | 429 +++++++++++------- .../go/settings/v1/setting_vtproto.pb.go | 233 ++++++++++ api/settings/v1/setting.proto | 8 +- 3 files changed, 493 insertions(+), 177 deletions(-) diff --git a/api/gen/proto/go/settings/v1/setting.pb.go b/api/gen/proto/go/settings/v1/setting.pb.go index 6132a701df..292e87e6d1 100644 --- a/api/gen/proto/go/settings/v1/setting.pb.go +++ b/api/gen/proto/go/settings/v1/setting.pb.go @@ -515,6 +515,62 @@ func (x *CollectionRule) GetAction() CollectionRuleAction { 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 @@ -526,7 +582,7 @@ type CollectionTarget struct { func (x *CollectionTarget) Reset() { *x = CollectionTarget{} if protoimpl.UnsafeEnabled { - mi := &file_settings_v1_setting_proto_msgTypes[6] + mi := &file_settings_v1_setting_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -539,7 +595,7 @@ func (x *CollectionTarget) String() string { func (*CollectionTarget) ProtoMessage() {} func (x *CollectionTarget) ProtoReflect() protoreflect.Message { - mi := &file_settings_v1_setting_proto_msgTypes[6] + mi := &file_settings_v1_setting_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -552,7 +608,7 @@ func (x *CollectionTarget) ProtoReflect() protoreflect.Message { // Deprecated: Use CollectionTarget.ProtoReflect.Descriptor instead. func (*CollectionTarget) Descriptor() ([]byte, []int) { - return file_settings_v1_setting_proto_rawDescGZIP(), []int{6} + return file_settings_v1_setting_proto_rawDescGZIP(), []int{7} } func (x *CollectionTarget) GetLabels() []*v1.LabelPair { @@ -570,13 +626,13 @@ type CollectionInstance struct { 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"` + 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[7] + mi := &file_settings_v1_setting_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -589,7 +645,7 @@ func (x *CollectionInstance) String() string { func (*CollectionInstance) ProtoMessage() {} func (x *CollectionInstance) ProtoReflect() protoreflect.Message { - mi := &file_settings_v1_setting_proto_msgTypes[7] + mi := &file_settings_v1_setting_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -602,7 +658,7 @@ func (x *CollectionInstance) ProtoReflect() protoreflect.Message { // Deprecated: Use CollectionInstance.ProtoReflect.Descriptor instead. func (*CollectionInstance) Descriptor() ([]byte, []int) { - return file_settings_v1_setting_proto_rawDescGZIP(), []int{7} + return file_settings_v1_setting_proto_rawDescGZIP(), []int{8} } func (x *CollectionInstance) GetHostname() string { @@ -643,7 +699,7 @@ type CollectionMessage struct { func (x *CollectionMessage) Reset() { *x = CollectionMessage{} if protoimpl.UnsafeEnabled { - mi := &file_settings_v1_setting_proto_msgTypes[8] + mi := &file_settings_v1_setting_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -656,7 +712,7 @@ func (x *CollectionMessage) String() string { func (*CollectionMessage) ProtoMessage() {} func (x *CollectionMessage) ProtoReflect() protoreflect.Message { - mi := &file_settings_v1_setting_proto_msgTypes[8] + mi := &file_settings_v1_setting_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -669,7 +725,7 @@ func (x *CollectionMessage) ProtoReflect() protoreflect.Message { // Deprecated: Use CollectionMessage.ProtoReflect.Descriptor instead. func (*CollectionMessage) Descriptor() ([]byte, []int) { - return file_settings_v1_setting_proto_rawDescGZIP(), []int{8} + return file_settings_v1_setting_proto_rawDescGZIP(), []int{9} } func (x *CollectionMessage) GetStatus() Status { @@ -732,7 +788,7 @@ type CollectionPayloadSubscribe struct { func (x *CollectionPayloadSubscribe) Reset() { *x = CollectionPayloadSubscribe{} if protoimpl.UnsafeEnabled { - mi := &file_settings_v1_setting_proto_msgTypes[9] + mi := &file_settings_v1_setting_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -745,7 +801,7 @@ func (x *CollectionPayloadSubscribe) String() string { func (*CollectionPayloadSubscribe) ProtoMessage() {} func (x *CollectionPayloadSubscribe) ProtoReflect() protoreflect.Message { - mi := &file_settings_v1_setting_proto_msgTypes[9] + mi := &file_settings_v1_setting_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -758,7 +814,7 @@ func (x *CollectionPayloadSubscribe) ProtoReflect() protoreflect.Message { // Deprecated: Use CollectionPayloadSubscribe.ProtoReflect.Descriptor instead. func (*CollectionPayloadSubscribe) Descriptor() ([]byte, []int) { - return file_settings_v1_setting_proto_rawDescGZIP(), []int{9} + return file_settings_v1_setting_proto_rawDescGZIP(), []int{10} } func (x *CollectionPayloadSubscribe) GetTopics() []string { @@ -780,7 +836,7 @@ type CollectionPayloadData struct { func (x *CollectionPayloadData) Reset() { *x = CollectionPayloadData{} if protoimpl.UnsafeEnabled { - mi := &file_settings_v1_setting_proto_msgTypes[10] + mi := &file_settings_v1_setting_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -793,7 +849,7 @@ func (x *CollectionPayloadData) String() string { func (*CollectionPayloadData) ProtoMessage() {} func (x *CollectionPayloadData) ProtoReflect() protoreflect.Message { - mi := &file_settings_v1_setting_proto_msgTypes[10] + mi := &file_settings_v1_setting_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -806,7 +862,7 @@ func (x *CollectionPayloadData) ProtoReflect() protoreflect.Message { // Deprecated: Use CollectionPayloadData.ProtoReflect.Descriptor instead. func (*CollectionPayloadData) Descriptor() ([]byte, []int) { - return file_settings_v1_setting_proto_rawDescGZIP(), []int{10} + return file_settings_v1_setting_proto_rawDescGZIP(), []int{11} } func (x *CollectionPayloadData) GetRules() []*CollectionRule { @@ -835,7 +891,7 @@ type CollectionPayloadRuleInsert struct { func (x *CollectionPayloadRuleInsert) Reset() { *x = CollectionPayloadRuleInsert{} if protoimpl.UnsafeEnabled { - mi := &file_settings_v1_setting_proto_msgTypes[11] + mi := &file_settings_v1_setting_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -848,7 +904,7 @@ func (x *CollectionPayloadRuleInsert) String() string { func (*CollectionPayloadRuleInsert) ProtoMessage() {} func (x *CollectionPayloadRuleInsert) ProtoReflect() protoreflect.Message { - mi := &file_settings_v1_setting_proto_msgTypes[11] + mi := &file_settings_v1_setting_proto_msgTypes[12] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -861,7 +917,7 @@ func (x *CollectionPayloadRuleInsert) ProtoReflect() protoreflect.Message { // Deprecated: Use CollectionPayloadRuleInsert.ProtoReflect.Descriptor instead. func (*CollectionPayloadRuleInsert) Descriptor() ([]byte, []int) { - return file_settings_v1_setting_proto_rawDescGZIP(), []int{11} + return file_settings_v1_setting_proto_rawDescGZIP(), []int{12} } func (x *CollectionPayloadRuleInsert) GetRule() *CollectionRule { @@ -889,7 +945,7 @@ type CollectionPayloadRuleDelete struct { func (x *CollectionPayloadRuleDelete) Reset() { *x = CollectionPayloadRuleDelete{} if protoimpl.UnsafeEnabled { - mi := &file_settings_v1_setting_proto_msgTypes[12] + mi := &file_settings_v1_setting_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -902,7 +958,7 @@ func (x *CollectionPayloadRuleDelete) String() string { func (*CollectionPayloadRuleDelete) ProtoMessage() {} func (x *CollectionPayloadRuleDelete) ProtoReflect() protoreflect.Message { - mi := &file_settings_v1_setting_proto_msgTypes[12] + mi := &file_settings_v1_setting_proto_msgTypes[13] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -915,7 +971,7 @@ func (x *CollectionPayloadRuleDelete) ProtoReflect() protoreflect.Message { // Deprecated: Use CollectionPayloadRuleDelete.ProtoReflect.Descriptor instead. func (*CollectionPayloadRuleDelete) Descriptor() ([]byte, []int) { - return file_settings_v1_setting_proto_rawDescGZIP(), []int{12} + return file_settings_v1_setting_proto_rawDescGZIP(), []int{13} } func (x *CollectionPayloadRuleDelete) GetId() int64 { @@ -975,127 +1031,134 @@ var file_settings_v1_setting_proto_rawDesc = []byte{ 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, 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, + 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, 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, + 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, 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, + 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, 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, + 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, 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, + 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 ( @@ -1111,7 +1174,7 @@ func file_settings_v1_setting_proto_rawDescGZIP() []byte { } var file_settings_v1_setting_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_settings_v1_setting_proto_msgTypes = make([]protoimpl.MessageInfo, 13) +var file_settings_v1_setting_proto_msgTypes = make([]protoimpl.MessageInfo, 14) var file_settings_v1_setting_proto_goTypes = []any{ (CollectionRuleAction)(0), // 0: settings.v1.CollectionRuleAction (Status)(0), // 1: settings.v1.Status @@ -1121,39 +1184,41 @@ var file_settings_v1_setting_proto_goTypes = []any{ (*SetSettingsResponse)(nil), // 5: settings.v1.SetSettingsResponse (*Setting)(nil), // 6: settings.v1.Setting (*CollectionRule)(nil), // 7: settings.v1.CollectionRule - (*CollectionTarget)(nil), // 8: settings.v1.CollectionTarget - (*CollectionInstance)(nil), // 9: settings.v1.CollectionInstance - (*CollectionMessage)(nil), // 10: settings.v1.CollectionMessage - (*CollectionPayloadSubscribe)(nil), // 11: settings.v1.CollectionPayloadSubscribe - (*CollectionPayloadData)(nil), // 12: settings.v1.CollectionPayloadData - (*CollectionPayloadRuleInsert)(nil), // 13: settings.v1.CollectionPayloadRuleInsert - (*CollectionPayloadRuleDelete)(nil), // 14: settings.v1.CollectionPayloadRuleDelete - (*v1.LabelPair)(nil), // 15: types.v1.LabelPair + (*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{ 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 - 15, // 4: settings.v1.CollectionTarget.labels:type_name -> types.v1.LabelPair - 8, // 5: settings.v1.CollectionInstance.targets:type_name -> settings.v1.CollectionTarget - 1, // 6: settings.v1.CollectionMessage.status:type_name -> settings.v1.Status - 11, // 7: settings.v1.CollectionMessage.payload_subscribe:type_name -> settings.v1.CollectionPayloadSubscribe - 12, // 8: settings.v1.CollectionMessage.payload_data:type_name -> settings.v1.CollectionPayloadData - 13, // 9: settings.v1.CollectionMessage.payload_rule_insert:type_name -> settings.v1.CollectionPayloadRuleInsert - 14, // 10: settings.v1.CollectionMessage.payload_rule_delete:type_name -> settings.v1.CollectionPayloadRuleDelete - 7, // 11: settings.v1.CollectionPayloadData.rules:type_name -> settings.v1.CollectionRule - 9, // 12: settings.v1.CollectionPayloadData.instances:type_name -> settings.v1.CollectionInstance - 7, // 13: settings.v1.CollectionPayloadRuleInsert.rule:type_name -> settings.v1.CollectionRule - 2, // 14: settings.v1.SettingsService.Get:input_type -> settings.v1.GetSettingsRequest - 4, // 15: settings.v1.SettingsService.Set:input_type -> settings.v1.SetSettingsRequest - 3, // 16: settings.v1.SettingsService.Get:output_type -> settings.v1.GetSettingsResponse - 5, // 17: settings.v1.SettingsService.Set:output_type -> settings.v1.SetSettingsResponse - 16, // [16:18] is the sub-list for method output_type - 14, // [14:16] is the sub-list for method input_type - 14, // [14:14] is the sub-list for extension type_name - 14, // [14:14] is the sub-list for extension extendee - 0, // [0:14] is the sub-list for field type_name + 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() } @@ -1235,7 +1300,7 @@ func file_settings_v1_setting_proto_init() { } } file_settings_v1_setting_proto_msgTypes[6].Exporter = func(v any, i int) any { - switch v := v.(*CollectionTarget); i { + switch v := v.(*CollectionRuleStore); i { case 0: return &v.state case 1: @@ -1247,7 +1312,7 @@ func file_settings_v1_setting_proto_init() { } } file_settings_v1_setting_proto_msgTypes[7].Exporter = func(v any, i int) any { - switch v := v.(*CollectionInstance); i { + switch v := v.(*CollectionTarget); i { case 0: return &v.state case 1: @@ -1259,7 +1324,7 @@ func file_settings_v1_setting_proto_init() { } } file_settings_v1_setting_proto_msgTypes[8].Exporter = func(v any, i int) any { - switch v := v.(*CollectionMessage); i { + switch v := v.(*CollectionInstance); i { case 0: return &v.state case 1: @@ -1271,7 +1336,7 @@ func file_settings_v1_setting_proto_init() { } } file_settings_v1_setting_proto_msgTypes[9].Exporter = func(v any, i int) any { - switch v := v.(*CollectionPayloadSubscribe); i { + switch v := v.(*CollectionMessage); i { case 0: return &v.state case 1: @@ -1283,7 +1348,7 @@ func file_settings_v1_setting_proto_init() { } } file_settings_v1_setting_proto_msgTypes[10].Exporter = func(v any, i int) any { - switch v := v.(*CollectionPayloadData); i { + switch v := v.(*CollectionPayloadSubscribe); i { case 0: return &v.state case 1: @@ -1295,7 +1360,7 @@ func file_settings_v1_setting_proto_init() { } } file_settings_v1_setting_proto_msgTypes[11].Exporter = func(v any, i int) any { - switch v := v.(*CollectionPayloadRuleInsert); i { + switch v := v.(*CollectionPayloadData); i { case 0: return &v.state case 1: @@ -1307,6 +1372,18 @@ func file_settings_v1_setting_proto_init() { } } 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 @@ -1320,15 +1397,15 @@ func file_settings_v1_setting_proto_init() { } } file_settings_v1_setting_proto_msgTypes[5].OneofWrappers = []any{} - file_settings_v1_setting_proto_msgTypes[8].OneofWrappers = []any{} - file_settings_v1_setting_proto_msgTypes[11].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: 2, - NumMessages: 13, + NumMessages: 14, NumExtensions: 0, NumServices: 1, }, 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 4815dfc372..d14037c83a 100644 --- a/api/gen/proto/go/settings/v1/setting_vtproto.pb.go +++ b/api/gen/proto/go/settings/v1/setting_vtproto.pb.go @@ -159,6 +159,30 @@ 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) @@ -484,6 +508,42 @@ func (this *CollectionRule) EqualMessageVT(thatMsg proto.Message) bool { } return this.EqualVT(that) } +func (this *CollectionRuleStore) EqualVT(that *CollectionRuleStore) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if len(this.Rules) != len(that.Rules) { + return false + } + 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 this.LastUpdated != that.LastUpdated { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *CollectionRuleStore) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*CollectionRuleStore) + if !ok { + return false + } + return this.EqualVT(that) +} func (this *CollectionTarget) EqualVT(that *CollectionTarget) bool { if this == that { return true @@ -1142,6 +1202,56 @@ func (m *CollectionRule) MarshalToSizedBufferVT(dAtA []byte) (int, error) { 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 @@ -1647,6 +1757,25 @@ func (m *CollectionRule) SizeVT() (n int) { 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 @@ -2513,6 +2642,110 @@ func (m *CollectionRule) UnmarshalVT(dAtA []byte) error { } 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 diff --git a/api/settings/v1/setting.proto b/api/settings/v1/setting.proto index ac88271768..82cd458434 100644 --- a/api/settings/v1/setting.proto +++ b/api/settings/v1/setting.proto @@ -79,6 +79,12 @@ message CollectionRule { 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; } @@ -87,7 +93,7 @@ message CollectionTarget { message CollectionInstance { string hostname = 1; repeated CollectionTarget targets = 2; - int64 last_updated = 3; + int64 last_updated = 3; // milliseconds unix time } enum Status { From ffbf2db30a4ec5d66eb45e217f9eaa82c3eb8a0e Mon Sep 17 00:00:00 2001 From: Christian Simon Date: Thu, 27 Jun 2024 17:28:44 +0100 Subject: [PATCH 07/10] Expose collection settings and implement store --- pkg/api/api.go | 3 + pkg/phlare/modules.go | 16 +- pkg/settings/bucket.go | 13 +- pkg/settings/bucket_test.go | 18 +- pkg/settings/collection/collection.go | 16 +- pkg/settings/collection/collection_test.go | 24 +-- pkg/settings/collection/hub.go | 205 +++++++++------------ pkg/settings/collection/store.go | 164 +++++++++++++++++ pkg/settings/collection/websocket.go | 34 +++- pkg/settings/setting_test.go | 4 +- pkg/settings/settings.go | 25 ++- pkg/settings/store.go | 2 +- 12 files changed, 349 insertions(+), 175 deletions(-) create mode 100644 pkg/settings/collection/store.go 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 index fd59587a1c..313d42aa56 100644 --- a/pkg/settings/collection/collection.go +++ b/pkg/settings/collection/collection.go @@ -1,6 +1,7 @@ package collection import ( + "context" "fmt" "net/http" "regexp" @@ -10,6 +11,7 @@ import ( "github.com/go-kit/log/level" "github.com/gorilla/websocket" "github.com/grafana/dskit/tenant" + "github.com/thanos-io/objstore" ) type Config struct{} @@ -25,6 +27,7 @@ const ( // 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{} @@ -35,9 +38,10 @@ type Collection struct { hubs map[hubKey]*hub } -func New(cfg Config, logger log.Logger) *Collection { +func New(cfg Config, bucket objstore.Bucket, logger log.Logger) *Collection { return &Collection{ cfg: cfg, + bucket: bucket, logger: logger, upgrader: websocket.Upgrader{ ReadBufferSize: 1024, @@ -61,12 +65,17 @@ var ( errInvalidScopeName = fmt.Errorf("invalid scope name, must match %s", validScopeName) ) -func (c *Collection) Stop() { +func (c *Collection) Stop(ctx context.Context) { close(c.stopCh) c.wg.Wait() } -// serveWs handles websocket requests from the peer. +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 { @@ -144,6 +153,7 @@ func (c *Collection) getHub(k hubKey) *hub { h = newHub( log.With(c.logger, "tenant", k.tenantID, "scope", k.scope), + newBucketStore(c.bucket, k), defaultTopics, ) c.wg.Add(1) diff --git a/pkg/settings/collection/collection_test.go b/pkg/settings/collection/collection_test.go index b044fcc772..9db70c5d3f 100644 --- a/pkg/settings/collection/collection_test.go +++ b/pkg/settings/collection/collection_test.go @@ -1,6 +1,7 @@ package collection import ( + "context" "encoding/json" "net/http" "net/http/httptest" @@ -13,7 +14,9 @@ import ( "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" @@ -67,17 +70,13 @@ func TestCollection_TwoCollectionInstances_OneRuleManager(t *testing.T) { if testing.Verbose() { logger = log.NewLogfmtLogger(os.Stderr) } - c := New(Config{}, logger) - defer c.Stop() + c := New(Config{}, objstore.NewInMemBucket(), logger) + defer c.Stop(context.Background()) // Create test server with the echo handler. mux := http.NewServeMux() - mux.HandleFunc("/collection", func(w http.ResponseWriter, r *http.Request) { - c.handleWS(w, r, RuleReceiver) - }) - mux.HandleFunc("/manager", func(w http.ResponseWriter, r *http.Request) { - c.handleWS(w, r, RuleManager) - }) + 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) @@ -113,10 +112,13 @@ func TestCollection_TwoCollectionInstances_OneRuleManager(t *testing.T) { } c.lck.RUnlock() - h.lck.RLock() - defer h.lck.RUnlock() + rules, err := h.store.list(context.Background()) + if err != nil { + assert.NoError(t, err) + return false + } - return len(h.rules) == 2 + return len(rules) == 2 }, 500000*time.Millisecond, time.Millisecond) // setup clients diff --git a/pkg/settings/collection/hub.go b/pkg/settings/collection/hub.go index 11e022f1d7..f8d07fa3b6 100644 --- a/pkg/settings/collection/hub.go +++ b/pkg/settings/collection/hub.go @@ -1,6 +1,7 @@ package collection import ( + "context" "encoding/json" "fmt" "log/slog" @@ -19,14 +20,14 @@ const defaultScope = "profiles-collection" type topic struct { name string ch chan struct{} - update func(*settingsv1.CollectionPayloadData) error + update func(context.Context, *settingsv1.CollectionPayloadData) error err error content *settingsv1.CollectionPayloadData hash uint64 clients map[*client]uint64 } -func newTopic(name string, f func(*settingsv1.CollectionPayloadData) error) *topic { +func newTopic(name string, f func(context.Context, *settingsv1.CollectionPayloadData) error) *topic { return &topic{ name: name, ch: make(chan struct{}), @@ -42,8 +43,8 @@ type buf struct { hasher xxhash.Digest } -func (t *topic) get(b *buf) { - t.err = t.update(t.content) +func (t *topic) get(ctx context.Context, b *buf) { + t.err = t.update(ctx, t.content) if t.err != nil { return } @@ -72,19 +73,23 @@ type hubKey struct { scope string } +func (k hubKey) path() string { + return fmt.Sprintf("%s/settings/collection.%s", k.tenantID, k.scope) +} + type hub struct { - logger log.Logger - lck sync.RWMutex - nextRuleID int64 - rules []*settingsv1.CollectionRule + logger log.Logger + + store *bucketStore + lck sync.RWMutex // TODO: Figure out why? topics map[string]*topic clients map[*client]struct{} - agentsPublishing map[*client]bool // are particular grafana agents publishing their targets - agentsPublishingActive bool // is agent publishing requested - agents map[string]*settingsv1.CollectionInstance + 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 @@ -92,8 +97,8 @@ type hub struct { // Unregister requests from clients. unregisterCh chan *client - // Update agent targets - agentCh chan *settingsv1.CollectionInstance + // Update instance targets + instanceCh chan *settingsv1.CollectionInstance // Update rules rulesCh chan func(*hub) @@ -102,17 +107,18 @@ type hub struct { buf buf } -func newHub(logger log.Logger, topicsF func(*hub) []*topic) *hub { +func newHub(logger log.Logger, store *bucketStore, topicsF func(*hub) []*topic) *hub { h := &hub{ - logger: logger, - topics: make(map[string]*topic), - clients: make(map[*client]struct{}), - agentsPublishing: make(map[*client]bool), - agents: make(map[string]*settingsv1.CollectionInstance), - agentCh: make(chan *settingsv1.CollectionInstance), - registerCh: make(chan *client), - unregisterCh: make(chan *client), - rulesCh: make(chan func(*hub), 32), + 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) { @@ -123,7 +129,7 @@ func newHub(logger log.Logger, topicsF func(*hub) []*topic) *hub { } // check data for topics to sent -func (h *hub) updateClientTopicsToPublish(client *client) error { +func (h *hub) updateClientTopicsToPublish(ctx context.Context, client *client) error { var payload []*settingsv1.CollectionPayloadData for _, t := range h.topics { clientHash, ok := t.clients[client] @@ -132,7 +138,7 @@ func (h *hub) updateClientTopicsToPublish(client *client) error { } if t.hash == 0 { - t.get(&h.buf) + t.get(ctx, &h.buf) } if clientHash == t.hash { @@ -157,19 +163,19 @@ func (h *hub) updateClientTopicsToPublish(client *client) error { return nil } -// check if agent needs toggle publishing -func (h *hub) updateClientToggleAgentSubscription(client *client) error { - active, ok := h.agentsPublishing[client] +// 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.agentsPublishingActive { + if active != h.instancesPublishingActive { msg := settingsv1.CollectionMessage{ PayloadSubscribe: &settingsv1.CollectionPayloadSubscribe{}, } if !active { - msg.PayloadSubscribe.Topics = []string{"agents"} + msg.PayloadSubscribe.Topics = []string{topicInstances} } data, err := json.Marshal(&msg) @@ -177,86 +183,54 @@ func (h *hub) updateClientToggleAgentSubscription(client *client) error { return err } - level.Debug(client.logger).Log("request agent publishing", "client", fmt.Sprintf("%p", client), "data", string(data)) + level.Debug(client.logger).Log("request instance target publishing", "client", fmt.Sprintf("%p", client), "data", string(data)) client.send <- data - h.agentsPublishing[client] = h.agentsPublishingActive + h.instancesPublishing[client] = h.instancesPublishingActive } return nil } -func (h *hub) updateClient(client *client) { - if err := h.updateClientTopicsToPublish(client); err != 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.updateClientToggleAgentSubscription(client); err != nil { - level.Error(client.logger).Log("msg", "error updating client to subscribe to agents", "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) updateAgents() { - t, ok := h.topics["agents"] +func (h *hub) updateInstances(ctx context.Context) { + t, ok := h.topics[topicInstances] if !ok { return } - t.get(&h.buf) + t.get(ctx, &h.buf) - // update frontend with new agents data + // update frontend with new instance data for client := range t.clients { - h.updateClient(client) + h.updateClient(ctx, client) } } -func (a *hub) insertRule(data *settingsv1.CollectionPayloadRuleInsert) { - a.lck.Lock() - defer a.lck.Unlock() - - if a.nextRuleID == 0 { - for _, r := range a.rules { - if r.Id > a.nextRuleID { - a.nextRuleID = r.Id - } - } - a.nextRuleID++ +func (a *hub) insertRule(ctx context.Context, data *settingsv1.CollectionPayloadRuleInsert) error { + rc, err := CollectionRuleToRelabelConfig(data.Rule) + if err != nil { + return err } - - pos := 0 - // find position to insert - if data.After != nil { - after := *data.After - for i, r := range a.rules { - if r.Id == after { - pos = i + 1 - break - } - } + if err := rc.Validate(); err != nil { + return err } - // overwrite id - rule := data.Rule.CloneVT() - rule.Id = a.nextRuleID - a.nextRuleID++ - - // insert rule to correct position - a.rules = append(a.rules, nil) - copy(a.rules[pos+1:], a.rules[pos:]) - a.rules[pos] = rule - + return a.store.insertRule(ctx, data) } -func (h *hub) deleteRule(id int64) { - h.lck.Lock() - defer h.lck.Unlock() - - for i, r := range h.rules { - if r.Id == id { - h.rules = append(h.rules[:i], h.rules[i+1:]...) - break - } - } +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: @@ -274,32 +248,32 @@ func (h *hub) run(stopCh <-chan struct{}) { } if client.isRuleManager() { - h.agentsPublishing[client] = false + h.instancesPublishing[client] = false } - // check if agents need toggle publishing - agentsTopic, ok := h.topics["agents"] - agentsPublishingRequested := false + // check if instance need toggle publishing + instanceTopic, ok := h.topics[topicInstances] + instancesPublishingRequested := false if ok { - agentsPublishingRequested = len(agentsTopic.clients) != 0 + instancesPublishingRequested = len(instanceTopic.clients) != 0 } - if agentsPublishingRequested != h.agentsPublishingActive { - if agentsPublishingRequested { - slog.Debug("agents publishing has been enabled") + if instancesPublishingRequested != h.instancesPublishingActive { + if instancesPublishingRequested { + slog.Debug("instance targets publishing has been enabled") } else { - slog.Debug("agents publishing has been disabled") + slog.Debug("instance targets publishing has been disabled") } - h.agentsPublishingActive = agentsPublishingRequested - // send message to all agents - for agent := range h.agentsPublishing { - h.updateClient(agent) + h.instancesPublishingActive = instancesPublishingRequested + // send message to all instances + for instance := range h.instancesPublishing { + h.updateClient(ctx, instance) } } - h.updateClient(client) - case agent := <-h.agentCh: - agent.LastUpdated = time.Now().UnixMilli() - h.agents[agent.Hostname] = agent - h.updateAgents() + 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 { @@ -326,44 +300,45 @@ func (h *hub) run(stopCh <-chan struct{}) { } case f := <-h.rulesCh: f(h) - t, ok := h.topics["rules"] + t, ok := h.topics[topicRules] if !ok { continue } - t.get(&h.buf) + t.get(ctx, &h.buf) // update all clients for client := range t.clients { - h.updateClient(client) + h.updateClient(ctx, client) } } } } -func (h *hub) updateRulesPayload(p *settingsv1.CollectionPayloadData) error { - h.lck.RLock() - defer h.lck.RUnlock() - - if cap(p.Rules) < len(h.rules) { - p.Rules = make([]*settingsv1.CollectionRule, 0, len(h.rules)) +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 h.rules { + for _, r := range rules { p.Rules = append(p.Rules, r.CloneVT()) } return nil } -func (h *hub) updateInstancesPayload(p *settingsv1.CollectionPayloadData) error { +func (h *hub) updateInstancesPayload(ctx context.Context, p *settingsv1.CollectionPayloadData) error { h.lck.RLock() defer h.lck.RUnlock() - if cap(p.Instances) < len(h.agents) { - p.Instances = make([]*settingsv1.CollectionInstance, 0, len(h.agents)) + 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.agents { + for _, a := range h.instances { p.Instances = append(p.Instances, a.CloneVT()) } return nil diff --git a/pkg/settings/collection/store.go b/pkg/settings/collection/store.go new file mode 100644 index 0000000000..cd06ee4838 --- /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 { + 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 index 91d95c6334..37df049ed4 100644 --- a/pkg/settings/collection/websocket.go +++ b/pkg/settings/collection/websocket.go @@ -1,6 +1,8 @@ package collection import ( + "context" + "encoding/json" "errors" "fmt" "net" @@ -47,12 +49,16 @@ func (c *client) isRuleManager() bool { 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 { @@ -66,6 +72,24 @@ func (c *client) readPump() { 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.subscribedTopics = p.Topics level.Debug(c.logger).Log("msg", "client subscribing", "topics", fmt.Sprintf("%v", p.Topics)) @@ -73,9 +97,9 @@ func (c *client) readPump() { } else if p := msg.PayloadData; p != nil { for idx := range p.Instances { - a := p.Instances[idx] - level.Debug(c.logger).Log("msg", "received collection instance targets", "hostname", a.Hostname, "targets", len(a.Targets)) - c.hub.agentCh <- a + 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 { @@ -89,7 +113,7 @@ func (c *client) readPump() { level.Info(c.logger).Log("msg", "received rule delete", "id", p.Id) id := p.Id c.hub.rulesCh <- func(h *hub) { - h.deleteRule(id) + handleResult(msg.Id, h.deleteRule(ctx, id)) } } else if p := msg.PayloadRuleInsert; p != nil { if !c.isRuleManager() { @@ -98,7 +122,7 @@ func (c *client) readPump() { } level.Info(c.logger).Log("msg", "received rule insert", "rule", p.Rule) c.hub.rulesCh <- func(h *hub) { - h.insertRule(p) + handleResult(msg.Id, h.insertRule(ctx, p)) } } else { level.Warn(c.logger).Log("msg", "no known message type used") 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) From f663c3efe5447319ed40b028af7905bc93a7d12f Mon Sep 17 00:00:00 2001 From: Christian Simon Date: Thu, 11 Jul 2024 16:47:39 +0100 Subject: [PATCH 08/10] Use yaml.v3 --- pkg/settings/collection/rules.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/settings/collection/rules.go b/pkg/settings/collection/rules.go index fb3626199c..978fe47414 100644 --- a/pkg/settings/collection/rules.go +++ b/pkg/settings/collection/rules.go @@ -7,7 +7,7 @@ import ( jsoniter "github.com/json-iterator/go" "github.com/prometheus/prometheus/model/relabel" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" settingsv1 "github.com/grafana/pyroscope/api/gen/proto/go/settings/v1" ) From 76c6da624fa6ae49481fd48c6ec5c24023cca88f Mon Sep 17 00:00:00 2001 From: Christian Simon Date: Mon, 15 Jul 2024 11:57:17 +0100 Subject: [PATCH 09/10] Properly protect client and hub state --- pkg/settings/collection/hub.go | 2 +- pkg/settings/collection/store.go | 2 +- pkg/settings/collection/websocket.go | 27 +++++++++++++++++++++------ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/pkg/settings/collection/hub.go b/pkg/settings/collection/hub.go index f8d07fa3b6..9c66dbdc2f 100644 --- a/pkg/settings/collection/hub.go +++ b/pkg/settings/collection/hub.go @@ -235,7 +235,7 @@ func (h *hub) run(stopCh <-chan struct{}) { select { case client := <-h.registerCh: h.clients[client] = struct{}{} - for _, topic := range client.subscribedTopics { + for _, topic := range client.SubscribedTopics() { t, ok := h.topics[topic] if !ok { continue diff --git a/pkg/settings/collection/store.go b/pkg/settings/collection/store.go index cd06ee4838..fa497f72d8 100644 --- a/pkg/settings/collection/store.go +++ b/pkg/settings/collection/store.go @@ -141,7 +141,7 @@ func (b *bucketStore) list(ctx context.Context) ([]*settingsv1.CollectionRule, e // serve from cache if available b.cacheLock.RLock() if b.cache != nil { - b.cacheLock.RUnlock() + defer b.cacheLock.RUnlock() return b.cache.Rules, nil } b.cacheLock.RUnlock() diff --git a/pkg/settings/collection/websocket.go b/pkg/settings/collection/websocket.go index 37df049ed4..9177057085 100644 --- a/pkg/settings/collection/websocket.go +++ b/pkg/settings/collection/websocket.go @@ -23,8 +23,10 @@ type client struct { // The websocket connection. conn *websocket.Conn - role Role - subscribedTopics []string + role Role + + subscribedTopics []string + subscribedTopicsMtx sync.Mutex // Buffered channel of outbound messages. send chan []byte @@ -37,6 +39,12 @@ func (c *client) close() { }) } +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 } @@ -91,7 +99,11 @@ func (c *client) readPump() { } if p := msg.PayloadSubscribe; p != nil { - c.subscribedTopics = p.Topics + 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 { @@ -111,9 +123,10 @@ func (c *client) readPump() { continue } level.Info(c.logger).Log("msg", "received rule delete", "id", p.Id) - id := p.Id + ruleID := p.Id + msgID := msg.Id c.hub.rulesCh <- func(h *hub) { - handleResult(msg.Id, h.deleteRule(ctx, id)) + handleResult(msgID, h.deleteRule(ctx, ruleID)) } } else if p := msg.PayloadRuleInsert; p != nil { if !c.isRuleManager() { @@ -121,8 +134,10 @@ func (c *client) readPump() { 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(msg.Id, h.insertRule(ctx, p)) + handleResult(id, h.insertRule(ctx, settings)) } } else { level.Warn(c.logger).Log("msg", "no known message type used") From 11b275e5c8f19060f3271484a805a28e6bb17a66 Mon Sep 17 00:00:00 2001 From: Christian Simon Date: Fri, 26 Jul 2024 15:15:28 +0100 Subject: [PATCH 10/10] Add profilecli client --- cmd/profilecli/collection_rules.go | 369 +++++++++++++++++++++++++++++ cmd/profilecli/main.go | 20 ++ 2 files changed, 389 insertions(+) create mode 100644 cmd/profilecli/collection_rules.go 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) }