data

package
v0.5.7-rc1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2018 License: BSD-3-Clause Imports: 17 Imported by: 377

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CoerceToAny

func CoerceToAny(val interface{}) (interface{}, error)

CoerceToAny coerce a value to generic value

func CoerceToArray

func CoerceToArray(val interface{}) ([]interface{}, error)

CoerceToArray coerce a value to an array of empty interface values

func CoerceToArrayIfNecessary

func CoerceToArrayIfNecessary(val interface{}) (interface{}, error)

CoerceToArrayIfNecessary coerce a value to an array if it isn't one already

func CoerceToBoolean

func CoerceToBoolean(val interface{}) (bool, error)

CoerceToBoolean coerce a value to a boolean

func CoerceToDouble

func CoerceToDouble(val interface{}) (float64, error)

CoerceToDouble coerce a value to a double/float64

func CoerceToInteger

func CoerceToInteger(val interface{}) (int, error)

CoerceToInteger coerce a value to an integer

func CoerceToLong

func CoerceToLong(val interface{}) (int64, error)

CoerceToInteger coerce a value to an integer

func CoerceToNumber deprecated

func CoerceToNumber(val interface{}) (float64, error)

Deprecated: Use CoerceToDouble()

func CoerceToObject

func CoerceToObject(val interface{}) (map[string]interface{}, error)

CoerceToObject coerce a value to an object

func CoerceToParams

func CoerceToParams(val interface{}) (map[string]string, error)

CoerceToParams coerce a value to params

func CoerceToString

func CoerceToString(val interface{}) (string, error)

CoerceToString coerce a value to a string

func CoerceToValue

func CoerceToValue(value interface{}, dataType Type) (interface{}, error)

CoerceToValue coerce a value to the specified type

func GetComplexValue added in v0.5.7

func GetComplexValue(value interface{}) interface{}

func GetValueWithResolver

func GetValueWithResolver(valueMap map[string]interface{}, key string) (interface{}, bool)

func IsSimpleType

func IsSimpleType(val interface{}) bool

func PathGetValue

func PathGetValue(value interface{}, path string) (interface{}, error)

func SetPropertyProvider

func SetPropertyProvider(provider PropertyProvider)

func SetSecretValueHandler added in v0.5.6

func SetSecretValueHandler(pwdResolver SecretValueHandler)

Set secret value decoder

func SimpleScopeResolve

func SimpleScopeResolve(toResolve string, scope Scope) (value interface{}, err error)

Types

type Attribute

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

Attribute is a simple structure used to define a data Attribute/property

func CloneAttribute

func CloneAttribute(name string, oldAttr *Attribute) *Attribute

CloneAttribute clones the given attribute assigning a new name

func NewAttribute

func NewAttribute(name string, dataType Type, value interface{}) (*Attribute, error)

NewAttribute constructs a new attribute

func NewZeroAttribute

func NewZeroAttribute(name string, dataType Type) *Attribute

NewZeroAttribute constructs a new attribute

func (*Attribute) MarshalJSON

func (a *Attribute) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.MarshalJSON

func (*Attribute) Name

func (a *Attribute) Name() string

func (*Attribute) SetValue

func (a *Attribute) SetValue(value interface{}) (err error)

func (*Attribute) Type

func (a *Attribute) Type() Type

func (*Attribute) UnmarshalJSON

func (a *Attribute) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.UnmarshalJSON

func (*Attribute) Value

func (a *Attribute) Value() interface{}

type BasicResolver

type BasicResolver struct {
}

func (*BasicResolver) Resolve

func (r *BasicResolver) Resolve(toResolve string, scope Scope) (value interface{}, err error)

type ComplexObject

type ComplexObject struct {
	Metadata string      `json:"metadata"`
	Value    interface{} `json:"value"`
}

ComplexObject is the value that is used when using a "COMPLEX_OBJECT" type

func CoerceToComplexObject

func CoerceToComplexObject(val interface{}) (*ComplexObject, error)

CoerceToObject coerce a value to an complex object

type DefaultPropertyProvider

type DefaultPropertyProvider struct {
}

DefaultPropertyProvider empty property provider

func (*DefaultPropertyProvider) GetProperty

func (pp *DefaultPropertyProvider) GetProperty(property string) (value interface{}, exists bool)

type Expr

type Expr interface {
	Eval(scope Scope) (interface{}, error)
}

type FixedScope

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

