condition

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2020 License: Apache-2.0 Imports: 21 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppRouter

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

AppRouter For listen application router with config center

func NewAppRouter

func NewAppRouter(url *common.URL) (*AppRouter, error)

NewAppRouter Init AppRouter by url

func (*AppRouter) Priority

func (l *AppRouter) Priority() int64

Priority Return Priority in listenable router

func (*AppRouter) Process

func (l *AppRouter) Process(event *config_center.ConfigChangeEvent)

Process Process config change event , generate routers and set them to the listenableRouter instance

func (*AppRouter) Route

func (l *AppRouter) Route(invokers []protocol.Invoker, url *common.URL, invocation protocol.Invocation) []protocol.Invoker

Route Determine the target invokers list.

func (*AppRouter) RouterRule

func (l *AppRouter) RouterRule() *RouterRule

RouterRule Get RouterRule instance from listenableRouter

func (*AppRouter) URL

func (l *AppRouter) URL() common.URL

URL Return URL in listenable router

type AppRouterFactory

type AppRouterFactory struct{}

AppRouterFactory Application router factory

func (*AppRouterFactory) NewRouter

func (c *AppRouterFactory) NewRouter(url *common.URL) (router.Router, error)

NewRouter Create AppRouterFactory by URL

type ConditionRouter

type ConditionRouter struct {
	Pattern string

	Force bool

	WhenCondition map[string]MatchPair
	ThenCondition map[string]MatchPair
	// contains filtered or unexported fields
}

ConditionRouter Condition router struct

func NewConditionRouter

func NewConditionRouter(url *common.URL) (*ConditionRouter, error)

NewConditionRouter Init condition router by URL

func NewConditionRouterWithRule

func NewConditionRouterWithRule(rule string) (*ConditionRouter, error)

NewConditionRouterWithRule Init condition router by raw rule

func (*ConditionRouter) Enabled

func (c *ConditionRouter) Enabled() bool

Enabled Return is condition router is enabled true: enabled false: disabled

func (*ConditionRouter) MatchThen

func (c *ConditionRouter) MatchThen(url *common.URL, param *common.URL) bool

MatchThen MatchThen

func (*ConditionRouter) MatchWhen

func (c *ConditionRouter) MatchWhen(url *common.URL, invocation protocol.Invocation) bool

MatchWhen MatchWhen

func (*ConditionRouter) Priority

func (c *ConditionRouter) Priority() int64

Priority Return Priority in condition router

func (*ConditionRouter) Route

func (c *ConditionRouter) Route(invokers []protocol.Invoker, url *common.URL, invocation protocol.Invocation) []protocol.Invoker

Route Determine the target invokers list.

func (*ConditionRouter) URL

func (c *ConditionRouter) URL() common.URL

URL Return URL in condition router

type ConditionRouterFactory

type ConditionRouterFactory struct{}

ConditionRouterFactory Condition router factory

func (*ConditionRouterFactory) NewFileRouter

func (c *ConditionRouterFactory) NewFileRouter(content []byte) (router.Router, error)

NewRouter Create FileRouterFactory by Content

func (*ConditionRouterFactory) NewRouter

func (c *ConditionRouterFactory) NewRouter(url *common.URL) (router.Router, error)

NewRouter Create ConditionRouterFactory by URL

type FileConditionRouter

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

FileConditionRouter Use for parse config file of condition router

func NewFileConditionRouter

func NewFileConditionRouter(content []byte) (*FileConditionRouter, error)

NewFileConditionRouter Create file condition router instance with content ( from config file)

func (*FileConditionRouter) Priority

func (l *FileConditionRouter) Priority() int64

Priority Return Priority in listenable router

func (*FileConditionRouter) Process

func (l *FileConditionRouter) Process(event *config_center.ConfigChangeEvent)

Process Process config change event , generate routers and set them to the listenableRouter instance

func (*FileConditionRouter) Route

func (l *FileConditionRouter) Route(invokers []protocol.Invoker, url *common.URL, invocation protocol.Invocation) []protocol.Invoker

Route Determine the target invokers list.

func (*FileConditionRouter) RouterRule

func (l *FileConditionRouter) RouterRule() *RouterRule

RouterRule Get RouterRule instance from listenableRouter

func (*FileConditionRouter) URL

func (f *FileConditionRouter) URL() common.URL

URL Return URL in file condition router n

type MatchPair

type MatchPair struct {
	Matches    *gxset.HashSet
	Mismatches *gxset.HashSet
}

MatchPair Match key pair , condition process

type RouterRule

type RouterRule struct {
	router.BaseRouterRule `yaml:",inline""`
	Conditions            []string
}

RouterRule RouterRule config read from config file or config center

func Parse

func Parse(rawRule string) (*RouterRule, error)

Parse Router raw rule parser * example : * scope: application * runtime: true * force: false * conditions: * - > * method!=sayHello => * - > * ip=127.0.0.1 * => * 1.1.1.1

Jump to

Keyboard shortcuts

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