router

package
v0.0.0-...-e3e1183 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const RouterLogFormat = "[router] [%s] [%s] %v"

[sub module] & [function] & msg

Variables

View Source
var (
	ErrNilRouterConfig      = errors.New("router config is nil")
	ErrNoVirtualHost        = errors.New("virtual host is nil")
	ErrNoRouters            = errors.New("routers is nil")
	ErrDuplicateVirtualHost = errors.New("duplicate domain virtual host")
	ErrUnexpected           = errors.New("an unexpected error occurs")
	ErrRouterFactory        = errors.New("default router factory create router failed")
)
View Source
var ConfigUtilityInst = &configUtility{}

Functions

func GetRouterHeaders

func GetRouterHeaders(headers []v2.HeaderMatcher) []*types.HeaderData

GetRouterHeaders exports getRouterHeaders

func GetRoutersMangerInstance

func GetRoutersMangerInstance() types.RouterManager

compatible

func NewConfigImpl

func NewConfigImpl(routerConfig *v2.RouterConfiguration) *configImpl

NewConfigImpl return an configImpl instance contains requestHeadersParser and responseHeadersParser

func NewRouterManager

func NewRouterManager() types.RouterManager

func NewRouters

func NewRouters(routerConfig *v2.RouterConfiguration) (types.Routers, error)

NewRouters creates a types.Routers by according to config

func RegisterMakeHandlerChain

func RegisterMakeHandlerChain(f MakeHandlerChain, order uint32)

func RegisterRouterRule

func RegisterRouterRule(f RouterRuleFactory, order uint32)

Types

type MakeHandlerChain

MakeHandlerChain creates a RouteHandlerChain, should not returns a nil handler chain, or the stream filters will be ignored

type Matchable

type Matchable interface {
	Match(headers types.HeaderMap, randomValue uint64) types.Route
}

type MetadataMatchCriteriaImpl

type MetadataMatchCriteriaImpl struct {
	MatchCriteriaArray []types.MetadataMatchCriterion
}

MetadataMatchCriteriaImpl class wrapper MatchCriteriaArray which contains MatchCriteria in dictionary sorted

func NewMetadataMatchCriteriaImpl

func NewMetadataMatchCriteriaImpl(metadataMatches map[string]string) *MetadataMatchCriteriaImpl

NewMetadataMatchCriteriaImpl

func (*MetadataMatchCriteriaImpl) Len

func (mmcti *MetadataMatchCriteriaImpl) Len() int

func (*MetadataMatchCriteriaImpl) Less

func (mmcti *MetadataMatchCriteriaImpl) Less(i, j int) bool

func (*MetadataMatchCriteriaImpl) MergeMatchCriteria

func (mmcti *MetadataMatchCriteriaImpl) MergeMatchCriteria(metadataMatches map[string]interface{}) types.MetadataMatchCriteria

MergeMatchCriteria No usage currently

func (*MetadataMatchCriteriaImpl) MetadataMatchCriteria

func (mmcti *MetadataMatchCriteriaImpl) MetadataMatchCriteria() []types.MetadataMatchCriterion

MetadataMatchCriteria

func (*MetadataMatchCriteriaImpl) Swap

func (mmcti *MetadataMatchCriteriaImpl) Swap(i, j int)

type MetadataMatchCriterionImpl

type MetadataMatchCriterionImpl struct {
	Name  string
	Value string
}

MetadataMatchCriterionImpl class contains the name and value of the metadata match criterion Implement types.MetadataMatchCriterion

func (*MetadataMatchCriterionImpl) MetadataKeyName

func (mmci *MetadataMatchCriterionImpl) MetadataKeyName() string

MetadataKeyName return name

func (*MetadataMatchCriterionImpl) MetadataValue

func (mmci *MetadataMatchCriterionImpl) MetadataValue() string

MetadataValue return value

type PathRouteRuleImpl

type PathRouteRuleImpl struct {
	*RouteRuleImplBase
	// contains filtered or unexported fields
}

func (*PathRouteRuleImpl) FinalizeRequestHeaders

func (prri *PathRouteRuleImpl) FinalizeRequestHeaders(headers types.HeaderMap, requestInfo types.RequestInfo)

types.RouteRule override Base

func (*PathRouteRuleImpl) Match

func (prri *PathRouteRuleImpl) Match(headers types.HeaderMap, randomValue uint64) types.Route