FixedScope is an implementation of a empty scope fixed to a particular set of metadata

func NewFixedScope

func NewFixedScope(metadata map[string]*Attribute) *FixedScope

NewFixedScope creates a new SimpleScope

func NewFixedScopeFromMap

func NewFixedScopeFromMap(metadata map[string]*Attribute) *FixedScope

func (*FixedScope) GetAttr

func (s *FixedScope) GetAttr(name string) (attr *Attribute, exists bool)

GetAttr implements Scope.GetAttr

func (*FixedScope) GetAttrs

func (s *FixedScope) GetAttrs() map[string]*Attribute

GetAttrs gets the attributes set in the scope

func (*FixedScope) SetAttrValue

func (s *FixedScope) SetAttrValue(name string, value interface{}) error

SetAttrValue implements Scope.SetAttrValue

type FlexableScope added in v0.5.6

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

FixedScope is an implementation of a empty scope fixed to a particular set of metadata

func NewFlexableScope added in v0.5.6

func NewFlexableScope(metadata map[string]*Attribute) *FlexableScope

NewFlexableScope creates a new SimpleScope

func NewFlexableScopeFromMap added in v0.5.6

func NewFlexableScopeFromMap(metadata map[string]*Attribute) *FlexableScope

func (*FlexableScope) GetAttr added in v0.5.6

func (s *FlexableScope) GetAttr(name string) (attr *Attribute, exists bool)

GetAttr implements Scope.GetAttr

func (*FlexableScope) GetAttrs added in v0.5.6

func (s *FlexableScope) GetAttrs() map[string]*Attribute

GetAttrs gets the attributes set in the scope

func (*FlexableScope) SetAttrValue added in v0.5.6

func (s *FlexableScope) SetAttrValue(name string, value interface{}) error

SetAttrValue implements Scope.SetAttrValue

type IOMappings

type IOMappings struct {
	Input  []*MappingDef `json:"input,omitempty"`
	Output []*MappingDef `json:"output,omitempty"`
}

type IOMetadata

type IOMetadata struct {
	Input  map[string]*Attribute
	Output map[string]*Attribute
}

func (*IOMetadata) MarshalJSON

func (md *IOMetadata) MarshalJSON() ([]byte, error)

func (*IOMetadata) UnmarshalJSON

func (md *IOMetadata) UnmarshalJSON(b []byte) error

type KeyBasedSecretValueHandler added in v0.5.6

type KeyBasedSecretValueHandler struct {
	Key string
}

A key based secret value decoder. Secret value encryption/decryption is based on SHA256 and uses implementation from https://gist.github.com/willshiao/f4b03650e5a82561a460b4a15789cfa1

func (*KeyBasedSecretValueHandler) DecodeValue added in v0.5.6

func (defaultResolver *KeyBasedSecretValueHandler) DecodeValue(value interface{}) (string, error)

Decode value based on a key

func (*KeyBasedSecretValueHandler) EncodeValue added in v0.5.6

func (defaultResolver *KeyBasedSecretValueHandler) EncodeValue(value interface{}) (string, error)

type Mapper

type Mapper interface {
	Apply(inputScope Scope, outputScope Scope) error
}

Mapper is a constructs that maps values from one scope to another

type MapperDef

type MapperDef struct {
	//todo possibly add optional lang/mapper type so we can fast fail on unsupported mappings/mapper combo
	Mappings []*MappingDef
}

MapperDef represents a Mapper, which is a collection of mappings

type MappingDef

type MappingDef struct {
	//Type the mapping type
	Type MappingType

	//Value the mapping value to execute to determine the result (rhs)
	Value interface{}

	//Result the name of attribute to place the result of the mapping in (lhs)
	MapTo string
}

MappingDef is a simple structure that defines a mapping

func (*MappingDef) UnmarshalJSON

func (md *MappingDef) UnmarshalJSON(b []byte) error

type MappingType

type MappingType int

MappingType is an enum for possible MappingDef Types

const (
	// MtAssign denotes an attribute to attribute assignment
	MtAssign MappingType = 1

	// MtLiteral denotes a literal to attribute assignment
	MtLiteral MappingType = 2

	// MtExpression denotes a expression execution to perform mapping
	MtExpression MappingType = 3

	// MtObject denotes a object construction mapping
	MtObject MappingType = 4

	MtArray MappingType = 5
)

func ConvertMappingType

