Documentation ¶
Overview ¶
nolint
nolint
nolint
nolint
Index ¶
- Constants
- Variables
- 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, i interface{}) (interface{}, error)
- func GetProtocolResource(ctx context.Context, name api.ProtocolResourceName, data ...interface{}) (string, error)
- func GetString(ctx context.Context, v interface{}) (string, error)
- func NewVariableContext(ctx context.Context) context.Context
- func Override(variable Variable) error
- func OverridePrefix(prefix string, variable Variable) error
- func Register(variable Variable) error
- func RegisterPrefix(prefix string, variable Variable) error
- func RegisterProtocolResource(protocol api.ProtocolName, resource api.ProtocolResourceName, varname string) error
- func ResetVariableForTest()
- func Set(ctx context.Context, i interface{}, value interface{}) error
- func SetString(ctx context.Context, v interface{}, value string) error
- type BasicVariable
- type Getter
- type GetterFunc
- type IndexedValue
- type IndexedVariable
- type Indexer
- type Setter
- type SetterFunc
- type StringGetterFunc
- type StringSetterFunc
- type Variable
Constants ¶
const (
ValueNotFound = "-"
)
Variables ¶
var (
ErrValueNotFound = errors.New("value not found")
)
var GetProtocol func(ctx context.Context) (api.ProtocolName, error)
GetProtocol returns the protocol name in the context. This allows user defines the way to get protocol. If the GetProtocol is undefined, the GetProtocolResource always returns an error.
Functions ¶
func DefaultSetter ¶
func DefaultSetter(ctx context.Context, variableValue *IndexedValue, value interface{}) error
DefaultSetter used for interface-typed variable value setting
func DefaultStringSetter ¶
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 ¶
func GetProtocolResource(ctx context.Context, name api.ProtocolResourceName, data ...interface{}) (string, error)
GetProtocolResource get URI,PATH,ARG var depends on ProtocolResourceName
func Override ¶ added in v1.4.0
Override a variable, return error if the variable haven't been registered
func OverridePrefix ¶ added in v1.4.0
Override a variable with prefix, return error if the variable haven't been registered
func RegisterPrefix ¶
Register a new variable with prefix
func RegisterProtocolResource ¶
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 ResetVariableForTest ¶
func ResetVariableForTest()
ResetVariableForTest is a test function for reset the variables. DONOT call it in any non-test functions
Types ¶
type BasicVariable ¶
type BasicVariable struct {
// contains filtered or unexported fields
}
variable.Variable
func (*BasicVariable) Data ¶
func (bv *BasicVariable) Data() interface{}
Data returns variable's value
func (*BasicVariable) Getter ¶
func (bv *BasicVariable) Getter() Getter
Getter is the variable's value get function if the variable contains it
func (*BasicVariable) Setter ¶
func (bv *BasicVariable) Setter() Setter
Setter is the variable's value set function if the variable contains it
type Getter ¶
type Getter interface {
Get(ctx context.Context, value *IndexedValue, data interface{}) (interface{}, error)
}
Getter used to get the value of interface-typed variable
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 ¶
type IndexedValue struct { Valid bool // contains filtered or unexported fields }
IndexedValue used to store result value
type IndexedVariable ¶
type IndexedVariable struct { BasicVariable // contains filtered or unexported fields }
IndexedVariable contains index for set search
func (*IndexedVariable) GetIndex ¶
func (iv *IndexedVariable) GetIndex() uint32
GetIndex returns the variable's index for search
func (*IndexedVariable) SetIndex ¶
func (iv *IndexedVariable) SetIndex(index uint32)
SetIndex sets the variable's index for search
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 ¶
type Setter interface {
Set(ctx context.Context, variableValue *IndexedValue, value interface{}) error
}
Setter used to set the value of interface-typed variable
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 ¶
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 of IndexedValue if it was not nil, Valid means the value is valid.
Function should return ValueNotFound("-") if target value not exists. E.g. reference to the header which is not existed in current request.
type StringSetterFunc ¶
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{} // value getter Getter() Getter // value setter Setter() Setter }
Variable provides a flexible and convenient way to pass information
func NewStringVariable ¶
func NewStringVariable(name string, data interface{}, getter StringGetterFunc, setter StringSetterFunc, flags uint32) Variable
NewStringVariable is a wrapper for NewVariable nolint:lll
func NewVariable ¶
func NewVariable(name string, data interface{}, getter GetterFunc, setter SetterFunc, flags uint32) Variable
NewVariable creates a variable with name