func (*PathRouteRuleImpl) MatchType

func (prri *PathRouteRuleImpl) MatchType() types.PathMatchType

func (*PathRouteRuleImpl) Matcher

func (prri *PathRouteRuleImpl) Matcher() string

types.PathMatchCriterion

func (*PathRouteRuleImpl) PathMatchCriterion

func (prri *PathRouteRuleImpl) PathMatchCriterion() types.PathMatchCriterion

func (*PathRouteRuleImpl) RouteRule

func (prri *PathRouteRuleImpl) RouteRule() types.RouteRule

type PrefixRouteRuleImpl

type PrefixRouteRuleImpl struct {
	*RouteRuleImplBase
	// contains filtered or unexported fields
}

PrefixRouteRuleImpl used to "match path" with "prefix match"

func (*PrefixRouteRuleImpl) FinalizeRequestHeaders

func (prei *PrefixRouteRuleImpl) FinalizeRequestHeaders(headers types.HeaderMap, requestInfo types.RequestInfo)

types.RouteRule override Base

func (*PrefixRouteRuleImpl) Match

func (prei *PrefixRouteRuleImpl) Match(headers types.HeaderMap, randomValue uint64) types.Route

func (*PrefixRouteRuleImpl) MatchType

func (prei *PrefixRouteRuleImpl) MatchType() types.PathMatchType

func (*PrefixRouteRuleImpl) Matcher

func (prei *PrefixRouteRuleImpl) Matcher() string

types.PathMatchCriterion

func (*PrefixRouteRuleImpl) PathMatchCriterion

func (prei *PrefixRouteRuleImpl) PathMatchCriterion() types.PathMatchCriterion

func (*PrefixRouteRuleImpl) RouteRule

func (prei *PrefixRouteRuleImpl) RouteRule() types.RouteRule

type RegexRouteRuleImpl

type RegexRouteRuleImpl struct {
	*RouteRuleImplBase
	// contains filtered or unexported fields
}

RegexRouteRuleImpl used to "match path" with "regex match"

func (*RegexRouteRuleImpl) FinalizeRequestHeaders

func (rrei *RegexRouteRuleImpl) FinalizeRequestHeaders(headers types.HeaderMap, requestInfo types.RequestInfo)

func (*RegexRouteRuleImpl) Match

func (rrei *RegexRouteRuleImpl) Match(headers types.HeaderMap, randomValue uint64) types.Route

func (*RegexRouteRuleImpl) MatchType

func (rrei *RegexRouteRuleImpl) MatchType() types.PathMatchType

func (*RegexRouteRuleImpl) Matcher

func (rrei *RegexRouteRuleImpl) Matcher() string

func (*RegexRouteRuleImpl) PathMatchCriterion

func (rrei *RegexRouteRuleImpl) PathMatchCriterion() types.PathMatchCriterion

func (*RegexRouteRuleImpl) RouteRule

func (rrei *RegexRouteRuleImpl) RouteRule() types.RouteRule

type RouteBase

type RouteBase interface {
	types.Route
	types.PathMatchCriterion
	Matchable
}

func DefaultSofaRouterRuleFactory

func DefaultSofaRouterRuleFactory(base *RouteRuleImplBase, headers []v2.HeaderMatcher) RouteBase

func SofaRouterFactory

func SofaRouterFactory(headers []v2.HeaderMatcher) RouteBase

type RouteHandlerChain

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

RouteHandlerChain returns first available handler's router

func CallMakeHandlerChain

func CallMakeHandlerChain(ctx context.Context, headers types.HeaderMap, routers types.Routers, clusterManager types.ClusterManager) *RouteHandlerChain

func DefaultMakeHandlerChain

func DefaultMakeHandlerChain(ctx context.Context, headers types.HeaderMap, routers types.Routers, clusterManager types.ClusterManager) *RouteHandlerChain

func NewRouteHandlerChain

func NewRouteHandlerChain(ctx context.Context, clusterManager types.ClusterManager, handlers []types.RouteHandler) *RouteHandlerChain

func (*RouteHandlerChain) DoNextHandler

func (hc *RouteHandlerChain) DoNextHandler() (types.ClusterSnapshot, types.Route)

func (*RouteHandlerChain) Next

type RouteRuleImplBase

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

func NewRouteRuleImplBase

func NewRouteRuleImplBase(vHost *VirtualHostImpl, route *v2.Router) (*RouteRuleImplBase, error)

