go.temporal.io/server/chasm/search_attribute.go

525 LOC · 204 covered · 321 uncovered · 38 ranges · 22043 concepts · 24 introducers · 10883 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the filego.temporal.io/server/api/chasm/v1/message.pb.go · 230 LOCv1/message.pb.gogo.temporal.io/server/api/visibilityservice/v1/request_response.pb.go · 426 LOCv1/request_response.pb.g…go.temporal.io/server/chasm/lib/scheduler/eventlog.go · 97 LOCscheduler/eventlog.gogo.temporal.io/server/chasm/lib/scheduler/gen/schedulerpb/v1/message.pb.go · 871 LOCv1/message.pb.gogo.temporal.io/server/chasm/lib/scheduler/gen/schedulerpb/v1/tasks.pb.go · 367 LOCv1/tasks.pb.gogo.temporal.io/server/chasm/lib/scheduler/generator.go · 115 LOCscheduler/generator.gogo.temporal.io/server/chasm/lib/scheduler/generator_tasks.go · 213 LOCscheduler/generator_task…go.temporal.io/server/chasm/lib/scheduler/invoker.go · 444 LOCscheduler/invoker.gogo.temporal.io/server/chasm/lib/scheduler/scheduler.go · 1081 LOCscheduler/scheduler.gogo.temporal.io/server/chasm/lib/scheduler/util.go · 94 LOCscheduler/util.gogo.temporal.io/server/chasm/library.go · 60 LOCchasm/library.gogo.temporal.io/server/chasm/registrable_component.go · 233 LOCchasm/registrable_compon…go.temporal.io/server/chasm/visibility_value.go · 181 LOCchasm/visibility_value.g…scheduler.go ×19 · 240 introduced LOCscheduler.go ×19TestArchivalQueueFactory · 0 introduced LOCTestArchivalQueueFactoryTestSkipPersistenceIfClean_DeleteUnpersistedNode · 0 introduced LOCTestSkipPersistenceIfCle…TestSkipPersistenceIfClean_NewNode · 0 introduced LOCTestSkipPersistenceIfCle…handler.go ×3 · 41 introduced LOChandler.go ×3Archival_disabled · 0 introduced LOCArchival_disabledsearch_attribute.go ×1 · 7 introduced LOCsearch_attribute.go ×1TestNewTree · 0 introduced LOCTestNewTreeactivity.go ×3 · 12 introduced LOCactivity.go ×3activity.go ×2 · 48 introduced LOCactivity.go ×2activity_state.pb.go ×1 · 4 introduced LOCactivity_state.pb.go ×1activity_state.pb.go ×1 · 4 introduced LOCactivity_state.pb.go ×1activity_state.pb.go ×1 · 4 introduced LOCactivity_state.pb.go ×1visibility_value.go ×1 · 12 introduced LOCvisibility_value.go ×1nexus_operation_processor.go ×1 · 2 introduced LOCnexus_operation_processo…TestRegistry_RegisterNexusServices_Success · 0 introduced LOCTestRegistry_RegisterNex…valid_search_attributes_do_not_panic · 0 introduced LOCvalid_search_attributes_…registrable_component.go ×1 · 2 introduced LOCregistrable_component.go…registry.go ×2 · 4 introduced LOCregistry.go ×2registrable_component.go ×1 · 2 introduced LOCregistrable_component.go…ExecutionStatus_alias_is_allowed_for_CHASM_components · 0 introduced LOCExecutionStatus_alias_is…search_attribute.go ×2 · 5 introduced LOCsearch_attribute.go ×2service_not_found · 0 introduced LOCservice_not_foundTaskQueue_preallocated_search_attribute_is_allowed · 0 introduced LOCTaskQueue_preallocated_s…path_encoder.go ×3 · 7 introduced LOCpath_encoder.go ×3registrable_component.go ×1 · 2 introduced LOCregistrable_component.go…nexus_operation_processor.go ×1 · 2 introduced LOCnexus_operation_processo…valid_input_returns_routing_key,_no_overwrite · 0 introduced LOCvalid_input_returns_rout…invalid_input · 0 introduced LOCinvalid_inputnexus_operation_processor.go ×1 · 2 introduced LOCnexus_operation_processo…GetBool · 0 introduced LOCGetBoolGetFloat64 · 0 introduced LOCGetFloat64GetInt64 · 0 introduced LOCGetInt64GetString · 0 introduced LOCGetStringGetStringSlice · 0 introduced LOCGetStringSliceGetText · 0 introduced LOCGetTextGetTime · 0 introduced LOCGetTimevisibility_value.go ×1 · 2 introduced LOCvisibility_value.go ×1visibility_value.go ×1 · 3 introduced LOCvisibility_value.go ×1visibility_value.go ×1 · 3 introduced LOCvisibility_value.go ×1visibility_value.go ×1 · 2 introduced LOCvisibility_value.go ×1visibility_value.go ×1 · 3 introduced LOCvisibility_value.go ×1visibility_value.go ×1 · 2 introduced LOCvisibility_value.go ×1search_attribute.go ×1 · 4 introduced LOCsearch_attribute.go ×1search_attribute.go ×1 · 2 introduced LOCsearch_attribute.go ×1visibility_value.go ×1 · 3 introduced LOCvisibility_value.go ×1visibility_value.go ×3 · 7 introduced LOCvisibility_value.go ×3visibility_value.go ×2 · 9 introduced LOCvisibility_value.go ×2visibility_value.go ×2 · 9 introduced LOCvisibility_value.go ×2visibility_value.go ×3 · 6 introduced LOCvisibility_value.go ×3fields_iterator.go ×1 · 2 introduced LOCfields_iterator.go ×1search_attribute.go ×1 · 2 introduced LOCsearch_attribute.go ×1search_attribute.go ×1 · 3 introduced LOCsearch_attribute.go ×1search_attribute.go ×1 · 9 introduced LOCsearch_attribute.go ×1search_attribute.go ×2 · 18 introduced LOCsearch_attribute.go ×2visibility_value.go ×1 · 3 introduced LOCvisibility_value.go ×1search_attribute.go ×2 · 3 introduced LOCsearch_attribute.go ×2component_with_Visibility_field · 0 introduced LOCcomponent_with_Visibilit…component_without_Visibility_field · 0 introduced LOCcomponent_without_Visibi…TestTaskValidator · 0 introduced LOCTestTaskValidatorsearch_attribute.go ×1 · 3 introduced LOCsearch_attribute.go ×1Map_type, Field_type, +1 · 0 introduced LOCMap_type, Field_type, +1Non-generic_type · 0 introduced LOCNon-generic_typefields_iterator.go ×1 · 2 introduced LOCfields_iterator.go ×1search_attribute.go ×1 · 3 introduced LOCsearch_attribute.go ×1search_attribute.go ×1 · 2 introduced LOCsearch_attribute.go ×1search_attribute.go ×1 · 2 introduced LOCsearch_attribute.go ×1search_attribute.go ×1 · 5 introduced LOCsearch_attribute.go ×1search_attribute.go ×1 · 9 introduced LOCsearch_attribute.go ×1search_attribute.go ×1 · 7 introduced LOCsearch_attribute.go ×1search_attribute.go ×1 · 7 introduced LOCsearch_attribute.go ×1search_attribute.go ×1 · 9 introduced LOCsearch_attribute.go ×1search_attribute.go ×1 · 9 introduced LOCsearch_attribute.go ×1search_attribute.go ×1 · 9 introduced LOCsearch_attribute.go ×1search_attribute.go ×1 · 3 introduced LOCsearch_attribute.go ×1search_attribute.go ×1 · 9 introduced LOCsearch_attribute.go ×1search_attribute.go ×12 · 121 introduced LOCsearch_attribute.go ×12TestDefaultPathEncoder_EncodeDecode · introduced test · go.temporal.io/server/chasm/TestDefaultPathEncoder_EncodeDecodeTestDefaultPathEncoder_E…TestChasmFieldTypePrefix · introduced test · go.temporal.io/server/chasm/TestFieldsIteratorSuite/TestChasmFieldTypePrefixTestChasmFieldTypePrefixTestChasmMapTypePrefix · introduced test · go.temporal.io/server/chasm/TestFieldsIteratorSuite/TestChasmMapTypePrefixTestChasmMapTypePrefixComponent_with_multiple_data_fields · introduced test · go.temporal.io/server/chasm/TestFieldsIteratorSuite/TestFieldsOf/Component_with_multiple_data_fieldsComponent_with_multiple_…Field_type · introduced test · go.temporal.io/server/chasm/TestFieldsIteratorSuite/TestGenericTypePrefix/Field_typeField_typeMap_type · introduced test · go.temporal.io/server/chasm/TestFieldsIteratorSuite/TestGenericTypePrefix/Map_typeMap_typeMap_type#01 · introduced test · go.temporal.io/server/chasm/TestFieldsIteratorSuite/TestGenericTypePrefix/Map_type#01Map_type#01Non-generic_type · introduced test · go.temporal.io/server/chasm/TestFieldsIteratorSuite/TestGenericTypePrefix/Non-generic_typeNon-generic_typecomponent_with_Visibility_field · introduced test · go.temporal.io/server/chasm/TestFieldsIteratorSuite/TestHasVisibilityField/component_with_Visibility_fieldcomponent_with_Visibilit…component_without_Visibility_field · introduced test · go.temporal.io/server/chasm/TestFieldsIteratorSuite/TestHasVisibilityField/component_without_Visibility_fieldcomponent_without_Visibi…non-struct_type · introduced test · go.temporal.io/server/chasm/TestFieldsIteratorSuite/TestHasVisibilityField/non-struct_typenon-struct_typeTestIsVisibilityValueEqual · introduced test · go.temporal.io/server/chasm/TestIsVisibilityValueEqualTestIsVisibilityValueEqu…TestMapKeyTypesMatchConst · introduced test · go.temporal.io/server/chasm/TestMapKeyTypesMatchConstTestMapKeyTypesMatchCons…EmptyIndexedFields · introduced test · go.temporal.io/server/chasm/TestNewSearchAttributesMapFromProto/EmptyIndexedFieldsEmptyIndexedFieldsInvalidPayload · introduced test · go.temporal.io/server/chasm/TestNewSearchAttributesMapFromProto/InvalidPayloadInvalidPayloadMultipleValueTypes · introduced test · go.temporal.io/server/chasm/TestNewSearchAttributesMapFromProto/MultipleValueTypesMultipleValueTypesNilSearchAttributes · introduced test · go.temporal.io/server/chasm/TestNewSearchAttributesMapFromProto/NilSearchAttributesNilSearchAttributesSingleBoolValue · introduced test · go.temporal.io/server/chasm/TestNewSearchAttributesMapFromProto/SingleBoolValueSingleBoolValueservice_not_found · introduced test · go.temporal.io/server/chasm/TestNexusEndpointProcessor_ProcessInput/service_not_foundservice_not_founddecode_error · introduced test · go.temporal.io/server/chasm/TestNexusOperationProcessor_ProcessInput/decode_errordecode_errorinvalid_input · introduced test · go.temporal.io/server/chasm/TestNexusOperationProcessor_ProcessInput/invalid_inputinvalid_inputvalid_input_returns_routing_key,_no_overwrite · introduced test · go.temporal.io/server/chasm/TestNexusOperationProcessor_ProcessInput/valid_input_returns_routing_key,_no_overwritevalid_input_returns_rout…operation_not_found · introduced test · go.temporal.io/server/chasm/TestNexusServiceProcessor_ProcessInput/operation_not_foundoperation_not_foundTestNewTree · introduced test · go.temporal.io/server/chasm/TestNodeSuite/TestNewTreeTestNewTreeTestSkipPersistenceIfClean_DeleteUnpersistedNode · introduced test · go.temporal.io/server/chasm/TestNodeSuite/TestSkipPersistenceIfClean_DeleteUnpersistedNodeTestSkipPersistenceIfCle…TestSkipPersistenceIfClean_NewNode · introduced test · go.temporal.io/server/chasm/TestNodeSuite/TestSkipPersistenceIfClean_NewNodeTestSkipPersistenceIfCle…CHASM_system_search_attribute_alias_panics · introduced test · go.temporal.io/server/chasm/TestRegistryTestSuite/TestRegistry_RegisterComponents_Error/CHASM_system_search_attribute_alias_panicsCHASM_system_search_attr…ExecutionStatus_alias_is_allowed_for_CHASM_components · introduced test · go.temporal.io/server/chasm/TestRegistryTestSuite/TestRegistry_RegisterComponents_Error/ExecutionStatus_alias_is_allowed_for_CHASM_componentsExecutionStatus_alias_is…TaskQueue_preallocated_search_attribute_is_allowed · introduced test · go.temporal.io/server/chasm/TestRegistryTestSuite/TestRegistry_RegisterComponents_Error/TaskQueue_preallocated_search_attribute_is_allowedTaskQueue_preallocated_s…duplicate_search_attribute_alias_panics · introduced test · go.temporal.io/server/chasm/TestRegistryTestSuite/TestRegistry_RegisterComponents_Error/duplicate_search_attribute_alias_panicsduplicate_search_attribu…duplicate_search_attribute_field_panics · introduced test · go.temporal.io/server/chasm/TestRegistryTestSuite/TestRegistry_RegisterComponents_Error/duplicate_search_attribute_field_panicsduplicate_search_attribu…valid_search_attributes_do_not_panic · introduced test · go.temporal.io/server/chasm/TestRegistryTestSuite/TestRegistry_RegisterComponents_Error/valid_search_attributes_do_not_panicvalid_search_attributes_…TestRegistry_RegisterNexusServiceProcessors · introduced test · go.temporal.io/server/chasm/TestRegistryTestSuite/TestRegistry_RegisterNexusServiceProcessorsTestRegistry_RegisterNex…nexus_service_is_already_registered · introduced test · go.temporal.io/server/chasm/TestRegistryTestSuite/TestRegistry_RegisterNexusServices_Error/nexus_service_is_already_registerednexus_service_is_already…TestRegistry_RegisterNexusServices_Success · introduced test · go.temporal.io/server/chasm/TestRegistryTestSuite/TestRegistry_RegisterNexusServices_SuccessTestRegistry_RegisterNex…GetBool · introduced test · go.temporal.io/server/chasm/TestSearchAttributesMap_Get/GetBoolGetBoolGetFloat64 · introduced test · go.temporal.io/server/chasm/TestSearchAttributesMap_Get/GetFloat64GetFloat64GetInt64 · introduced test · go.temporal.io/server/chasm/TestSearchAttributesMap_Get/GetInt64GetInt64GetString · introduced test · go.temporal.io/server/chasm/TestSearchAttributesMap_Get/GetStringGetStringGetStringSlice · introduced test · go.temporal.io/server/chasm/TestSearchAttributesMap_Get/GetStringSliceGetStringSliceGetText · introduced test · go.temporal.io/server/chasm/TestSearchAttributesMap_Get/GetTextGetTextGetTime · introduced test · go.temporal.io/server/chasm/TestSearchAttributesMap_Get/GetTimeGetTimeNilMap · introduced test · go.temporal.io/server/chasm/TestSearchAttributesMap_Get/NilMapNilMapNotFound · introduced test · go.temporal.io/server/chasm/TestSearchAttributesMap_Get/NotFoundNotFoundTestTaskValidator · introduced test · go.temporal.io/server/chasm/TestTaskValidatorTestTaskValidatorBool · introduced test · go.temporal.io/server/chasm/TestVisibilityValue/BoolBoolFloat64 · introduced test · go.temporal.io/server/chasm/TestVisibilityValue/Float64Float64Int64 · introduced test · go.temporal.io/server/chasm/TestVisibilityValue/Int64Int64String · introduced test · go.temporal.io/server/chasm/TestVisibilityValue/StringStringStringSlice · introduced test · go.temporal.io/server/chasm/TestVisibilityValue/StringSliceStringSliceText · introduced test · go.temporal.io/server/chasm/TestVisibilityValue/TextTextTime · introduced test · go.temporal.io/server/chasm/TestVisibilityValue/TimeTimewith_start_delay · introduced test · go.temporal.io/server/chasm/lib/activity/TestSearchAttributesIncludesExecutionTime/with_start_delaywith_start_delaywithout_start_delay · introduced test · go.temporal.io/server/chasm/lib/activity/TestSearchAttributesIncludesExecutionTime/without_start_delaywithout_start_delayTestArchivalQueueFactory · introduced test · go.temporal.io/server/service/history/TestArchivalQueueFactoryTestArchivalQueueFactoryTestDescribeHistoryHost · introduced test · go.temporal.io/server/service/history/TestDescribeHistoryHostTestDescribeHistoryHostArchival_disabled · introduced test · go.temporal.io/server/service/history/TestQueueModule_ArchivalQueue/Archival_disabledArchival_disabledFocused file · go.temporal.io/server/chasm/search_attribute.go · 525 LOCchasm/search_attribute.g…

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 package chasm
2
3 import (
4 "fmt"
5 "time"
6
7 commonpb "go.temporal.io/api/common/v1"
8 enumspb "go.temporal.io/api/enums/v1"
9 "go.temporal.io/server/common/searchattribute/sadefs"
10 )
11
12 // CHASM Search Attribute User Guide:
13 //
14 // This contains CHASM search attribute field constants. These predefined fields correspond to the exact column name in Visibility storage.
15 // For each root component, search attributes can be mapped from a user defined alias to these fields.
16 // Each component must register its search attributes with the CHASM Registry.
17 //
18 // To define a CHASM search attribute, create this as a package/global scoped variable. Below is an example:
19 // var testComponentCompletedSearchAttribute = NewSearchAttributeBool("Completed", SearchAttributeFieldBool01)
20 // var testComponentFailedSearchAttribute = NewSearchAttributeBool("Failed", SearchAttributeFieldBool02)
21 // var testComponentStartTimeSearchAttribute = NewSearchAttributeTime("StartTime", SearchAttributeFieldDateTime01)
22 // var testComponentCategorySearchAttribute = NewSearchAttributeLowCardinalityKeyword("Category", SearchAttributeFieldLowCardinalityKeyword01)
23 //
24 // Each CHASM search attribute field is associated with a specific indexed value type. The Value() method of a search attribute
25 // specifies the supported value type to set at compile time. eg. DateTime values must be set with a time.Time typed value.
26 //
27 // Low Cardinality Keyword Fields: used for categorical data that support GROUP BY aggregations. Values must be limited to a small number of dimensions.
28 //
29 // Each root component can only use a predefined search attribute field once. Developers should not reassign aliases to different fields.
30 // Reassiging aliases to different fields will result in incorrect visibility query results.
31 //
32 // To register these search attributes with the CHASM Registry, use the WithSearchAttributes() option when creating the component in the library.
33 // eg.
34 // NewRegistrableComponent[T]("testcomponent", WithSearchAttributes(testComponentCompletedSearchAttribute, testComponentStartTimeSearchAttribute))
35 var (
36 SearchAttributeFieldBool01 = newSearchAttributeFieldBool(1)
37 SearchAttributeFieldBool02 = newSearchAttributeFieldBool(2)
38
39 SearchAttributeFieldDateTime01 = newSearchAttributeFieldDateTime(1)
40 SearchAttributeFieldDateTime02 = newSearchAttributeFieldDateTime(2)
41
42 SearchAttributeFieldInt01 = newSearchAttributeFieldInt(1)
43 SearchAttributeFieldInt02 = newSearchAttributeFieldInt(2)
44
45 SearchAttributeFieldDouble01 = newSearchAttributeFieldDouble(1)
46 SearchAttributeFieldDouble02 = newSearchAttributeFieldDouble(2)
47
48 SearchAttributeFieldKeyword01 = newSearchAttributeFieldKeyword(1)
49 SearchAttributeFieldKeyword02 = newSearchAttributeFieldKeyword(2)
50 SearchAttributeFieldKeyword03 = newSearchAttributeFieldKeyword(3)
51 SearchAttributeFieldKeyword04 = newSearchAttributeFieldKeyword(4)
52
53 // SearchAttributeFieldLowCardinalityKeyword is a search attribute field for a low cardinality keyword value.
54 // Used for categorical data that support GROUP BY aggregations, eg. CHASM Execution Statuses.
55 SearchAttributeFieldLowCardinalityKeyword01 = newSearchAttributeFieldLowCardinalityKeyword(1)
56
57 SearchAttributeFieldKeywordList01 = newSearchAttributeFieldKeywordList(1)
58 SearchAttributeFieldKeywordList02 = newSearchAttributeFieldKeywordList(2)
59
60 // CHASM search attribute of type Text is not supported at this moment.
61 // SearchAttributeFieldText01 = newSearchAttributeFieldText(1)
62
63 // Predefined search attributes use their system field names as aliases.
64 // TaskQueue and ExecutionTime are system search attributes; a component may override the value
65 // written to their system column by registering the identity-mapped attribute below and emitting
66 // its own value from SearchAttributes(). See sadefs.IsChasmOverridableSystem.
67 SearchAttributeTaskQueue = newSearchAttributeKeywordByField(sadefs.TaskQueue)
68 SearchAttributeExecutionTime = newSearchAttributeDateTimeByField(sadefs.ExecutionTime)
69 SearchAttributeTemporalChangeVersion = newSearchAttributeKeywordListByField(sadefs.TemporalChangeVersion)
70 SearchAttributeBinaryChecksums = newSearchAttributeKeywordListByField(sadefs.BinaryChecksums)
71 SearchAttributeBuildIds = newSearchAttributeKeywordListByField(sadefs.BuildIds)
72 SearchAttributeBatcherNamespace = newSearchAttributeKeywordByField(sadefs.BatcherNamespace)
73 SearchAttributeBatcherUser = newSearchAttributeKeywordByField(sadefs.BatcherUser)
74 SearchAttributeTemporalScheduledStartTime = newSearchAttributeDateTimeByField(sadefs.TemporalScheduledStartTime)
75 SearchAttributeTemporalScheduledByID = newSearchAttributeKeywordByField(sadefs.TemporalScheduledById)
76 SearchAttributeTemporalSchedulePaused = newSearchAttributeBoolByField(sadefs.TemporalSchedulePaused)
77 SearchAttributeTemporalNamespaceDivision = newSearchAttributeKeywordByField(sadefs.TemporalNamespaceDivision)
78 SearchAttributeTemporalPauseInfo = newSearchAttributeKeywordListByField(sadefs.TemporalPauseInfo)
79 SearchAttributeTemporalReportedProblems = newSearchAttributeKeywordListByField(sadefs.TemporalReportedProblems)
80 SearchAttributeTemporalWorkerDeploymentVersion = newSearchAttributeKeywordByField(sadefs.TemporalWorkerDeploymentVersion)
81 SearchAttributeTemporalWorkflowVersioningBehavior = newSearchAttributeKeywordByField(sadefs.TemporalWorkflowVersioningBehavior)
82 SearchAttributeTemporalWorkerDeployment = newSearchAttributeKeywordByField(sadefs.TemporalWorkerDeployment)
83 SearchAttributeTemporalUsedWorkerDeploymentVersions = newSearchAttributeKeywordListByField(sadefs.TemporalUsedWorkerDeploymentVersions)
84 )
85
86 var (
87 _ SearchAttribute = (*SearchAttributeBool)(nil)
88 _ SearchAttribute = (*SearchAttributeDateTime)(nil)
89 _ SearchAttribute = (*SearchAttributeInt)(nil)
90 _ SearchAttribute = (*SearchAttributeDouble)(nil)
91 _ SearchAttribute = (*SearchAttributeKeyword)(nil)
92 _ SearchAttribute = (*SearchAttributeKeywordList)(nil)
93 _ SearchAttribute = (*SearchAttributeText)(nil)
94
95 _ typedSearchAttribute[bool] = (*SearchAttributeBool)(nil)
96 _ typedSearchAttribute[time.Time] = (*SearchAttributeDateTime)(nil)
97 _ typedSearchAttribute[int64] = (*SearchAttributeInt)(nil)
98 _ typedSearchAttribute[float64] = (*SearchAttributeDouble)(nil)
99 _ typedSearchAttribute[string] = (*SearchAttributeKeyword)(nil)
100 _ typedSearchAttribute[[]string] = (*SearchAttributeKeywordList)(nil)
101 _ typedSearchAttribute[string] = (*SearchAttributeText)(nil)
102 )
103
104 type (
105 // SearchAttribute is a shared interface for all search attribute types. Each type must embed searchAttributeDefinition.
106 SearchAttribute interface {
107 definition() searchAttributeDefinition
108 }
109
110 typedSearchAttribute[T any] interface {
111 SearchAttribute
112 typeMarker(T)
113 }
114
115 searchAttributeDefinition struct {
116 alias string
117 field string
118 valueType enumspb.IndexedValueType
119 }
120
121 // SearchAttributeKeyValue is a key value pair of a search attribute.
122 // Represents the current value of a search attribute in a CHASM Component during a transaction.
123 SearchAttributeKeyValue struct {
124 // Alias refers to the user defined name of the search attribute
125 Alias string
126 // Field refers to a fully formed schema field, which is a Predefined CHASM search attribute
127 Field string
128 // Value refers to the current value of the search attribute. Must support encoding to a Payload.
129 Value VisibilityValue
130 }
131 )
132
133 // SearchAttributeFieldBool is a search attribute field for a boolean value.
134 type SearchAttributeFieldBool struct {
135 field string
136 }
137
138 > func newSearchAttributeFieldBool(index int) SearchAttributeFieldBool { search_attribute.go ×12
139 > return SearchAttributeFieldBool{
140 > field: resolveFieldName(enumspb.INDEXED_VALUE_TYPE_BOOL, index),
141 > }
142 > }
143
144 // SearchAttributeFieldDateTime is a search attribute field for a datetime value.
145 type SearchAttributeFieldDateTime struct {
146 field string
147 }
148
149 > func newSearchAttributeFieldDateTime(index int) SearchAttributeFieldDateTime { search_attribute.go ×12
150 > return SearchAttributeFieldDateTime{
151 > field: resolveFieldName(enumspb.INDEXED_VALUE_TYPE_DATETIME, index),
152 > }
153 > }
154
155 // SearchAttributeFieldInt is a search attribute field for an integer value.
156 type SearchAttributeFieldInt struct {
157 field string
158 }
159
160 > func newSearchAttributeFieldInt(index int) SearchAttributeFieldInt { search_attribute.go ×12
161 > return SearchAttributeFieldInt{
162 > field: resolveFieldName(enumspb.INDEXED_VALUE_TYPE_INT, index),
163 > }
164 > }
165
166 // SearchAttributeFieldDouble is a search attribute field for a double value.
167 type SearchAttributeFieldDouble struct {
168 field string
169 }
170
171 > func newSearchAttributeFieldDouble(index int) SearchAttributeFieldDouble { search_attribute.go ×12
172 > return SearchAttributeFieldDouble{
173 > field: resolveFieldName(enumspb.INDEXED_VALUE_TYPE_DOUBLE, index),
174 > }
175 > }
176
177 // SearchAttributeFieldKeyword is a search attribute field for a keyword value.
178 type SearchAttributeFieldKeyword struct {
179 field string
180 }
181
182 > func newSearchAttributeFieldKeyword(index int) SearchAttributeFieldKeyword { search_attribute.go ×12
183 > return SearchAttributeFieldKeyword{
184 > field: resolveFieldName(enumspb.INDEXED_VALUE_TYPE_KEYWORD, index),
185 > }
186 > }
187
188 > func newSearchAttributeFieldLowCardinalityKeyword(index int) SearchAttributeFieldKeyword { search_attribute.go ×12
189 > return SearchAttributeFieldKeyword{
190 > field: fmt.Sprintf("%s%s%02d", sadefs.ReservedPrefix, "LowCardinalityKeyword", index),
191 > }
192 > }
193
194 // SearchAttributeFieldKeywordList is a search attribute field for a keyword list value.
195 type SearchAttributeFieldKeywordList struct {
196 field string
197 }
198
199 > func newSearchAttributeFieldKeywordList(index int) SearchAttributeFieldKeywordList { search_attribute.go ×12
200 > return SearchAttributeFieldKeywordList{
201 > field: resolveFieldName(enumspb.INDEXED_VALUE_TYPE_KEYWORD_LIST, index),
202 > }
203 > }
204
205 // SearchAttributeFieldText is a search attribute field for a text value.
206 type SearchAttributeFieldText struct {
207 field string
208 }
209
210 > func newSearchAttributeFieldText(index int) SearchAttributeFieldText { search_attribute.go ×1
211 > return SearchAttributeFieldText{
212 > field: resolveFieldName(enumspb.INDEXED_VALUE_TYPE_TEXT, index),
213 > }
214 > }
215
216 > func resolveFieldName(valueType enumspb.IndexedValueType, index int) string { search_attribute.go ×12
217 > // Columns are named like TemporalBool01, TemporalDatetime01, TemporalDouble01, TemporalInt01.
218 > return fmt.Sprintf("%s%s%02d", sadefs.ReservedPrefix, valueType.String(), index)
219 > }
220
221 > func (s searchAttributeDefinition) definition() searchAttributeDefinition { search_attribute.go ×1
222 > return s
223 > }
224
225 // SearchAttributeBool is a search attribute for a boolean value.
226 type SearchAttributeBool struct {
227 searchAttributeDefinition
228 }
229
230 // NewSearchAttributeBool creates a new boolean search attribute given a predefined chasm field
231 > func NewSearchAttributeBool(alias string, boolField SearchAttributeFieldBool) SearchAttributeBool { search_attribute.go ×1
232 > return SearchAttributeBool{
233 > searchAttributeDefinition: searchAttributeDefinition{
234 > alias: alias,
235 > field: boolField.field,
236 > valueType: enumspb.INDEXED_VALUE_TYPE_BOOL,
237 > },
238 > }
239 > }
240
241 > func newSearchAttributeBoolByField(field string) SearchAttributeBool { search_attribute.go ×12
242 > return SearchAttributeBool{
243 > searchAttributeDefinition: searchAttributeDefinition{
244 > alias: field,
245 > field: field,
246 > valueType: enumspb.INDEXED_VALUE_TYPE_BOOL,
247 > },
248 > }
249 > }
250
251 // Value sets the boolean value of the search attribute.
252 > func (s SearchAttributeBool) Value(value bool) SearchAttributeKeyValue { search_attribute.go ×1
253 > return SearchAttributeKeyValue{
254 > Alias: s.alias,
255 > Field: s.field,
256 > Value: VisibilityValueBool(value),
257 > }
258 > }
259
260 func (s SearchAttributeBool) typeMarker(_ bool) {}
261
262 // SearchAttributeDateTime is a search attribute for a datetime value.
263 type SearchAttributeDateTime struct {
264 searchAttributeDefinition
265 }
266
267 // NewSearchAttributeDateTime creates a new date time search attribute given a predefined chasm field
268 > func NewSearchAttributeDateTime(alias string, datetimeField SearchAttributeFieldDateTime) SearchAttributeDateTime { search_attribute.go ×1
269 > return SearchAttributeDateTime{
270 > searchAttributeDefinition: searchAttributeDefinition{
271 > alias: alias,
272 > field: datetimeField.field,
273 > valueType: enumspb.INDEXED_VALUE_TYPE_DATETIME,
274 > },
275 > }
276 > }
277
278 > func newSearchAttributeDateTimeByField(field string) SearchAttributeDateTime { search_attribute.go ×12
279 > return SearchAttributeDateTime{
280 > searchAttributeDefinition: searchAttributeDefinition{
281 > alias: field,
282 > field: field,
283 > valueType: enumspb.INDEXED_VALUE_TYPE_DATETIME,
284 > },
285 > }
286 > }
287
288 // Value sets the date time value of the search attribute.
289 > func (s SearchAttributeDateTime) Value(value time.Time) SearchAttributeKeyValue { search_attribute.go ×1
290 > return SearchAttributeKeyValue{
291 > Alias: s.alias,
292 > Field: s.field,
293 > Value: VisibilityValueTime(value),
294 > }
295 > }
296
297 func (s SearchAttributeDateTime) typeMarker(_ time.Time) {}
298
299 // SearchAttributeInt is a search attribute for an integer value.
300 type SearchAttributeInt struct {
301 searchAttributeDefinition
302 }
303
304 // NewSearchAttributeInt creates a new integer search attribute given a predefined chasm field
305 > func NewSearchAttributeInt(alias string, intField SearchAttributeFieldInt) SearchAttributeInt { search_attribute.go ×1
306 > return SearchAttributeInt{
307 > searchAttributeDefinition: searchAttributeDefinition{
308 > alias: alias,
309 > field: intField.field,
310 > valueType: enumspb.INDEXED_VALUE_TYPE_INT,
311 > },
312 > }
313 > }
314
315 // Value sets the integer value of the search attribute.
316 > func (s SearchAttributeInt) Value(value int64) SearchAttributeKeyValue { scheduler.go ×19
317 > return SearchAttributeKeyValue{
318 > Alias: s.alias,
319 > Field: s.field,
320 > Value: VisibilityValueInt64(value),
321 > }
322 > }
323
324 func (s SearchAttributeInt) typeMarker(_ int64) {}
325
326 // SearchAttributeDouble is a search attribute for a double value.
327 type SearchAttributeDouble struct {
328 searchAttributeDefinition
329 }
330
331 // NewSearchAttributeDouble creates a new double search attribute given a predefined chasm field
332 > func NewSearchAttributeDouble(alias string, doubleField SearchAttributeFieldDouble) SearchAttributeDouble { search_attribute.go ×1
333 > return SearchAttributeDouble{
334 > searchAttributeDefinition: searchAttributeDefinition{
335 > alias: alias,
336 > field: doubleField.field,
337 > valueType: enumspb.INDEXED_VALUE_TYPE_DOUBLE,
338 > },
339 > }
340 > }
341
342 func newSearchAttributeDoubleByField(field string) SearchAttributeDouble {
343 return SearchAttributeDouble{
344 searchAttributeDefinition: searchAttributeDefinition{
345 alias: field,
346 field: field,
347 valueType: enumspb.INDEXED_VALUE_TYPE_DOUBLE,
348 },
349 }
350 }
351
352 // Value sets the double value of the search attribute.
353 func (s SearchAttributeDouble) Value(value float64) SearchAttributeKeyValue {
354 return SearchAttributeKeyValue{
355 Alias: s.alias,
356 Field: s.field,
357 Value: VisibilityValueFloat64(value),
358 }
359 }
360
361 func (s SearchAttributeDouble) typeMarker(_ float64) {}
362
363 // SearchAttributeKeyword is a search attribute for a keyword value.
364 type SearchAttributeKeyword struct {
365 searchAttributeDefinition
366 }
367
368 // NewSearchAttributeKeyword creates a new keyword search attribute given a predefined chasm field
369 > func NewSearchAttributeKeyword(alias string, keywordField SearchAttributeFieldKeyword) SearchAttributeKeyword { search_attribute.go ×1
370 > return SearchAttributeKeyword{
371 > searchAttributeDefinition: searchAttributeDefinition{
372 > alias: alias,
373 > field: keywordField.field,
374 > valueType: enumspb.INDEXED_VALUE_TYPE_KEYWORD,
375 > },
376 > }
377 > }
378
379 > func newSearchAttributeKeywordByField(field string) SearchAttributeKeyword { search_attribute.go ×12
380 > return SearchAttributeKeyword{
381 > searchAttributeDefinition: searchAttributeDefinition{
382 > alias: field,
383 > field: field,
384 > valueType: enumspb.INDEXED_VALUE_TYPE_KEYWORD,
385 > },
386 > }
387 > }
388
389 // Value sets the string value of the search attribute.
390 > func (s SearchAttributeKeyword) Value(value string) SearchAttributeKeyValue { search_attribute.go ×1
391 > return SearchAttributeKeyValue{
392 > Alias: s.alias,
393 > Field: s.field,
394 > Value: VisibilityValueKeyword(value),
395 > }
396 > }
397
398 func (s SearchAttributeKeyword) typeMarker(_ string) {}
399
400 // SearchAttributeKeywordList is a search attribute for a keyword list value.
401 type SearchAttributeKeywordList struct {
402 searchAttributeDefinition
403 }
404
405 // NewSearchAttributeKeywordList creates a new keyword list search attribute given a predefined chasm field
406 > func NewSearchAttributeKeywordList(alias string, keywordListField SearchAttributeFieldKeywordList) SearchAttributeKeywordList { search_attribute.go ×2
407 > return SearchAttributeKeywordList{
408 > searchAttributeDefinition: searchAttributeDefinition{
409 > alias: alias,
410 > field: keywordListField.field,
411 > valueType: enumspb.INDEXED_VALUE_TYPE_KEYWORD_LIST,
412 > },
413 > }
414 > }
415
416 > func newSearchAttributeKeywordListByField(field string) SearchAttributeKeywordList { search_attribute.go ×12
417 > return SearchAttributeKeywordList{
418 > searchAttributeDefinition: searchAttributeDefinition{
419 > alias: field,
420 > field: field,
421 > valueType: enumspb.INDEXED_VALUE_TYPE_KEYWORD_LIST,
422 > },
423 > }
424 > }
425
426 // Value sets the string list value of the search attribute.
427 func (s SearchAttributeKeywordList) Value(value []string) SearchAttributeKeyValue {
428 return SearchAttributeKeyValue{
429 Alias: s.alias,
430 Field: s.field,
431 Value: VisibilityValueStringSlice(value),
432 }
433 }
434
435 func (s SearchAttributeKeywordList) typeMarker(_ []string) {}
436
437 // SearchAttributeText is a search attribute for a text value.
438 type SearchAttributeText struct {
439 searchAttributeDefinition
440 }
441
442 // NewSearchAttributeText creates a new text search attribute given a predefined chasm field
443 > func NewSearchAttributeText(alias string, textField SearchAttributeFieldText) SearchAttributeText { search_attribute.go ×2
444 > return SearchAttributeText{
445 > searchAttributeDefinition: searchAttributeDefinition{
446 > alias: alias,
447 > field: textField.field,
448 > valueType: enumspb.INDEXED_VALUE_TYPE_TEXT,
449 > },
450 > }
451 > }
452
453 func newSearchAttributeTextByField(field string) SearchAttributeText {
454 return SearchAttributeText{
455 searchAttributeDefinition: searchAttributeDefinition{
456 alias: field,
457 field: field,
458 valueType: enumspb.INDEXED_VALUE_TYPE_TEXT,
459 },
460 }
461 }
462
463 // Value sets the string value of the search attribute.
464 func (s SearchAttributeText) Value(value string) SearchAttributeKeyValue {
465 return SearchAttributeKeyValue{
466 Alias: s.alias,
467 Field: s.field,
468 Value: VisibilityValueText(value),
469 }
470 }
471
472 func (s SearchAttributeText) typeMarker(_ string) {}
473
474 // SearchAttributesMap wraps search attribute values with type-safe access.
475 type SearchAttributesMap struct {
476 values map[string]VisibilityValue
477 }
478
479 // NewSearchAttributesMap creates a new SearchAttributeMap from raw values.
480 > func NewSearchAttributesMap(values map[string]VisibilityValue) SearchAttributesMap { search_attribute.go ×1
481 > return SearchAttributesMap{values: values}
482 > }
483
484 // newSearchAttributesMapFromProto creates a new SearchAttributesMap from commonpb.SearchAttributes.
485 func newSearchAttributesMapFromProto(
486 searchAttributes *commonpb.SearchAttributes,
487 > ) (SearchAttributesMap, error) { search_attribute.go ×1
488 > if len(searchAttributes.GetIndexedFields()) == 0 {
489 > return SearchAttributesMap{}, nil search_attribute.go ×1
490 > }
491 > result := SearchAttributesMap{ search_attribute.go ×1
492 > values: make(map[string]VisibilityValue),
493 > }
494 > for saName, saPayload := range searchAttributes.IndexedFields {
495 > value, err := visibilityValueFromPayload(saPayload)
496 > if err != nil {
497 > return SearchAttributesMap{}, err search_attribute.go ×1
498 > }
499 > result.values[saName] = value search_attribute.go ×2
500 }
501 > return result, nil search_attribute.go ×2
502 }
503
504 // SearchAttributeValue returns the value for a given SearchAttribute with compile-time type safety.
505 // The return type T is inferred from the SearchAttribute's type parameter.
506 // For example, SearchAttributeBool will return a bool value.
507 // If the value is not found or the type does not match, the zero value for the type T is returned and the second return value is false.
508 > func SearchAttributeValue[T any](m SearchAttributesMap, sa typedSearchAttribute[T]) (val T, ok bool) { search_attribute.go ×1
509 > var zero T
510 > if len(m.values) == 0 {
511 > return zero, false search_attribute.go ×1
512 > }
513
514 > alias := sa.definition().alias search_attribute.go ×1
515 > visibilityValue, exists := m.values[alias]
516 > if !exists {
517 > return zero, false search_attribute.go ×1
518 > }
519
520 > finalVal, ok := visibilityValue.Value().(T) search_attribute.go ×2
521 > if !ok {
522 return zero, false
523 }
524 > return finalVal, true search_attribute.go ×2
525 }