executable_seq

package
v4.5.3 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2022 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogicalAndMatcherGroup

func LogicalAndMatcherGroup(ctx context.Context, qCtx *query_context.Context, mg []Matcher) (matched bool, err error)

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 (*ConditionNode) LinkNext

func (b *ConditionNode) LinkNext(n ExecutableChainNode)

func (*ConditionNode) Next

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

type DummyMatcher

type DummyMatcher struct {
	Matched bool
	WantErr error
}

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

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

type LBConfig

type LBConfig struct {
	LoadBalance []interface{} `yaml:"load_balance"`
}

type LBNode

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

func ParseLBNode

func ParseLBNode(
	c *LBConfig,
	logger *zap.Logger,
	execs map[string]Executable,
	matchers map[string]Matcher,
) (*LBNode, error)

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

Jump to

Keyboard shortcuts

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