func (*RouteRuleImplBase) ClusterName

func (rri *RouteRuleImplBase) ClusterName() string

types.RouteRule Select Cluster for Routing if weighted cluster is nil, return clusterName directly, else select cluster from weighted-clusters

func (*RouteRuleImplBase) DirectResponseRule

func (rri *RouteRuleImplBase) DirectResponseRule() types.DirectResponseRule

func (*RouteRuleImplBase) FinalizeRequestHeaders

func (rri *RouteRuleImplBase) FinalizeRequestHeaders(headers types.HeaderMap, requestInfo types.RequestInfo)

func (*RouteRuleImplBase) FinalizeResponseHeaders

func (rri *RouteRuleImplBase) FinalizeResponseHeaders(headers types.HeaderMap, requestInfo types.RequestInfo)

func (*RouteRuleImplBase) GlobalTimeout

func (rri *RouteRuleImplBase) GlobalTimeout() time.Duration

func (*RouteRuleImplBase) MetadataMatchCriteria

func (rri *RouteRuleImplBase) MetadataMatchCriteria(clusterName string) types.MetadataMatchCriteria

func (*RouteRuleImplBase) PerFilterConfig

func (rri *RouteRuleImplBase) PerFilterConfig() map[string]interface{}

func (*RouteRuleImplBase) Policy

func (rri *RouteRuleImplBase) Policy() types.Policy

func (*RouteRuleImplBase) UpstreamProtocol

func (rri *RouteRuleImplBase) UpstreamProtocol() string

func (*RouteRuleImplBase) VirtualHost

func (rri *RouteRuleImplBase) VirtualHost() types.VirtualHost

type RouterRuleFactory

type RouterRuleFactory func(base *RouteRuleImplBase, header []v2.HeaderMatcher) RouteBase

RouterRuleFactory creates a RouteBase

type RoutersWrapper

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

func (*RoutersWrapper) GetRouters

func (rw *RoutersWrapper) GetRouters() types.Routers

func (*RoutersWrapper) GetRoutersConfig

func (rw *RoutersWrapper) GetRoutersConfig() v2.RouterConfiguration

type SofaRouteRuleImpl

type SofaRouteRuleImpl struct {
	*RouteRuleImplBase
	// contains filtered or unexported fields
}

func (*SofaRouteRuleImpl) FinalizeRequestHeaders

func (srri *SofaRouteRuleImpl) FinalizeRequestHeaders(headers types.HeaderMap, requestInfo types.RequestInfo)

func (*SofaRouteRuleImpl) Match

func (srri *SofaRouteRuleImpl) Match(headers types.HeaderMap, randomValue uint64) types.Route

func (*SofaRouteRuleImpl) MatchType

func (srri *SofaRouteRuleImpl) MatchType() types.PathMatchType

func (*SofaRouteRuleImpl) Matcher

func (srri *SofaRouteRuleImpl) Matcher() string

func (*SofaRouteRuleImpl) PathMatchCriterion

func (srri *SofaRouteRuleImpl) PathMatchCriterion() types.PathMatchCriterion

func (*SofaRouteRuleImpl) RouteRule

func (srri *SofaRouteRuleImpl) RouteRule() types.RouteRule

type VirtualHostImpl

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

func NewVirtualHostImpl

func NewVirtualHostImpl(virtualHost *v2.VirtualHost) (*VirtualHostImpl, error)

func (*VirtualHostImpl) AddRoute

func (vh *VirtualHostImpl) AddRoute(route *v2.Router) error

func (*VirtualHostImpl) GetAllRoutesFromEntries

func (vh *VirtualHostImpl) GetAllRoutesFromEntries(headers types.HeaderMap, randomValue uint64) []types.Route

func (*VirtualHostImpl) GetRouteFromEntries

func (vh *VirtualHostImpl) GetRouteFromEntries(headers types.HeaderMap, randomValue uint64) types.Route

func (*VirtualHostImpl) GetRouteFromHeaderKV

func (vh *VirtualHostImpl) GetRouteFromHeaderKV(key, value string) types.Route

func (*VirtualHostImpl) Name

func (vh *VirtualHostImpl) Name() string

func (*VirtualHostImpl) RemoveAllRoutes

func (vh *VirtualHostImpl) RemoveAllRoutes()

Jump to

Keyboard shortcuts

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