searchattribute

package
v1.32.1-x.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Overview

Package searchattribute is a generated GoMock package.

Package searchattribute is a generated GoMock package.

Index

Constants

View Source
const (
	MetadataType = "type"
)

Variables

View Source
var (

	// ScheduleId is mapped to Keyword10 for tests
	TestScheduleIDFieldName = "Keyword10"

	TestAliases = map[string]string{
		"Int01":         "CustomIntField",
		"Text01":        "CustomTextField",
		"Keyword01":     "CustomKeywordField",
		"Datetime01":    "CustomDatetimeField",
		"Double01":      "CustomDoubleField",
		"Bool01":        "CustomBoolField",
		"KeywordList01": "CustomKeywordListField",
	}
)

Functions

func AddSearchAttributes

func AddSearchAttributes(saPtr **commonpb.SearchAttributes, sas ...chasm.SearchAttributeKeyValue)

This may mutate saPtr and *saPtr

func AliasFields

func AliasFields(
	mapperProvider MapperProvider,
	searchAttributes *commonpb.SearchAttributes,
	namespaceName string,
) (*commonpb.SearchAttributes, error)

AliasFields returns SearchAttributes struct where each custom search attribute name is replaced with alias. If no replacement where made, it returns nil which means that original SearchAttributes struct should be used.

func ApplyTypeMap

func ApplyTypeMap(searchAttributes *commonpb.SearchAttributes, typeMap NameTypeMap)

ApplyTypeMap set type for all valid search attributes which don't have it. It doesn't do any validation and just skip invalid or already set search attributes.

func Decode

func Decode(
	searchAttributes *commonpb.SearchAttributes,
	typeMap *NameTypeMap,
	allowList bool,
) (map[string]any, error)

Decode decodes search attributes to the map of search attribute values using (in order): 1. type from typeMap, 2. if typeMap is nil, type from MetadataType field is used. In case of error, it will continue to next search attribute and return last error.

func Encode

func Encode(searchAttributes map[string]any, typeMap *NameTypeMap) (*commonpb.SearchAttributes, error)

