Documentation
¶
Overview ¶
Package searchattribute is a generated GoMock package.
Package searchattribute is a generated GoMock package.
Index ¶
- Constants
- Variables
- func AddSearchAttribute(saPtr **commonpb.SearchAttributes, key string, value *commonpb.Payload)
- func AliasFields(mapperProvider MapperProvider, searchAttributes *commonpb.SearchAttributes, ...) (*commonpb.SearchAttributes, error)
- func ApplyTypeMap(searchAttributes *commonpb.SearchAttributes, typeMap NameTypeMap)
- func Decode(searchAttributes *commonpb.SearchAttributes, typeMap *NameTypeMap, ...) (map[string]any, error)
- func DecodeValue(value *commonpb.Payload, t enumspb.IndexedValueType, allowList bool) (any, error)
- func Encode(searchAttributes map[string]any, typeMap *NameTypeMap) (*commonpb.SearchAttributes, error)
- func EncodeValue(val any, t enumspb.IndexedValueType) (*commonpb.Payload, error)
- func GetFromEvent(event *historypb.HistoryEvent) (*commonpb.SearchAttributes, bool)
- func NewManager(timeSource clock.TimeSource, ...) *managerImpl
- func Parse(searchAttributesStr map[string]string, typeMap *NameTypeMap) (*commonpb.SearchAttributes, error)
- func SetToEvent(event *historypb.HistoryEvent, sas *commonpb.SearchAttributes) bool
- func Stringify(searchAttributes *commonpb.SearchAttributes, typeMap *NameTypeMap) (map[string]string, error)
- func UnaliasFields(mapperProvider MapperProvider, searchAttributes *commonpb.SearchAttributes, ...) (*commonpb.SearchAttributes, error)
- type Manager
- type Mapper
- type MapperProvider
- type MockManager
- type MockManagerMockRecorder
- type MockMapper
- type MockMapperMockRecorder
- type MockMapperProvider
- type MockMapperProviderMockRecorder
- type MockProvider
- type MockProviderMockRecorder
- type NameTypeMap
- func (m NameTypeMap) All() map[string]enumspb.IndexedValueType
- func (m NameTypeMap) Custom() map[string]enumspb.IndexedValueType
- func (m NameTypeMap) GetType(name string) (enumspb.IndexedValueType, error)
- func (m NameTypeMap) IsDefined(name string) bool
- func (m NameTypeMap) System() map[string]enumspb.IndexedValueType
- type Provider
- type SystemProvider
- type TestMapper
- type TestProvider
- type Validator
Constants ¶
const (
MetadataType = "type"
)
Variables ¶
var ( ErrInvalidName = errors.New("invalid search attribute name") ErrInvalidType = errors.New("invalid search attribute type") )
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", } )
var ErrInvalidString = errors.New("SearchAttribute value is not a valid UTF-8 string")
Functions ¶
func AddSearchAttribute ¶
func AddSearchAttribute(saPtr **commonpb.SearchAttributes, key string, value *commonpb.Payload)
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 DecodeValue ¶
func DecodeValue( value *commonpb.Payload, t enumspb.IndexedValueType, allowList bool, ) (any, error)
DecodeValue decodes search attribute value from Payload using (in order): 1. passed type t. 2. type from MetadataType field, if t is not specified. allowList allows list of values when it's not keyword list type.
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 EncodeValue ¶
EncodeValue encodes search attribute value and IndexedValueType to Payload.
func GetFromEvent ¶
func GetFromEvent(event *historypb.HistoryEvent) (*commonpb.SearchAttributes, bool)
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 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 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.
func NewNoopMapper ¶
func NewNoopMapper() Mapper
type MapperProvider ¶
func NewMapperProvider ¶
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 ¶
func (m *MockMapperProvider) EXPECT() *MockMapperProviderMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockMapperProviderMockRecorder ¶
type MockMapperProviderMockRecorder struct {
// contains filtered or unexported fields
}
MockMapperProviderMockRecorder is the mock recorder for MockMapperProvider.
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 ¶
func (m *MockProvider) EXPECT() *MockProviderMockRecorder
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 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 (m NameTypeMap) All() map[string]enumspb.IndexedValueType
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
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 ¶
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, ) *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.