Documentation ¶
Index ¶
- Constants
- func BasicSetter(ctx context.Context, variableValue *IndexedValue, value string) errordeprecated
- func DefaultSetter(ctx context.Context, variableValue *IndexedValue, value interface{}) error
- func DefaultStringSetter(ctx context.Context, variableValue *IndexedValue, value string) error
- func Get(ctx context.Context, name string) (interface{}, error)
- func GetProtocolResource(ctx context.Context, name api.ProtocolResourceName, data ...interface{}) (string, error)
- func GetString(ctx context.Context, name string) (string, error)
- func GetVariableValue(ctx context.Context, name string) (string, error)deprecated
- func NewVariableContext(ctx context.Context) context.Context
- func Register(variable Variable) error
- func RegisterPrefix(prefix string, variable Variable) error
- func RegisterPrefixVariable(prefix string, variable Variable) errordeprecated
- func RegisterProtocolResource(protocol api.ProtocolName, resource api.ProtocolResourceName, varname string) error
- func RegisterVariable(variable Variable) errordeprecated
- func ResetVariableForTest()
- func Set(ctx context.Context, name string, value interface{}) error
- func SetString(ctx context.Context, name, value string) error
- func SetVariableValue(ctx context.Context, name, value string) errordeprecated
- type BasicVariable
- type Getter
- type GetterFunc
- type IndexedValue
- type IndexedVariable
- type Indexer
- type Setter
- type SetterFunc
- type StringGetterFunc
- type StringSetterFunc
- type Variable
- func AddVariable(name string) (Variable, error)deprecated
- func Check(name string) (Variable, error)
- func NewBasicVariable(name string, data interface{}, getter StringGetterFunc, ...) Variabledeprecated
- func NewIndexedVariable(name string, data interface{}, getter StringGetterFunc, ...) Variabledeprecated
- func NewStringVariable(name string, data interface{}, getter StringGetterFunc, ...) Variable
- func NewVariable(name string, data interface{}, getter GetterFunc, setter SetterFunc, ...) Variable
Constants ¶
const ( MOSN_VAR_FLAG_CHANGEABLE = 1 MOSN_VAR_FLAG_NOCACHEABLE = 2 MOSN_VAR_FLAG_NOHASH = 4 ValueNotFound = "-" )
Variables ¶
This section is empty.
Functions ¶
func BasicSetter
deprecated
added in
v0.11.0
func BasicSetter(ctx context.Context, variableValue *IndexedValue, value string) error
Deprecated: use DefaultStringSetter or DefaultSetter instead
func DefaultSetter ¶ added in v0.24.0
func DefaultSetter(ctx context.Context, variableValue *IndexedValue, value interface{}) error
DefaultSetter used for interface-typed variable value setting
func DefaultStringSetter ¶ added in v0.24.0
func DefaultStringSetter(ctx context.Context, variableValue *IndexedValue, value string) error
DefaultStringSetter used for string-typed variable value setting only, and would not affect any real data structure, like headers.
func GetProtocolResource ¶ added in v0.12.0
func GetProtocolResource(ctx context.Context, name api.ProtocolResourceName, data ...interface{}) (string, error)
GetProtocolResource get URI,PATH,ARG var depends on ProtocolResourceName
func RegisterPrefix ¶ added in v0.24.0
Register a new variable with prefix
func RegisterPrefixVariable
deprecated
func RegisterProtocolResource ¶ added in v0.12.0
func RegisterProtocolResource(protocol api.ProtocolName, resource api.ProtocolResourceName, varname string) error
RegisterProtocolResource registers the resource as ProtocolResourceName forexample protocolVar[Http1+api.URI] = http_request_uri var
func RegisterVariable
deprecated
func ResetVariableForTest ¶ added in v0.22.0
func ResetVariableForTest()
ResetVariableForTest is a test function for reset the variables. DONOT call it in any non-test functions
func SetVariableValue
deprecated
added in
v0.11.0
Types ¶
type BasicVariable ¶
type BasicVariable struct {
// contains filtered or unexported fields
}
variable.Variable
func (*BasicVariable) Data ¶
func (bv *BasicVariable) Data() interface{}
func (*BasicVariable) Flags ¶
func (bv *BasicVariable) Flags() uint32
func (*BasicVariable) Getter ¶
func (bv *BasicVariable) Getter() Getter
func (*BasicVariable) Name ¶
func (bv *BasicVariable) Name() string
func (*BasicVariable) Setter ¶
func (bv *BasicVariable) Setter() Setter
type Getter ¶ added in v0.24.0
type Getter interface {
Get(ctx context.Context, value *IndexedValue, data interface{}) (interface{}, error)
}
type GetterFunc ¶
type GetterFunc func(ctx context.Context, value *IndexedValue, data interface{}) (interface{}, error)
GetterFunc used to get the value of interface-typed variable
type IndexedValue ¶
IndexedValue used to store result value
type IndexedVariable ¶
type IndexedVariable struct { BasicVariable // contains filtered or unexported fields }
variable.Variable variable.VariableIndexer
func (*IndexedVariable) GetIndex ¶
func (iv *IndexedVariable) GetIndex() uint32
func (*IndexedVariable) SetIndex ¶
func (iv *IndexedVariable) SetIndex(index uint32)
type Indexer ¶
type Indexer interface { // variable index GetIndex() uint32 // set index to variable SetIndex(index uint32) }
Indexer indicates that variable needs to be cached by using pre-allocated IndexedValue
type Setter ¶ added in v0.24.0
type Setter interface {
Set(ctx context.Context, variableValue *IndexedValue, value interface{}) error
}
type SetterFunc ¶
type SetterFunc func(ctx context.Context, variableValue *IndexedValue, value interface{}) error
SetterFunc used to set the value of interface-typed variable
type StringGetterFunc ¶ added in v0.24.0
type StringGetterFunc func(ctx context.Context, value *IndexedValue, data interface{}) (string, error)
StringGetterFunc used to get the value of string-typed variable, the implementation should handle the field (Valid, NotFound) of IndexedValue if it was not nil, Valid means the value is valid; NotFound means the value can not be found. It indicates that value can be cached for next-time get handle if any one of (Valid, NotFound) is set to true.
Function should return ValueNotFound("-") if target value not exists. E.g. reference to the header which is not existed in current request.
type StringSetterFunc ¶ added in v0.24.0
type StringSetterFunc func(ctx context.Context, variableValue *IndexedValue, value string) error
StringSetterFunc used to set the value of string-typed variable
type Variable ¶
type Variable interface { // variable name Name() string // variable data, which is useful for getter/setter Data() interface{} // variable flags Flags() uint32 // value getter Getter() Getter // value setter Setter() Setter }
Variable provides a flexible and convenient way to pass information
func AddVariable
deprecated
func Check ¶ added in v0.24.0
Check return the variable related to name, return error if not registered
func NewBasicVariable
deprecated
func NewBasicVariable(name string, data interface{}, getter StringGetterFunc, setter StringSetterFunc, flags uint32) Variable
Deprecated: use NewStringVariable instead.
func NewIndexedVariable
deprecated
func NewIndexedVariable(name string, data interface{}, getter StringGetterFunc, setter StringSetterFunc, flags uint32) Variable
Deprecated: use NewStringVariable instead.
func NewStringVariable ¶ added in v0.24.0
func NewStringVariable(name string, data interface{}, getter StringGetterFunc, setter StringSetterFunc, flags uint32) Variable
func NewVariable ¶ added in v0.24.0
func NewVariable(name string, data interface{}, getter GetterFunc, setter SetterFunc, flags uint32) Variable