Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyTypeMap(searchAttributes *commonpb.SearchAttributes, ...)
- func BuildTypeMap(validSearchAttributesFn dynamicconfig.MapPropertyFn) (map[string]enumspb.IndexedValueType, error)
- func Decode(searchAttributes *commonpb.SearchAttributes, ...) (map[string]interface{}, error)
- func DecodeValue(value *commonpb.Payload, t enumspb.IndexedValueType) (interface{}, error)
- func Encode(searchAttributes map[string]interface{}, ...) (*commonpb.SearchAttributes, error)
- func EncodeValue(val interface{}, t enumspb.IndexedValueType) (*commonpb.Payload, error)
- func GetDefaultTypeMap() map[string]interface{}
- func GetESType(t enumspb.IndexedValueType) string
- func GetType(name string, typeMap map[string]enumspb.IndexedValueType) (enumspb.IndexedValueType, error)
- func IsBuiltIn(saName string) bool
- func IsReservedField(fieldName string) bool
- func IsSystem(saName string) bool
- func Parse(searchAttributesStr map[string]string, ...) (*commonpb.SearchAttributes, error)
- func Stringify(searchAttributes *commonpb.SearchAttributes, ...) (map[string]string, error)
- type Validator
- func (v *Validator) Validate(searchAttributes *commonpb.SearchAttributes, namespace string) error
- func (v *Validator) ValidateAndLog(searchAttributes *commonpb.SearchAttributes, namespace string) error
- func (v *Validator) ValidateSize(searchAttributes *commonpb.SearchAttributes, namespace string) error
Constants ¶
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" )
const (
MetadataType = "type"
)
Variables ¶
var ( ErrInvalidName = errors.New("invalid search attribute name") ErrInvalidType = errors.New("invalid search attribute type") ErrTypeMapIsEmpty = errors.New("search attributes type map is empty") )
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 IsReservedField ¶ added in v1.9.0
IsReservedField return true if field name is system reserved.
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