Documentation ¶
Index ¶
- func ExecChainNode(ctx context.Context, qCtx *query_context.Context, n ExecutableChainNode) error
- func LogicalAndMatcherGroup(ctx context.Context, qCtx *query_context.Context, mg []Matcher) (matched bool, err error)
- type ConditionNode
- type ConditionNodeConfig
- type DummyExecutable
- type DummyMatcher
- type Executable
- type ExecutableChainNode
- type ExecutableNodeWrapper
- type FallbackConfig
- type FallbackNode
- type LBConfig
- type LBNode
- type LinkedListNode
- type Matcher
- type NodeLinker
- type ParallelConfig
- type ParallelNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecChainNode ¶
func ExecChainNode(ctx context.Context, qCtx *query_context.Context, n ExecutableChainNode) error
func LogicalAndMatcherGroup ¶
Types ¶
type ConditionNode ¶
type ConditionNode struct { ConditionMatcher Matcher // if ConditionMatcher is nil, ConditionNode is a no-op. ExecutableNode ExecutableChainNode ElseExecutableNode ExecutableChainNode // contains filtered or unexported fields }
ConditionNode implement handler.ExecutableChainNode. Internal ConditionNode.ExecutableNode will also be linked by LinkPrevious and LinkNext.
func ParseConditionNode ¶
func ParseConditionNode( cfg *ConditionNodeConfig, logger *zap.Logger, execs map[string]Executable, matchers map[string]Matcher, ) (*ConditionNode, error)
func (*ConditionNode) Exec ¶
func (b *ConditionNode) Exec(ctx context.Context, qCtx *query_context.Context, next ExecutableChainNode) (err error)
func (*ConditionNode) LinkNext ¶
func (b *ConditionNode) LinkNext(n ExecutableChainNode)
func (*ConditionNode) Next ¶
func (b *ConditionNode) Next() ExecutableChainNode
type ConditionNodeConfig ¶
type ConditionNodeConfig struct { If string `yaml:"if"` // See BuildExecutableLogicTree. Exec interface{} `yaml:"exec"` ElseExec interface{} `yaml:"else_exec"` }
ConditionNodeConfig is a config to build a ConditionNode.
type DummyExecutable ¶
type DummyExecutable struct { sync.Mutex WantSkip bool WantSleep time.Duration WantR *dns.Msg WantErr error }
func (*DummyExecutable) Exec ¶
func (d *DummyExecutable) Exec(ctx context.Context, qCtx *query_context.Context, next ExecutableChainNode) error
type DummyMatcher ¶
func (*DummyMatcher) Match ¶
func (d *DummyMatcher) Match(_ context.Context, _ *query_context.Context) (matched bool, err error)
type Executable ¶
type Executable interface {
Exec(ctx context.Context, qCtx *query_context.Context, next ExecutableChainNode) error
}
Executable represents something that is executable.
type ExecutableChainNode ¶
type ExecutableChainNode interface { Executable LinkedListNode }
ExecutableChainNode represents a node in a executable chain.
func BuildExecutableLogicTree ¶
func BuildExecutableLogicTree( in interface{}, logger *zap.Logger, execs map[string]Executable, matchers map[string]Matcher, ) (ExecutableChainNode, error)
BuildExecutableLogicTree parses in into a ExecutableChainNode. in can be: (a / a slice of) Executable, (a / a slice of) string that map to an Executable in execs, (a / a slice of) map[string]interface{}, which can be parsed to FallbackConfig, ParallelConfig or ConditionNodeConfig, a []interface{} that contains all the above.
func LastNode ¶
func LastNode(n ExecutableChainNode) ExecutableChainNode
LastNode returns the Latest node of chain of n.
func WrapExecutable ¶
func WrapExecutable(e Executable) ExecutableChainNode
WrapExecutable wraps a Executable to a ExecutableChainNode.
type ExecutableNodeWrapper ¶
type ExecutableNodeWrapper struct { Executable NodeLinker }
ExecutableNodeWrapper wraps a Executable to a ExecutableChainNode.
type FallbackConfig ¶
type FallbackConfig struct { // Primary exec sequence. Primary interface{} `yaml:"primary"` // Secondary exec sequence. Secondary interface{} `yaml:"secondary"` StatLength int `yaml:"stat_length"` // A Zero value disables the normal fallback. Threshold int `yaml:"threshold"` // FastFallback threshold in milliseconds. Zero means fast fallback is disabled. FastFallback int `yaml:"fast_fallback"` // AlwaysStandby: secondary should always stand by in fast fallback. AlwaysStandby bool `yaml:"always_standby"` }
type FallbackNode ¶
type FallbackNode struct {
// contains filtered or unexported fields
}
func ParseFallbackNode ¶
func ParseFallbackNode( c *FallbackConfig, logger *zap.Logger, execs map[string]Executable, matchers map[string]Matcher, ) (*FallbackNode, error)
func (*FallbackNode) Exec ¶
func (f *FallbackNode) Exec(ctx context.Context, qCtx *query_context.Context, next ExecutableChainNode) error
type LBNode ¶
type LBNode struct {
// contains filtered or unexported fields
}
func ParseLBNode ¶
func (*LBNode) Exec ¶
func (lbn *LBNode) Exec(ctx context.Context, qCtx *query_context.Context, next ExecutableChainNode) error
func (*LBNode) LinkNext ¶
func (lbn *LBNode) LinkNext(n ExecutableChainNode)
func (*LBNode) Next ¶
func (lbn *LBNode) Next() ExecutableChainNode
type LinkedListNode ¶
type LinkedListNode interface { Next() ExecutableChainNode LinkNext(n ExecutableChainNode) }
type Matcher ¶
type Matcher interface {
Match(ctx context.Context, qCtx *query_context.Context) (matched bool, err error)
}
Matcher represents a matcher that can match a certain patten in Context.
type NodeLinker ¶
type NodeLinker struct {
// contains filtered or unexported fields
}
NodeLinker implements LinkedListNode.
func (*NodeLinker) LinkNext ¶
func (l *NodeLinker) LinkNext(n ExecutableChainNode)
func (*NodeLinker) Next ¶
func (l *NodeLinker) Next() ExecutableChainNode
type ParallelConfig ¶
type ParallelConfig struct {
Parallel []interface{} `yaml:"parallel"`
}
type ParallelNode ¶
type ParallelNode struct {
// contains filtered or unexported fields
}
func ParseParallelNode ¶
func ParseParallelNode( c *ParallelConfig, logger *zap.Logger, execs map[string]Executable, matchers map[string]Matcher, ) (*ParallelNode, error)
func (*ParallelNode) Exec ¶
func (p *ParallelNode) Exec(ctx context.Context, qCtx *query_context.Context, next ExecutableChainNode) error