func ConvertMappingType(mapType interface{}) (MappingType, error)

type MutableScope

type MutableScope interface {
	Scope

	//AddAttr adds an attribute to the scope
	AddAttr(name string, valueType Type, value interface{}) *Attribute
}

MutableScope is a scope that new attributes can be added

func GetGlobalScope

func GetGlobalScope() MutableScope

GetGlobalScope gets the global scope the application

func NewSimpleSyncScope

func NewSimpleSyncScope(attrs []*Attribute, parentScope Scope) MutableScope

NewSimpleSyncScope creates a new SimpleSyncScope

type PropertyProvider

type PropertyProvider interface {
	GetProperty(property string) (value interface{}, exists bool)
}

func GetPropertyProvider

func GetPropertyProvider() PropertyProvider

type ResolutionDetails

type ResolutionDetails struct {
	ResolverName string
	Item         string
	Property     string
	Path         string
}

func GetResolutionDetails

func GetResolutionDetails(toResolve string) (*ResolutionDetails, error)

func GetResolutionDetailsOld

func GetResolutionDetailsOld(toResolve string) (*ResolutionDetails, error)

type Resolver

type Resolver interface {
	Resolve(toResolve string, scope Scope) (value interface{}, err error)
}

func GetBasicResolver

func GetBasicResolver() Resolver

type Scope

type Scope interface {
	// GetAttr gets the specified attribute
	GetAttr(name string) (attr *Attribute, exists bool)

	// SetAttrValue sets the value of the specified attribute
	SetAttrValue(name string, value interface{}) error
}

Scope is a set of attributes that are accessible

func NewSimpleScope

func NewSimpleScope(attrs []*Attribute, parentScope Scope) Scope

NewSimpleScope creates a new SimpleScope

type SecretValueHandler added in v0.5.6

type SecretValueHandler interface {
	EncodeValue(value interface{}) (string, error)
	DecodeValue(value interface{}) (string, error)
}

SecretValueDecoder defines method for decoding value

func GetSecretValueHandler added in v0.5.6

func GetSecretValueHandler() SecretValueHandler

Get secret value handler. If not already set by SetSecretValueHandler(), will return default KeyBasedSecretValueDecoder where decoding key value is expected to be set through FLOGO_DATA_SECRET_KEY environment variable. If key is not set, a default key value(github.com/TIBCOSoftware/flogo-lib/config.DATA_SECRET_KEY_DEFAULT) will be used.

type SimpleScope

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

SimpleScope is a basic implementation of a scope

func NewSimpleScopeFromMap

func NewSimpleScopeFromMap(attrs map[string]*Attribute, parentScope Scope) *SimpleScope

NewSimpleScopeFromMap creates a new SimpleScope

func (*SimpleScope) AddAttr

func (s *SimpleScope) AddAttr(name string, valueType Type, value interface{}) *Attribute

AddAttr implements MutableScope.AddAttr

func (*SimpleScope) GetAttr

func (s *SimpleScope) GetAttr(name string) (attr *Attribute, exists bool)

GetAttr implements Scope.GetAttr

func (*SimpleScope) SetAttrValue

func (s *SimpleScope) SetAttrValue(name string, value interface{}) error

SetAttrValue implements Scope.SetAttrValue

type SimpleSyncScope

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

SimpleSyncScope is a basic implementation of a synchronized scope

func (*SimpleSyncScope) AddAttr

func (s *SimpleSyncScope) AddAttr(name string, valueType Type, value interface{}) *Attribute

AddAttr implements MutableScope.AddAttr

func (*SimpleSyncScope) GetAttr

func (s *SimpleSyncScope) GetAttr(name string) (value *Attribute, exists bool)

GetAttr implements Scope.GetAttr

func (*SimpleSyncScope) SetAttrValue

func (s *SimpleSyncScope) SetAttrValue(name string, value interface{}) error

SetAttrValue implements Scope.SetAttrValue

type Type

type Type int

Type denotes a data type

const (
	TypeAny Type = iota
	TypeString
	TypeInteger
	TypeLong
	TypeDouble
	TypeBoolean
	TypeObject
	TypeComplexObject
	TypeArray
	TypeParams
)

func GetType

func GetType(val interface{}) (Type, error)

GetType get the Type of the supplied value

func ToTypeEnum

func ToTypeEnum(typeStr string) (Type, bool)

ToTypeEnum get the data type that corresponds to the specified name

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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