Encode encodes map of search attribute values to search attributes. typeMap can be nil (then MetadataType field won't be set). In case of error, it will continue to next search attribute and return last error.

func GetFromEvent

func GetFromEvent(event *historypb.HistoryEvent) (*commonpb.SearchAttributes, bool)

func IsUserDefinedSearchAttribute

func IsUserDefinedSearchAttribute(alias string, saMapper Mapper, saNameType NameTypeMap, ns string) bool

IsUserDefinedSearchAttribute returns true if alias refers to a user-defined custom search attribute rather than a synthetic one (e.g. the synthetic ScheduleId that maps to WorkflowId).

Two independent checks are required because custom SAs can be registered in two ways:

  1. Via UpdateNamespace with an explicit alias: stored in the Mapper as alias → field-name. GetFieldName returns the underlying field name (different from the alias), so the SA is identifiable even when it is absent from the NameTypeMap under the alias.
  2. Via AddSearchAttributes without an alias: stored directly in NameTypeMap's custom map under the alias itself. GetFieldName returns an error (no mapping exists), so the type map is the only way to detect these.

func NewManager

func NewManager(
	timeSource clock.TimeSource,
	clusterMetadataManager persistence.ClusterMetadataManager,
	logger log.Logger,
	forceRefresh dynamicconfig.BoolPropertyFn,
) *managerImpl

func Parse

func Parse(searchAttributesStr map[string]string, typeMap *NameTypeMap) (*commonpb.SearchAttributes, error)

Parse converts maps of search attribute strings to search attributes. typeMap can be nil (values will be parsed with strconv and MetadataType field won't be set). In case of error, it will continue to next search attribute and return last error. Single values are parsed using strconv, arrays are parsed using json.Unmarshal.

func SetToEvent

func SetToEvent(event *historypb.HistoryEvent, sas *commonpb.SearchAttributes) bool

func Stringify

func Stringify(searchAttributes *commonpb.SearchAttributes, typeMap *NameTypeMap) (map[string]string, error)

Stringify converts search attributes to map of strings using (in order): 1. type from MetadataType field, 2. type from typeMap (can be nil). In case of error, it will continue to next search attribute and return last error. Single values are converted using strconv, arrays are converted using json.Marshal. Search attributes with `nil` values are skipped.

func TestSearchAttributesToRegister

func TestSearchAttributesToRegister() map[string]enumspb.IndexedValueType

func UnaliasFields

func UnaliasFields(
	mapperProvider MapperProvider,
	searchAttributes *commonpb.SearchAttributes,
	namespaceName string,
) (*commonpb.SearchAttributes, error)

UnaliasFields returns SearchAttributes struct where each search attribute alias is replaced with field name.

Types

type Manager

type Manager interface {
	Provider
	SaveSearchAttributes(ctx context.Context, indexName string, newCustomSearchAttributes map[string]enumspb.IndexedValueType) error
}

type Mapper

type Mapper interface {
	GetAlias(fieldName string, namespace string) (string, error)
	GetFieldName(alias string, namespace string) (string, error)
}

Mapper interface allows overriding custom search attribute names with aliases per namespace. Create an instance of a Mapper interface and pass it to the temporal.NewServer using temporal.WithSearchAttributesMapper. Returned error must be from the serviceerror package.

type MapperProvider

type MapperProvider interface {
	GetMapper(nsName namespace.Name) (Mapper, error)
}

func NewMapperProvider

func NewMapperProvider(
	customMapper Mapper,
	namespaceRegistry namespace.Registry,
	searchAttributesProvider Provider,
	fallbackIndexName string,
) MapperProvider

func NewTestMapperProvider

func NewTestMapperProvider(customMapper Mapper) MapperProvider

type MockManager

type MockManager struct {
	// contains filtered or unexported fields
}

MockManager is a mock of Manager interface.

func NewMockManager

func NewMockManager(ctrl *gomock.Controller) *MockManager

NewMockManager creates a new mock instance.

func (*MockManager) EXPECT

func (m *MockManager) EXPECT() *MockManagerMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockManager) GetSearchAttributes

func (m *MockManager) GetSearchAttributes(indexName string, forceRefreshCache bool) (NameTypeMap, error)

GetSearchAttributes mocks base method.

func (*MockManager) SaveSearchAttributes

func (m *MockManager) SaveSearchAttributes(ctx context.Context, indexName string, newCustomSearchAttributes map[string]enums.IndexedValueType) error

SaveSearchAttributes mocks base method.

type MockManagerMockRecorder

type MockManagerMockRecorder struct {
	// contains filtered or unexported fields
}

MockManagerMockRecorder is the mock recorder for MockManager.

func (*MockManagerMockRecorder) GetSearchAttributes

func (mr *MockManagerMockRecorder) GetSearchAttributes(indexName, forceRefreshCache any) *gomock.Call

GetSearchAttributes indicates an expected call of GetSearchAttributes.

func (*MockManagerMockRecorder) SaveSearchAttributes

func (mr *MockManagerMockRecorder) SaveSearchAttributes(ctx, indexName, newCustomSearchAttributes any) *gomock.Call

SaveSearchAttributes indicates an expected call of SaveSearchAttributes.

type MockMapper

type MockMapper struct {
	// contains filtered or unexported fields
}

MockMapper is a mock of Mapper interface.

func NewMockMapper

func NewMockMapper(ctrl *gomock.Controller) *MockMapper

NewMockMapper creates a new mock instance.

func (*MockMapper) EXPECT

func (m *MockMapper) EXPECT() *MockMapperMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockMapper) GetAlias

func (m *MockMapper) GetAlias(fieldName, arg1 string) (string, error)

GetAlias mocks base method.

func (*MockMapper) GetFieldName

func (m *MockMapper) GetFieldName(alias, arg1 string) (string, error)

GetFieldName mocks base method.

type MockMapperMockRecorder

type MockMapperMockRecorder struct {
	// contains filtered or unexported fields
}

MockMapperMockRecorder is the mock recorder for MockMapper.

