From cbdb8d79596b08dc6baf4c79a94957adcfb1f5db Mon Sep 17 00:00:00 2001 From: rodrigozhou Date: Mon, 30 Jan 2023 13:32:42 -0800 Subject: [PATCH] Add custom search attributes alias map to namespace config --- api/persistence/v1/namespaces.pb.go | 329 ++++++++++++++---- common/namespace/namespace.go | 45 ++- common/util/util.go | 12 + .../api/persistence/v1/namespaces.proto | 1 + 4 files changed, 321 insertions(+), 66 deletions(-) diff --git a/api/persistence/v1/namespaces.pb.go b/api/persistence/v1/namespaces.pb.go index 448aa68d942..cc1f1849110 100644 --- a/api/persistence/v1/namespaces.pb.go +++ b/api/persistence/v1/namespaces.pb.go @@ -233,13 +233,14 @@ func (m *NamespaceInfo) GetData() map[string]string { } type NamespaceConfig struct { - Retention *time.Duration `protobuf:"bytes,1,opt,name=retention,proto3,stdduration" json:"retention,omitempty"` - ArchivalBucket string `protobuf:"bytes,2,opt,name=archival_bucket,json=archivalBucket,proto3" json:"archival_bucket,omitempty"` - BadBinaries *v11.BadBinaries `protobuf:"bytes,3,opt,name=bad_binaries,json=badBinaries,proto3" json:"bad_binaries,omitempty"` - HistoryArchivalState v1.ArchivalState `protobuf:"varint,4,opt,name=history_archival_state,json=historyArchivalState,proto3,enum=temporal.api.enums.v1.ArchivalState" json:"history_archival_state,omitempty"` - HistoryArchivalUri string `protobuf:"bytes,5,opt,name=history_archival_uri,json=historyArchivalUri,proto3" json:"history_archival_uri,omitempty"` - VisibilityArchivalState v1.ArchivalState `protobuf:"varint,6,opt,name=visibility_archival_state,json=visibilityArchivalState,proto3,enum=temporal.api.enums.v1.ArchivalState" json:"visibility_archival_state,omitempty"` - VisibilityArchivalUri string `protobuf:"bytes,7,opt,name=visibility_archival_uri,json=visibilityArchivalUri,proto3" json:"visibility_archival_uri,omitempty"` + Retention *time.Duration `protobuf:"bytes,1,opt,name=retention,proto3,stdduration" json:"retention,omitempty"` + ArchivalBucket string `protobuf:"bytes,2,opt,name=archival_bucket,json=archivalBucket,proto3" json:"archival_bucket,omitempty"` + BadBinaries *v11.BadBinaries `protobuf:"bytes,3,opt,name=bad_binaries,json=badBinaries,proto3" json:"bad_binaries,omitempty"` + HistoryArchivalState v1.ArchivalState `protobuf:"varint,4,opt,name=history_archival_state,json=historyArchivalState,proto3,enum=temporal.api.enums.v1.ArchivalState" json:"history_archival_state,omitempty"` + HistoryArchivalUri string `protobuf:"bytes,5,opt,name=history_archival_uri,json=historyArchivalUri,proto3" json:"history_archival_uri,omitempty"` + VisibilityArchivalState v1.ArchivalState `protobuf:"varint,6,opt,name=visibility_archival_state,json=visibilityArchivalState,proto3,enum=temporal.api.enums.v1.ArchivalState" json:"visibility_archival_state,omitempty"` + VisibilityArchivalUri string `protobuf:"bytes,7,opt,name=visibility_archival_uri,json=visibilityArchivalUri,proto3" json:"visibility_archival_uri,omitempty"` + CustomSearchAttributeAliases map[string]string `protobuf:"bytes,8,rep,name=custom_search_attribute_aliases,json=customSearchAttributeAliases,proto3" json:"custom_search_attribute_aliases,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } func (m *NamespaceConfig) Reset() { *m = NamespaceConfig{} } @@ -323,6 +324,13 @@ func (m *NamespaceConfig) GetVisibilityArchivalUri() string { return "" } +func (m *NamespaceConfig) GetCustomSearchAttributeAliases() map[string]string { + if m != nil { + return m.CustomSearchAttributeAliases + } + return nil +} + type NamespaceReplicationConfig struct { ActiveClusterName string `protobuf:"bytes,1,opt,name=active_cluster_name,json=activeClusterName,proto3" json:"active_cluster_name,omitempty"` Clusters []string `protobuf:"bytes,2,rep,name=clusters,proto3" json:"clusters,omitempty"` @@ -447,6 +455,7 @@ func init() { proto.RegisterType((*NamespaceInfo)(nil), "temporal.server.api.persistence.v1.NamespaceInfo") proto.RegisterMapType((map[string]string)(nil), "temporal.server.api.persistence.v1.NamespaceInfo.DataEntry") proto.RegisterType((*NamespaceConfig)(nil), "temporal.server.api.persistence.v1.NamespaceConfig") + proto.RegisterMapType((map[string]string)(nil), "temporal.server.api.persistence.v1.NamespaceConfig.CustomSearchAttributeAliasesEntry") proto.RegisterType((*NamespaceReplicationConfig)(nil), "temporal.server.api.persistence.v1.NamespaceReplicationConfig") proto.RegisterType((*FailoverStatus)(nil), "temporal.server.api.persistence.v1.FailoverStatus") } @@ -456,63 +465,67 @@ func init() { } var fileDescriptor_0486d93c2107d6bc = []byte{ - // 889 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0x4d, 0x6f, 0x1b, 0x45, - 0x18, 0xf6, 0xda, 0x8e, 0x5b, 0x4f, 0x1a, 0xa7, 0x19, 0x02, 0x75, 0x8d, 0xd8, 0x1a, 0x8b, 0x90, - 0x70, 0x59, 0x93, 0x04, 0x01, 0x22, 0x2a, 0x12, 0x6e, 0x82, 0xa8, 0x40, 0x45, 0x5a, 0x28, 0x87, - 0x4a, 0x68, 0x19, 0xef, 0x8e, 0xdd, 0xa1, 0xeb, 0x99, 0xd5, 0xcc, 0xec, 0xa2, 0xdc, 0x10, 0x07, - 0xce, 0x3d, 0xf2, 0x13, 0x38, 0xf3, 0x2b, 0x38, 0xe6, 0xd8, 0x1b, 0xc4, 0xb9, 0x70, 0xe0, 0xd0, - 0x23, 0x47, 0x34, 0x1f, 0xbb, 0xeb, 0xcd, 0x87, 0x1a, 0xdf, 0x76, 0xde, 0xf7, 0x79, 0x9e, 0x79, - 0xe7, 0xfd, 0x5a, 0xb0, 0x2f, 0xf1, 0x2c, 0x61, 0x1c, 0xc5, 0x43, 0x81, 0x79, 0x86, 0xf9, 0x10, - 0x25, 0x64, 0x98, 0x60, 0x2e, 0x88, 0x90, 0x98, 0x86, 0x78, 0x98, 0xed, 0x0e, 0x29, 0x9a, 0x61, - 0x91, 0xa0, 0x10, 0x0b, 0x2f, 0xe1, 0x4c, 0x32, 0x38, 0xc8, 0x49, 0x9e, 0x21, 0x79, 0x28, 0x21, - 0xde, 0x02, 0xc9, 0xcb, 0x76, 0x7b, 0xee, 0x94, 0xb1, 0x69, 0x8c, 0x87, 0x9a, 0x31, 0x4e, 0x27, - 0xc3, 0x28, 0xe5, 0x48, 0x12, 0x46, 0x8d, 0x46, 0xef, 0xde, 0x79, 0xbf, 0x24, 0x33, 0x2c, 0x24, - 0x9a, 0x25, 0x16, 0xf0, 0x76, 0x84, 0x13, 0x4c, 0x23, 0x4c, 0x43, 0x82, 0xc5, 0x70, 0xca, 0xa6, - 0x4c, 0xdb, 0xf5, 0x97, 0x85, 0x6c, 0x15, 0xc1, 0xab, 0xa8, 0x31, 0x4d, 0x67, 0xa2, 0x12, 0xaf, - 0x85, 0x6d, 0x57, 0x60, 0x85, 0x57, 0x41, 0x67, 0x58, 0x08, 0x34, 0xb5, 0xc0, 0xc1, 0x7f, 0x0d, - 0xb0, 0xfe, 0x28, 0x77, 0x1f, 0x62, 0x89, 0x48, 0x0c, 0x8f, 0x40, 0x93, 0xd0, 0x09, 0xeb, 0x3a, - 0x7d, 0x67, 0x67, 0x75, 0x6f, 0xd7, 0x7b, 0xf5, 0xd3, 0xbd, 0x42, 0xe2, 0x21, 0x9d, 0x30, 0x5f, - 0xd3, 0xe1, 0x97, 0xa0, 0x15, 0x32, 0x3a, 0x21, 0xd3, 0x6e, 0x5d, 0x0b, 0xed, 0x2f, 0x25, 0xf4, - 0x40, 0x53, 0x7d, 0x2b, 0x01, 0x67, 0x00, 0x72, 0x9c, 0xc4, 0x24, 0xd4, 0x09, 0x0d, 0xac, 0x70, - 0x43, 0x0b, 0x7f, 0xba, 0x94, 0xb0, 0x5f, 0xca, 0xd8, 0x3b, 0x36, 0xf8, 0x79, 0x13, 0xdc, 0x02, - 0x1d, 0x73, 0x45, 0x90, 0x29, 0x19, 0x46, 0xbb, 0xcd, 0xbe, 0xb3, 0xd3, 0xf0, 0xd7, 0x8c, 0xf5, - 0x3b, 0x63, 0x84, 0x23, 0xf0, 0xd6, 0x04, 0x91, 0x98, 0x65, 0x98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, 0x3f, 0x00, 0x00, 0xff, - 0xff, 0xd9, 0x7a, 0x34, 0xae, 0x2e, 0x08, 0x00, 0x00, + // 949 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xf6, 0xda, 0x8e, 0x5b, 0x4f, 0x1a, 0xa7, 0x19, 0x02, 0x75, 0x0d, 0x6c, 0x5c, 0x8b, 0x90, + 0x70, 0x59, 0x93, 0x04, 0x01, 0x22, 0x2a, 0x52, 0x9c, 0x04, 0x51, 0x81, 0x5a, 0x69, 0x4b, 0x39, + 0x54, 0x42, 0xcb, 0x78, 0x77, 0xec, 0x0e, 0x5d, 0xef, 0xac, 0x66, 0x66, 0x17, 0xe5, 0x86, 0x38, + 0x70, 0xee, 0x91, 0x03, 0x7f, 0x00, 0x67, 0xfe, 0x0a, 0x8e, 0x39, 0xf6, 0x80, 0x04, 0x71, 0x2e, + 0x1c, 0x7b, 0xe4, 0x88, 0xe6, 0xc7, 0xee, 0x7a, 0x93, 0x98, 0xd6, 0xdc, 0x3c, 0xef, 0x7d, 0xdf, + 0x37, 0x6f, 0xde, 0xf7, 0xf6, 0xc9, 0x60, 0x4f, 0xe0, 0x49, 0x4c, 0x19, 0x0a, 0xfb, 0x1c, 0xb3, + 0x14, 0xb3, 0x3e, 0x8a, 0x49, 0x3f, 0xc6, 0x8c, 0x13, 0x2e, 0x70, 0xe4, 0xe3, 0x7e, 0xba, 0xd3, + 0x8f, 0xd0, 0x04, 0xf3, 0x18, 0xf9, 0x98, 0x3b, 0x31, 0xa3, 0x82, 0xc2, 0x5e, 0x46, 0x72, 0x34, + 0xc9, 0x41, 0x31, 0x71, 0x66, 0x48, 0x4e, 0xba, 0xd3, 0xb1, 0xc7, 0x94, 0x8e, 0x43, 0xdc, 0x57, + 0x8c, 0x61, 0x32, 0xea, 0x07, 0x09, 0x43, 0x82,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4, 0xfa, 0xb1, 0xd5, 0xfb, 0x63, 0x69, 0xe6, 0x7b, 0x31, 0xc3, 0x72, + 0x17, 0x34, 0x19, 0x16, 0x38, 0x52, 0x6f, 0xd2, 0x1f, 0xcd, 0xed, 0x4b, 0x76, 0x1c, 0x99, 0x5d, + 0x30, 0xa8, 0xff, 0x2c, 0xdd, 0x28, 0x18, 0x70, 0x0b, 0xac, 0x22, 0xe6, 0x3f, 0x21, 0x29, 0x0a, + 0xbd, 0x61, 0xe2, 0x3f, 0xc5, 0xc2, 0x5c, 0xdb, 0xca, 0xc2, 0x03, 0x15, 0x85, 0xf7, 0xc0, 0x8d, + 0x21, 0x0a, 0xbc, 0x21, 0x89, 0x10, 0x23, 0x98, 0x9b, 0xe9, 0x7f, 0xb7, 0xec, 0x4a, 0xb1, 0x09, + 0xd2, 0x1d, 0x67, 0x80, 0x82, 0x81, 0x41, 0xbb, 0xcb, 0xc3, 0xe2, 0x00, 0x1f, 0x83, 0x37, 0x9e, + 0x10, 0x2e, 0x28, 0x3b, 0xf1, 0xf2, 0xbb, 0xb5, 0xd5, 0x75, 0x65, 0xf5, 0x3b, 0x73, 0xac, 0x3e, + 0x30, 0x60, 0xed, 0xf4, 0xba, 0xd1, 0x28, 0x45, 0xe1, 0xfb, 0x60, 0xfd, 0x92, 0x76, 0xc2, 0x88, + 0x71, 0x14, 0x5e, 0xe0, 0x3c, 0x62, 0x04, 0x7e, 0x0b, 0x6e, 0xa7, 0x84, 0x93, 0x21, 0x09, 0x89, + 0xb8, 0x54, 0x50, 0x63, 0x81, 0x82, 0x6e, 0x15, 0x32, 0xe5, 0x9a, 0x3e, 0x04, 0xb7, 0xae, 0xba, + 0x41, 0x96, 0x75, 0x4d, 0x95, 0xf5, 0xfa, 0x65, 0xa6, 0xac, 0xec, 0x17, 0x0b, 0x6c, 0xf8, 0x09, + 0x17, 0x74, 0xe2, 0x71, 0x2c, 0x69, 0x1e, 0x12, 0x82, 0x91, 0x61, 0x22, 0xb0, 0x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0xfd, 0x3d, 0xb5, 0x2b, 0x2f, 0xa6, 0xb6, 0xf5, 0xec, 0xdc, 0xae, 0x9c, 0x9e, 0xdb, + 0x95, 0xe7, 0xe7, 0x76, 0xe5, 0xf1, 0x07, 0x63, 0x5a, 0x74, 0x80, 0xd0, 0xf9, 0xff, 0x72, 0xf6, + 0x67, 0x8e, 0xc3, 0x86, 0x2a, 0x7f, 0xef, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xee, 0xc8, 0xf5, + 0xd7, 0x1e, 0x09, 0x00, 0x00, } func (this *NamespaceDetail) Equal(that interface{}) bool { @@ -651,6 +664,14 @@ func (this *NamespaceConfig) Equal(that interface{}) bool { if this.VisibilityArchivalUri != that1.VisibilityArchivalUri { return false } + if len(this.CustomSearchAttributeAliases) != len(that1.CustomSearchAttributeAliases) { + return false + } + for i := range this.CustomSearchAttributeAliases { + if this.CustomSearchAttributeAliases[i] != that1.CustomSearchAttributeAliases[i] { + return false + } + } return true } func (this *NamespaceReplicationConfig) Equal(that interface{}) bool { @@ -780,7 +801,7 @@ func (this *NamespaceConfig) GoString() string { if this == nil { return "nil" } - s := make([]string, 0, 11) + s := make([]string, 0, 12) s = append(s, "&persistence.NamespaceConfig{") s = append(s, "Retention: "+fmt.Sprintf("%#v", this.Retention)+",\n") s = append(s, "ArchivalBucket: "+fmt.Sprintf("%#v", this.ArchivalBucket)+",\n") @@ -791,6 +812,19 @@ func (this *NamespaceConfig) GoString() string { s = append(s, "HistoryArchivalUri: "+fmt.Sprintf("%#v", this.HistoryArchivalUri)+",\n") s = append(s, "VisibilityArchivalState: "+fmt.Sprintf("%#v", this.VisibilityArchivalState)+",\n") s = append(s, "VisibilityArchivalUri: "+fmt.Sprintf("%#v", this.VisibilityArchivalUri)+",\n") + keysForCustomSearchAttributeAliases := make([]string, 0, len(this.CustomSearchAttributeAliases)) + for k, _ := range this.CustomSearchAttributeAliases { + keysForCustomSearchAttributeAliases = append(keysForCustomSearchAttributeAliases, k) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForCustomSearchAttributeAliases) + mapStringForCustomSearchAttributeAliases := "map[string]string{" + for _, k := range keysForCustomSearchAttributeAliases { + mapStringForCustomSearchAttributeAliases += fmt.Sprintf("%#v: %#v,", k, this.CustomSearchAttributeAliases[k]) + } + mapStringForCustomSearchAttributeAliases += "}" + if this.CustomSearchAttributeAliases != nil { + s = append(s, "CustomSearchAttributeAliases: "+mapStringForCustomSearchAttributeAliases+",\n") + } s = append(s, "}") return strings.Join(s, "") } @@ -1007,6 +1041,25 @@ func (m *NamespaceConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.CustomSearchAttributeAliases) > 0 { + for k := range m.CustomSearchAttributeAliases { + v := m.CustomSearchAttributeAliases[k] + baseI := i + i -= len(v) + copy(dAtA[i:], v) + i = encodeVarintNamespaces(dAtA, i, uint64(len(v))) + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintNamespaces(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintNamespaces(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x42 + } + } if len(m.VisibilityArchivalUri) > 0 { i -= len(m.VisibilityArchivalUri) copy(dAtA[i:], m.VisibilityArchivalUri) @@ -1272,6 +1325,14 @@ func (m *NamespaceConfig) Size() (n int) { if l > 0 { n += 1 + l + sovNamespaces(uint64(l)) } + if len(m.CustomSearchAttributeAliases) > 0 { + for k, v := range m.CustomSearchAttributeAliases { + _ = k + _ = v + mapEntrySize := 1 + len(k) + sovNamespaces(uint64(len(k))) + 1 + len(v) + sovNamespaces(uint64(len(v))) + n += mapEntrySize + 1 + sovNamespaces(uint64(mapEntrySize)) + } + } return n } @@ -1370,6 +1431,16 @@ func (this *NamespaceConfig) String() string { if this == nil { return "nil" } + keysForCustomSearchAttributeAliases := make([]string, 0, len(this.CustomSearchAttributeAliases)) + for k, _ := range this.CustomSearchAttributeAliases { + keysForCustomSearchAttributeAliases = append(keysForCustomSearchAttributeAliases, k) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForCustomSearchAttributeAliases) + mapStringForCustomSearchAttributeAliases := "map[string]string{" + for _, k := range keysForCustomSearchAttributeAliases { + mapStringForCustomSearchAttributeAliases += fmt.Sprintf("%v: %v,", k, this.CustomSearchAttributeAliases[k]) + } + mapStringForCustomSearchAttributeAliases += "}" s := strings.Join([]string{`&NamespaceConfig{`, `Retention:` + strings.Replace(fmt.Sprintf("%v", this.Retention), "Duration", "types.Duration", 1) + `,`, `ArchivalBucket:` + fmt.Sprintf("%v", this.ArchivalBucket) + `,`, @@ -1378,6 +1449,7 @@ func (this *NamespaceConfig) String() string { `HistoryArchivalUri:` + fmt.Sprintf("%v", this.HistoryArchivalUri) + `,`, `VisibilityArchivalState:` + fmt.Sprintf("%v", this.VisibilityArchivalState) + `,`, `VisibilityArchivalUri:` + fmt.Sprintf("%v", this.VisibilityArchivalUri) + `,`, + `CustomSearchAttributeAliases:` + mapStringForCustomSearchAttributeAliases + `,`, `}`, }, "") return s @@ -2235,6 +2307,133 @@ func (m *NamespaceConfig) Unmarshal(dAtA []byte) error { } m.VisibilityArchivalUri = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CustomSearchAttributeAliases", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNamespaces + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthNamespaces + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthNamespaces + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.CustomSearchAttributeAliases == nil { + m.CustomSearchAttributeAliases = make(map[string]string) + } + var mapkey string + var mapvalue string + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNamespaces + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNamespaces + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthNamespaces + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthNamespaces + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var stringLenmapvalue uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNamespaces + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapvalue |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapvalue := int(stringLenmapvalue) + if intStringLenmapvalue < 0 { + return ErrInvalidLengthNamespaces + } + postStringIndexmapvalue := iNdEx + intStringLenmapvalue + if postStringIndexmapvalue < 0 { + return ErrInvalidLengthNamespaces + } + if postStringIndexmapvalue > l { + return io.ErrUnexpectedEOF + } + mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue]) + iNdEx = postStringIndexmapvalue + } else { + iNdEx = entryPreIndex + skippy, err := skipNamespaces(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthNamespaces + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.CustomSearchAttributeAliases[mapkey] = mapvalue + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipNamespaces(dAtA[iNdEx:]) diff --git a/common/namespace/namespace.go b/common/namespace/namespace.go index 644c27efcfe..49071ab4b45 100644 --- a/common/namespace/namespace.go +++ b/common/namespace/namespace.go @@ -25,14 +25,18 @@ package namespace import ( + "fmt" "time" "github.com/google/uuid" + "golang.org/x/exp/maps" + enumspb "go.temporal.io/api/enums/v1" namespacepb "go.temporal.io/api/namespace/v1" - + "go.temporal.io/api/serviceerror" persistencespb "go.temporal.io/server/api/persistence/v1" "go.temporal.io/server/common/persistence" + "go.temporal.io/server/common/util" ) type ( @@ -67,6 +71,13 @@ type ( isGlobalNamespace bool failoverNotificationVersion int64 notificationVersion int64 + + customSearchAttributesMapper CustomSearchAttributesMapper + } + + CustomSearchAttributesMapper struct { + fieldToAlias map[string]string + aliasToField map[string]string } ) @@ -89,6 +100,10 @@ func FromPersistentState(record *persistence.GetNamespaceResponse) *Namespace { isGlobalNamespace: record.IsGlobalNamespace, failoverNotificationVersion: record.Namespace.FailoverNotificationVersion, notificationVersion: record.NotificationVersion, + customSearchAttributesMapper: CustomSearchAttributesMapper{ + fieldToAlias: record.Namespace.Config.CustomSearchAttributeAliases, + aliasToField: util.InverseMap(record.Namespace.Config.CustomSearchAttributeAliases), + }, } } @@ -250,6 +265,10 @@ func (ns *Namespace) Retention() time.Duration { return *ns.config.Retention } +func (ns *Namespace) CustomSearchAttributesMapper() CustomSearchAttributesMapper { + return ns.customSearchAttributesMapper +} + // Error returns the reason associated with this bad binary. func (e BadBinaryError) Error() string { return e.info.Reason @@ -290,3 +309,27 @@ func (n Name) String() string { func (n Name) IsEmpty() bool { return n == EmptyName } + +func (m *CustomSearchAttributesMapper) GetAlias(fieldName string, namespace string) (string, error) { + alias, ok := m.fieldToAlias[fieldName] + if !ok { + return "", serviceerror.NewInvalidArgument( + fmt.Sprintf("Namespace %s has no mapping defined for field name %s", namespace, fieldName), + ) + } + return alias, nil +} + +func (m *CustomSearchAttributesMapper) GetFieldName(alias string, namespace string) (string, error) { + fieldName, ok := m.aliasToField[alias] + if !ok { + return "", serviceerror.NewInvalidArgument( + fmt.Sprintf("Namespace %s has no mapping defined for search attribute %s", namespace, fieldName), + ) + } + return fieldName, nil +} + +func (m *CustomSearchAttributesMapper) FieldToAliasMap() map[string]string { + return maps.Clone(m.fieldToAlias) +} diff --git a/common/util/util.go b/common/util/util.go index 062109c2580..19c8f81a770 100644 --- a/common/util/util.go +++ b/common/util/util.go @@ -98,3 +98,15 @@ func CloneMapNonNil[M ~map[K]V, K comparable, V any](m M) M { } return m } + +// InverseMap creates the inverse map, ie., for a key-value map, it builds the value-key map. +func InverseMap[M ~map[K]V, K, V comparable](m M) map[V]K { + if m == nil { + return nil + } + invm := make(map[V]K, len(m)) + for k, v := range m { + invm[v] = k + } + return invm +} diff --git a/proto/internal/temporal/server/api/persistence/v1/namespaces.proto b/proto/internal/temporal/server/api/persistence/v1/namespaces.proto index 487182bb570..5cd6a145c1b 100644 --- a/proto/internal/temporal/server/api/persistence/v1/namespaces.proto +++ b/proto/internal/temporal/server/api/persistence/v1/namespaces.proto @@ -59,6 +59,7 @@ message NamespaceConfig { string history_archival_uri = 5; temporal.api.enums.v1.ArchivalState visibility_archival_state = 6; string visibility_archival_uri = 7; + map custom_search_attribute_aliases = 8; } message NamespaceReplicationConfig {