typedvalues

package
v0.0.0-...-0f8ae5d Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

package typedvalues provides a data container for annotating, interpreting, and transferring arbitrary data.

It revolves around the TypedValue struct type. Users typically serialize generic (though not entirely generic yet) Golang data to a TypedValue in order to serialize and transfer it. Users can set and get annotations from the TypedValue, which is for example used to preserve important headers from a HTTP request from which the entity was parsed.

The package relies heavily on Protobuf. Besides the primitive types, it supports any entity implementing the proto.Message interface. Internally the TypedValue uses the Protobuf Golang implementation for serializing and deserializing the TypedValue.

In Workflows TypedValues are used for: serialization, allowing it to store the data in the same format as the workflow structures; storing metadata of task outputs, by annotating the TypedValues; and data evaluation, by parsing and formatting task inputs and outputs into structured data (where possible).

Package typedvalues is a generated protocol buffer package.

It is generated from these files:

pkg/types/typedvalues/typedvalues.proto

It has these top-level messages:

TypedValue
Expression
MapValue
ArrayValue
NilValue
SchedulerValues

Index

Constants

View Source
const (
	MetadataPriority = "priority"
)
View Source
const (
	TypeUrlPrefix = "types.fission.io/"
)

Variables

View Source
var (
	ErrIllegalTypeAssertion = errors.New("illegal type assertion")
	ErrUnsupportedType      = errors.New("unsupported type")
)
View Source
var (
	TypeBool       string
	TypeInt32      string
	TypeInt64      string
	TypeUInt32     string
	TypeUInt64     string
	TypeFloat32    string
	TypeFloat64    string
	TypeString     string
	TypeBytes      string
	TypeNil        string
	TypeExpression string
	TypeMap        string
	TypeList       string
	TypeNumber     []string
	Types          []string
)

Functions

func IsExpression

func IsExpression(s string) bool

func MustUnwrap

func MustUnwrap(tv *TypedValue) interface{}

func MustWrapMapTypedValue

func MustWrapMapTypedValue(tvs map[string]interface{}) map[string]*TypedValue

func RemoveExpressionDelimiters

func RemoveExpressionDelimiters(expr string) string

func Unwrap

func Unwrap(tv *TypedValue) (interface{}, error)

func UnwrapArray

func UnwrapArray(tv *TypedValue) ([]interface{}, error)

func UnwrapBool

func UnwrapBool(tv *TypedValue) (bool, error)

func UnwrapBytes

func UnwrapBytes(tv *TypedValue) ([]byte, error)

func UnwrapExpression

func UnwrapExpression(tv *TypedValue) (string, error)

func UnwrapFloat64

func UnwrapFloat64(tv *TypedValue) (float64, error)

func UnwrapInt64

func UnwrapInt64(tv *TypedValue) (int64, error)

TODO reduce verbosity of these numberic implementations

func UnwrapMap

func UnwrapMap(tv *TypedValue) (map[string]interface{}, error)

func UnwrapMapTypedValue

func UnwrapMapTypedValue(tvs map[string]*TypedValue) (map[string]interface{}, error)

func UnwrapProto

func UnwrapProto(tv *TypedValue) (proto.Message, error)

func UnwrapString

func UnwrapString(tv *TypedValue) (string, error)

func UnwrapTypedValueMap

func UnwrapTypedValueMap(tv *TypedValue) (map[string]*TypedValue, error)

func WrapMapTypedValue

func WrapMapTypedValue(tvs map[string]interface{}) (map[string]*TypedValue, error)

Types

type ArrayValue

type ArrayValue struct {
	Value []*TypedValue `protobuf:"bytes,1,rep,name=value" json:"value,omitempty"`
}

func (*ArrayValue) Descriptor

func (*ArrayValue) Descriptor() ([]byte, []int)

func (*ArrayValue) GetValue

func (m *ArrayValue) GetValue() []*TypedValue

func (*ArrayValue) ProtoMessage

func (*ArrayValue) ProtoMessage()

func (*ArrayValue) Reset

func (m *ArrayValue) Reset()

func (*ArrayValue) String

func (m *ArrayValue) String() string

type Expression

type Expression struct {
	Value string `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"`
}

func (*Expression) Descriptor

func (*Expression) Descriptor() ([]byte, []int)

func (*Expression) GetValue