func (*MockMapperMockRecorder) GetAlias

func (mr *MockMapperMockRecorder) GetAlias(fieldName, arg1 any) *gomock.Call

GetAlias indicates an expected call of GetAlias.

func (*MockMapperMockRecorder) GetFieldName

func (mr *MockMapperMockRecorder) GetFieldName(alias, arg1 any) *gomock.Call

GetFieldName indicates an expected call of GetFieldName.

type MockMapperProvider

type MockMapperProvider struct {
	// contains filtered or unexported fields
}

MockMapperProvider is a mock of MapperProvider interface.

func NewMockMapperProvider

func NewMockMapperProvider(ctrl *gomock.Controller) *MockMapperProvider

NewMockMapperProvider creates a new mock instance.

func (*MockMapperProvider) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockMapperProvider) GetMapper

func (m *MockMapperProvider) GetMapper(nsName namespace.Name) (Mapper, error)

GetMapper mocks base method.

type MockMapperProviderMockRecorder

type MockMapperProviderMockRecorder struct {
	// contains filtered or unexported fields
}

MockMapperProviderMockRecorder is the mock recorder for MockMapperProvider.

func (*MockMapperProviderMockRecorder) GetMapper

func (mr *MockMapperProviderMockRecorder) GetMapper(nsName any) *gomock.Call

GetMapper indicates an expected call of GetMapper.

type MockProvider

type MockProvider struct {
	// contains filtered or unexported fields
}

MockProvider is a mock of Provider interface.

func NewMockProvider

func NewMockProvider(ctrl *gomock.Controller) *MockProvider

NewMockProvider creates a new mock instance.

func (*MockProvider) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockProvider) GetSearchAttributes

func (m *MockProvider) GetSearchAttributes(indexName string, forceRefreshCache bool) (NameTypeMap, error)

GetSearchAttributes mocks base method.

type MockProviderMockRecorder

type MockProviderMockRecorder struct {
	// contains filtered or unexported fields
}

MockProviderMockRecorder is the mock recorder for MockProvider.

func (*MockProviderMockRecorder) GetSearchAttributes

func (mr *MockProviderMockRecorder) GetSearchAttributes(indexName, forceRefreshCache any) *gomock.Call

GetSearchAttributes indicates an expected call of GetSearchAttributes.

type NameTypeMap

type NameTypeMap struct {
	// contains filtered or unexported fields
}

func MergeNameTypeMaps

func MergeNameTypeMaps(a NameTypeMap, b NameTypeMap) NameTypeMap

MergeNameTypeMaps merges two NameTypeMap. The first NameTypeMap is used as base, and the second NameTypeMap is added to the first map, ie., in case of conflicts, elements from the second map overwrites elements from the first map.

func NewNameTypeMap

func NewNameTypeMap(customSearchAttributes map[string]enumspb.IndexedValueType) NameTypeMap

NewNameTypeMap creates a new NameTypeMap with the given custom search attributes.

func NewNameTypeMapStub

func NewNameTypeMapStub(attributes map[string]enumspb.IndexedValueType) NameTypeMap

func TestEsNameTypeMap

func TestEsNameTypeMap() NameTypeMap

func TestEsNameTypeMapWithScheduleID

func TestEsNameTypeMapWithScheduleID() NameTypeMap

func TestNameTypeMap

func TestNameTypeMap() NameTypeMap

func (NameTypeMap) All

func (NameTypeMap) Custom

func (m NameTypeMap) Custom() map[string]enumspb.IndexedValueType

func (NameTypeMap) GetType

func (m NameTypeMap) GetType(name string) (enumspb.IndexedValueType, error)

GetType returns type of search attribute from type map.

func (NameTypeMap) IsDefined

func (m NameTypeMap) IsDefined(name string) bool

func (NameTypeMap) System

func (m NameTypeMap) System() map[string]enumspb.IndexedValueType

func (NameTypeMap) WithPredefinedSearchAttributes

func (m NameTypeMap) WithPredefinedSearchAttributes(
	predefinedSearchAttributes map[string]enumspb.IndexedValueType,
) NameTypeMap

