searchattribute

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: May 5, 2021 License: MIT Imports: 14 Imported by: 6

Documentation

Index

Constants

View Source
const (
	// Indexed fields on ES.
	NamespaceID     = "NamespaceId"
	WorkflowID      = "WorkflowId"
	RunID           = "RunId"
	WorkflowType    = "WorkflowType"
	StartTime       = "StartTime"
	ExecutionTime   = "ExecutionTime"
	CloseTime       = "CloseTime"
	ExecutionStatus = "ExecutionStatus"
	TaskQueue       = "TaskQueue"

	// Valid non-indexed fields on ES.
	HistoryLength     = "HistoryLength"
	Encoding          = "Encoding"
	Memo              = "Memo"
	VisibilityTaskKey = "VisibilityTaskKey"

	// Attr is prefix for search attributes.
	Attr = "Attr"
	// System search attributes.
	TemporalChangeVersion = "TemporalChangeVersion"
	BinaryChecksums       = "BinaryChecksums"
	CustomNamespace       = "CustomNamespace"
	Operator              = "Operator"

	// Default custom search attributes.
	CustomStringField   = "CustomStringField"
	CustomKeywordField  = "CustomKeywordField"
	CustomIntField      = "CustomIntField"
	CustomDoubleField   = "CustomDoubleField"
	CustomBoolField     = "CustomBoolField"
	CustomDatetimeField = "CustomDatetimeField"
)
View Source
const (
	MetadataType = "type"
)

Variables

View Source
var (
	ErrInvalidName    = errors.New("invalid search attribute name")
	ErrInvalidType    = errors.New("invalid search attribute type")
	ErrTypeMapIsEmpty = errors.New("search attributes type map is empty")
)
View Source
var (
	ErrExceedSizeLimit = errors.New("exceeds size limit")
)

Functions

func ApplyTypeMap

func ApplyTypeMap(searchAttributes *commonpb.SearchAttributes, typeMap map[string]enumspb.IndexedValueType)

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 BuildTypeMap

func BuildTypeMap(validSearchAttributesFn dynamicconfig.MapPropertyFn) (map[string]enumspb.IndexedValueType, error)

BuildTypeMap converts search attributes types from dynamic config map to type map.

func Decode

func Decode(searchAttributes *commonpb.SearchAttributes, typeMap map[string]enumspb.IndexedValueType) (map[string]interface{}, error)

Decode decodes search attributes to the map of search attribute values using (in order): 1. type from MetadataType field, 2. type for typeMap (can be nil). 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. type from MetadataType field, 2. passed type t.

func Encode

func Encode(searchAttributes map[string]interface{}, typeMap map[string]enumspb.IndexedValueType) (*commonpb.SearchAttributes, error)

Encode encodes map of search attribute values to search attributes. typeMap can be nil (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 GetDefaultTypeMap

func GetDefaultTypeMap() map[string]interface{}

GetDefaultTypeMap return default valid search attributes.

func GetESType

func GetESType(t enumspb.IndexedValueType) string

func GetType

func GetType(name string, typeMap map[string]enumspb.IndexedValueType) (enumspb.IndexedValueType, error)

GetType returns type of search attribute from type map.

func IsBuiltIn added in v1.9.0

func IsBuiltIn(saName string) bool

IsBuiltIn return true if search attribute is system built-in.

func IsReservedField added in v1.9.0

func IsReservedField(fieldName string) bool

IsReservedField return true if field name is system reserved.

func IsSystem

func IsSystem(saName string) bool

IsSystem return true if search attribute is system and doesn't require Attr prefix.

func Parse

func Parse(searchAttributesStr map[string]string, typeMap map[string]enumspb.IndexedValueType) (*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 map[string]enumspb.IndexedValueType) (map[string]string, error)

Stringify converts search attributes to map of strings using (in order): 1. type from MetadataType field, 2. type for 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.

Types

type Validator

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

Validator is used to validate search attributes

func NewValidator

func NewValidator(
	logger log.Logger,
	validSearchAttributes dynamicconfig.MapPropertyFn,
	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) error

Validate validate search attributes are valid for writing.

func (*Validator) ValidateAndLog

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

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

func (*Validator) ValidateSize added in v1.9.0

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

Validate 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