func (m *Expression) GetValue() string

func (*Expression) ProtoMessage

func (*Expression) ProtoMessage()

func (*Expression) Reset

func (m *Expression) Reset()

func (*Expression) String

func (m *Expression) String() string

type MapValue

type MapValue struct {
	Value map[string]*TypedValue `` /* 130-byte string literal not displayed */
}

func (*MapValue) Descriptor

func (*MapValue) Descriptor() ([]byte, []int)

func (*MapValue) GetValue

func (m *MapValue) GetValue() map[string]*TypedValue

func (*MapValue) ProtoMessage

func (*MapValue) ProtoMessage()

func (*MapValue) Reset

func (m *MapValue) Reset()

func (*MapValue) String

func (m *MapValue) String() string

type NamedInput

type NamedInput struct {
	Key string
	Val *TypedValue
}

NamedInput provides the TypedValue along with an associated key.

func Prioritize

func Prioritize(inputs map[string]*TypedValue) []NamedInput

Prioritize sorts the inputs based on the priority label (descending order)

type NilValue

type NilValue struct {
}

func (*NilValue) Descriptor

func (*NilValue) Descriptor() ([]byte, []int)

func (*NilValue) ProtoMessage

func (*NilValue) ProtoMessage()

func (*NilValue) Reset

func (m *NilValue) Reset()

func (*NilValue) String

func (m *NilValue) String() string

type SchedulerValues

type SchedulerValues struct {
	Value map[string]*TypedValue `` /* 130-byte string literal not displayed */
}

func (*SchedulerValues) Descriptor

func (*SchedulerValues) Descriptor() ([]byte, []int)

func (*SchedulerValues) GetValue

func (m *SchedulerValues) GetValue() map[string]*TypedValue

func (*SchedulerValues) ProtoMessage

func (*SchedulerValues) ProtoMessage()

func (*SchedulerValues) Reset

func (m *SchedulerValues) Reset()

func (*SchedulerValues) String

func (m *SchedulerValues) String() string

type TypedValue

type TypedValue struct {
	// Value holds the actual value in a serialized form.
	Value *google_protobuf.Any `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"`
	// Labels hold metadata about the value. It is used for example to store origins of data, past transformations,
	// and information needed by serialization processes.
	Metadata map[string]string `` /* 136-byte string literal not displayed */
}

TypedValue is used to serialize, deserialize, transfer data values across the workflow engine.

It consists partly copy of protobuf's Any, to avoid protobuf requirement of a protobuf-based type.

func MustWrap

func MustWrap(val interface{}) *TypedValue

func UnwrapTypedValueArray

func UnwrapTypedValueArray(tv *TypedValue) ([]*TypedValue, error)

func Wrap

func Wrap(val interface{}) (*TypedValue, error)

func (*TypedValue) Descriptor

func (*TypedValue) Descriptor() ([]byte, []int)

func (*TypedValue) Equals

func (m *TypedValue) Equals(other *TypedValue) bool

func (*TypedValue) Float64

func (m *TypedValue) Float64() float64

func (*TypedValue) GetMetadata

func (m *TypedValue) GetMetadata() map[string]string

func (*TypedValue) GetMetadataValue

func (m *TypedValue) GetMetadataValue(k string) (string, bool)

func (*TypedValue) GetValue

func (m *TypedValue) GetValue() *google_protobuf.Any

func (*TypedValue) Interface

func (m *TypedValue) Interface() interface{}

func (*TypedValue) ProtoMessage

func (*TypedValue) ProtoMessage()

func (*TypedValue) Reset

func (m *TypedValue) Reset()

func (*TypedValue) SetMetadata

func (m *TypedValue) SetMetadata(k string, v string) *TypedValue

func (*TypedValue) Short

func (m *TypedValue) Short() string

Short prints a short description of the Value

func (*TypedValue) String

func (m *TypedValue) String() string

func (*TypedValue) ValueType

func (m *TypedValue) ValueType() string

Directories

Path Synopsis
Package controlflow adds support for workflows and tasks (together "flows") to TypedValues.
Package controlflow adds support for workflows and tasks (together "flows") to TypedValues.
package httpconv provides methods for mapping TypedValues to and from HTTP requests and responses.
package httpconv provides methods for mapping TypedValues to and from HTTP requests and responses.

Jump to

Keyboard shortcuts

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