searchattribute

package
v1.17.3 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: MIT Imports: 20 Imported by: 6

Documentation

Overview

Package searchattribute is a generated GoMock package.

Package searchattribute is a generated GoMock package.

Index

Constants

View Source
const (
	NamespaceID          = "NamespaceId"
	WorkflowID           = "WorkflowId"
	RunID                = "RunId"
	WorkflowType         = "WorkflowType"
	StartTime            = "StartTime"
	ExecutionTime        = "ExecutionTime"
	CloseTime            = "CloseTime"
	ExecutionStatus      = "ExecutionStatus"
	TaskQueue            = "TaskQueue"
	HistoryLength        = "HistoryLength"
	ExecutionDuration    = "ExecutionDuration"
	StateTransitionCount = "StateTransitionCount"

	TemporalChangeVersion = "TemporalChangeVersion"
	BinaryChecksums       = "BinaryChecksums"
	BatcherNamespace      = "BatcherNamespace"
	BatcherUser           = "BatcherUser"

	TemporalNamespaceDivision = "TemporalNamespaceDivision"

	// These fields are not in Elasticsearch mappings definition and therefore are not indexed.
	MemoEncoding      = "MemoEncoding"
	Memo              = "Memo"
	VisibilityTaskKey = "VisibilityTaskKey"

	// Added to workflows started by a schedule.
	TemporalScheduledStartTime = "TemporalScheduledStartTime"
	TemporalScheduledById      = "TemporalScheduledById"

	// Used by scheduler workflow.
	TemporalSchedulePaused = "TemporalSchedulePaused"
	// TemporalScheduleInfoJSON is not in Elasticsearch mappings definition and therefore is not indexed.
	TemporalScheduleInfoJSON = "TemporalScheduleInfoJSON"

	ReservedPrefix = "Temporal"
)
View Source
const (
	MetadataType = "type"
)

Variables

View Source
var (
	ErrInvalidName = errors.New("invalid search attribute name")
	ErrInvalidType = errors.New("invalid search attribute type")
)
View Source
var (
	ErrExceedSizeLimit = errors.New("exceeds size limit")
)
View Source
var (
	TestNameTypeMap = NameTypeMap{
		// contains filtered or unexported fields
	}
)

Functions

func AddSearchAttribute added in v1.17.3

func AddSearchAttribute(saPtr **commonpb.SearchAttributes, key string, value *commonpb.Payload)

This may mutate saPtr and *saPtr

func ApplyAliases added in v1.12.1

func ApplyAliases(mapper Mapper, searchAttributes *commonpb.SearchAttributes, namespace string) error

ApplyAliases replaces field names with alias names for custom search attributes.

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) (map[string]interface{}, 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) (interface{}, 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.

func Encode

func Encode(searchAttributes map[string]interface{}, 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

func EncodeValue(val interface{}, t enumspb.IndexedValueType) (*commonpb.Payload, error)

EncodeValue encodes search attribute value and IndexedValueType to Payload.

func IsMappable added in v1.12.1

func IsMappable(name string) bool

IsMappable returns true if name can have be mapped tho the alias.

func IsReserved added in v1.11.0

func IsReserved(name string) bool

IsReserved returns true if name is system reserved and can't be used as custom search attribute name.

func NewManager added in v1.13.0

func NewManager(
	timeSource clock.TimeSource,
	clusterMetadataManager persistence.ClusterMetadataManager,
	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 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 SubstituteAliases added in v1.12.1

func SubstituteAliases(mapper Mapper, searchAttributes *commonpb.SearchAttributes, namespace string) error

SubstituteAliases replaces aliases with actual field names for custom search attributes.

Types

type Manager added in v1.10.0

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

type Mapper added in v1.12.1

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 MockManager added in v1.10.0

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

MockManager is a mock of Manager interface.

func NewMockManager added in v1.10.0

func NewMockManager(ctrl *gomock.Controller) *MockManager

NewMockManager creates a new mock instance.

func (*MockManager) EXPECT added in v1.10.0

func (m *MockManager) EXPECT() *MockManagerMockRecorder

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

func (*MockManager) GetSearchAttributes added in v1.10.0

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

GetSearchAttributes mocks base method.

func (*MockManager) SaveSearchAttributes added in v1.10.0

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

SaveSearchAttributes mocks base method.

type MockManagerMockRecorder added in v1.10.0

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

MockManagerMockRecorder is the mock recorder for MockManager.

func (*MockManagerMockRecorder) GetSearchAttributes added in v1.10.0

func (mr *MockManagerMockRecorder) GetSearchAttributes(indexName, forceRefreshCache interface{}) *gomock.Call

GetSearchAttributes indicates an expected call of GetSearchAttributes.

func (*MockManagerMockRecorder) SaveSearchAttributes added in v1.10.0

func (mr *MockManagerMockRecorder) SaveSearchAttributes(ctx, indexName, newCustomSearchAttributes interface{}) *gomock.Call

SaveSearchAttributes indicates an expected call of SaveSearchAttributes.

type MockMapper added in v1.12.1

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

MockMapper is a mock of Mapper interface.

func NewMockMapper added in v1.12.1

func NewMockMapper(ctrl *gomock.Controller) *MockMapper

NewMockMapper creates a new mock instance.

func (*MockMapper) EXPECT added in v1.12.1

func (m *MockMapper) EXPECT() *MockMapperMockRecorder

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

func (*MockMapper) GetAlias added in v1.12.1

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

GetAlias mocks base method.

func (*MockMapper) GetFieldName added in v1.12.1

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

GetFieldName mocks base method.

type MockMapperMockRecorder added in v1.12.1

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

MockMapperMockRecorder is the mock recorder for MockMapper.

func (*MockMapperMockRecorder) GetAlias added in v1.12.1

func (mr *MockMapperMockRecorder) GetAlias(fieldName, namespace interface{}) *gomock.Call

GetAlias indicates an expected call of GetAlias.

func (*MockMapperMockRecorder) GetFieldName added in v1.12.1

func (mr *MockMapperMockRecorder) GetFieldName(alias, namespace interface{}) *gomock.Call

GetFieldName indicates an expected call of GetFieldName.

type MockProvider added in v1.10.0

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

MockProvider is a mock of Provider interface.

func NewMockProvider added in v1.10.0

func NewMockProvider(ctrl *gomock.Controller) *MockProvider

NewMockProvider creates a new mock instance.

func (*MockProvider) EXPECT added in v1.10.0

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

func (*MockProvider) GetSearchAttributes added in v1.10.0

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

GetSearchAttributes mocks base method.

type MockProviderMockRecorder added in v1.10.0

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

MockProviderMockRecorder is the mock recorder for MockProvider.

func (*MockProviderMockRecorder) GetSearchAttributes added in v1.10.0

func (mr *MockProviderMockRecorder) GetSearchAttributes(indexName, forceRefreshCache interface{}) *gomock.Call

GetSearchAttributes indicates an expected call of GetSearchAttributes.

type NameTypeMap added in v1.10.0

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

func (NameTypeMap) All added in v1.10.0

func (NameTypeMap) Custom added in v1.10.0

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

func (NameTypeMap) GetType added in v1.10.0

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

GetType returns type of search attribute from type map.

func (NameTypeMap) IsDefined added in v1.10.0

func (m NameTypeMap) IsDefined(name string) bool

func (NameTypeMap) System added in v1.10.0

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

type Provider added in v1.10.0

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

type SystemProvider added in v1.10.0

type SystemProvider struct{}

func NewSystemProvider added in v1.10.0

func NewSystemProvider() *SystemProvider

func (*SystemProvider) GetSearchAttributes added in v1.10.0

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

type TestProvider added in v1.10.0

type TestProvider struct{}

func NewTestProvider added in v1.10.0

func NewTestProvider() *TestProvider

func (*TestProvider) GetSearchAttributes added in v1.10.0

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,
	searchAttributesMapper Mapper,
	searchAttributesNumberOfKeysLimit dynamicconfig.IntPropertyFnWithNamespaceFilter,
	searchAttributesSizeOfValueLimit dynamicconfig.IntPropertyFnWithNamespaceFilter,
	searchAttributesTotalSizeLimit dynamicconfig.IntPropertyFnWithNamespaceFilter,
) *Validator

NewValidator create Validator

func (*Validator) Validate

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

Validate search attributes are valid for writing.

func (*Validator) ValidateSize added in v1.9.0

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

ValidateSize validate search attributes are valid for writing and not exceed limits

Jump to

Keyboard shortcuts

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