WithPredefinedSearchAttributes returns a new NameTypeMap overriding the predefined search attributes with the given input. The default value is the sadefs.Predefined() map which contains the internal predefined search attributes. If you need to overwrite it while preserving the internal predefined search attributes, you can call as follows:

base := NewNameTypeMap(nil)
predefinedSearchAttributes := sadefs.Predefined()
predefinedSearchAttributes["your_predefined_key"] = <search_attribute_type>
result = base.WithPredefinedSearchAttributes(predefinedSearchAttributes)

func (NameTypeMap) WithSystemSearchAttributes

func (m NameTypeMap) WithSystemSearchAttributes(
	systemSearchAttributes map[string]enumspb.IndexedValueType,
) NameTypeMap

WithSystemSearchAttributes returns a new NameTypeMap overriding the system search attributes with the given input. The default value is the sadefs.System() map which contains the internal system search attributes. If you need to overwrite it while preserving the internal system search attributes, you can call as follows:

base := NewNameTypeMap(nil)
systemSearchAttributes := sadefs.System()
systemSearchAttributes["your_system_key"] = <search_attribute_type>
result = base.WithSystemSearchAttributes(systemSearchAttributes)

type NoopMapper

type NoopMapper struct{}

NoopMapper is an identity mapper that returns all field names and aliases unchanged.

func (*NoopMapper) GetAlias

func (*NoopMapper) GetAlias(fieldName string, _ string) (string, error)

func (*NoopMapper) GetFieldName

func (*NoopMapper) GetFieldName(alias string, _ string) (string, error)

type Provider

type Provider interface {
	GetSearchAttributes(indexName string, forceRefreshCache bool) (NameTypeMap, error)
}

type SystemProvider

type SystemProvider struct{}

func NewSystemProvider

func NewSystemProvider() *SystemProvider

func (*SystemProvider) GetSearchAttributes

func (s *SystemProvider) GetSearchAttributes(_ string, _ bool) (NameTypeMap, error)

type TestMapper

type TestMapper struct {
	Namespace            string
	WithCustomScheduleID bool
}

func (*TestMapper) GetAlias

func (t *TestMapper) GetAlias(fieldName string, namespace string) (string, error)

func (*TestMapper) GetFieldName

func (t *TestMapper) GetFieldName(alias string, namespace string) (string, error)

type TestProvider

type TestProvider struct {
	// contains filtered or unexported fields
}

func NewTestEsProvider

func NewTestEsProvider() *TestProvider

func NewTestProvider

func NewTestProvider() *TestProvider

func (*TestProvider) GetSearchAttributes

func (s *TestProvider) GetSearchAttributes(_ string, _ bool) (NameTypeMap, error)

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

Validator is used to validate search attributes

func NewValidator

func NewValidator(
	searchAttributesProvider Provider,
	searchAttributesMapperProvider MapperProvider,
	searchAttributesNumberOfKeysLimit dynamicconfig.IntPropertyFnWithNamespaceFilter,
	searchAttributesSizeOfValueLimit dynamicconfig.IntPropertyFnWithNamespaceFilter,
	searchAttributesTotalSizeLimit dynamicconfig.IntPropertyFnWithNamespaceFilter,
	visibilityManager manager.VisibilityManager,
	allowList dynamicconfig.BoolPropertyFnWithNamespaceFilter,
	suppressErrorSetSystemSearchAttribute dynamicconfig.BoolPropertyFnWithNamespaceFilter,
	metricsHandler metrics.Handler,
	logger log.Logger,
) *Validator

NewValidator create Validator

func (*Validator) Validate

func (v *Validator) Validate(searchAttributes *commonpb.SearchAttributes, namespace string) error

Validate search attributes are valid for writing. The search attributes must be unaliased before calling validation.

func (*Validator) ValidateSize

func (v *Validator) ValidateSize(searchAttributes *commonpb.SearchAttributes, namespace string) error

ValidateSize validate search attributes are valid for writing and not exceed limits. The search attributes must be unaliased before calling validation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL