Documentation ¶
Index ¶
- Constants
- Variables
- func GetRouterHeaders(headers []v2.HeaderMatcher) []*types.HeaderData
- func GetRoutersMangerInstance() types.RouterManager
- func NewConfigImpl(routerConfig *v2.RouterConfiguration) *configImpl
- func NewRouterManager() types.RouterManager
- func NewRouters(routerConfig *v2.RouterConfiguration) (types.Routers, error)
- func RegisterMakeHandlerChain(f MakeHandlerChain, order uint32)
- func RegisterRouterRule(f RouterRuleFactory, order uint32)
- type MakeHandlerChain
- type Matchable
- type MetadataMatchCriteriaImpl
- func (mmcti *MetadataMatchCriteriaImpl) Len() int
- func (mmcti *MetadataMatchCriteriaImpl) Less(i, j int) bool
- func (mmcti *MetadataMatchCriteriaImpl) MergeMatchCriteria(metadataMatches map[string]interface{}) types.MetadataMatchCriteria
- func (mmcti *MetadataMatchCriteriaImpl) MetadataMatchCriteria() []types.MetadataMatchCriterion
- func (mmcti *MetadataMatchCriteriaImpl) Swap(i, j int)
- type MetadataMatchCriterionImpl
- type PathRouteRuleImpl
- func (prri *PathRouteRuleImpl) FinalizeRequestHeaders(headers types.HeaderMap, requestInfo types.RequestInfo)
- func (prri *PathRouteRuleImpl) Match(headers types.HeaderMap, randomValue uint64) types.Route
- func (prri *PathRouteRuleImpl) MatchType() types.PathMatchType
- func (prri *PathRouteRuleImpl) Matcher() string
- func (prri *PathRouteRuleImpl) PathMatchCriterion() types.PathMatchCriterion
- func (prri *PathRouteRuleImpl) RouteRule() types.RouteRule
- type PrefixRouteRuleImpl
- func (prei *PrefixRouteRuleImpl) FinalizeRequestHeaders(headers types.HeaderMap, requestInfo types.RequestInfo)
- func (prei *PrefixRouteRuleImpl) Match(headers types.HeaderMap, randomValue uint64) types.Route
- func (prei *PrefixRouteRuleImpl) MatchType() types.PathMatchType
- func (prei *PrefixRouteRuleImpl) Matcher() string
- func (prei *PrefixRouteRuleImpl) PathMatchCriterion() types.PathMatchCriterion
- func (prei *PrefixRouteRuleImpl) RouteRule() types.RouteRule
- type RegexRouteRuleImpl
- func (rrei *RegexRouteRuleImpl) FinalizeRequestHeaders(headers types.HeaderMap, requestInfo types.RequestInfo)
- func (rrei *RegexRouteRuleImpl) Match(headers types.HeaderMap, randomValue uint64) types.Route
- func (rrei *RegexRouteRuleImpl) MatchType() types.PathMatchType
- func (rrei *RegexRouteRuleImpl) Matcher() string
- func (rrei *RegexRouteRuleImpl) PathMatchCriterion() types.PathMatchCriterion
- func (rrei *RegexRouteRuleImpl) RouteRule() types.RouteRule
- type RouteBase
- type RouteHandlerChain
- func CallMakeHandlerChain(ctx context.Context, headers types.HeaderMap, routers types.Routers, ...) *RouteHandlerChain
- func DefaultMakeHandlerChain(ctx context.Context, headers types.HeaderMap, routers types.Routers, ...) *RouteHandlerChain
- func NewRouteHandlerChain(ctx context.Context, clusterManager types.ClusterManager, ...) *RouteHandlerChain
- type RouteRuleImplBase
- func (rri *RouteRuleImplBase) ClusterName() string
- func (rri *RouteRuleImplBase) DirectResponseRule() types.DirectResponseRule
- func (rri *RouteRuleImplBase) FinalizeRequestHeaders(headers types.HeaderMap, requestInfo types.RequestInfo)
- func (rri *RouteRuleImplBase) FinalizeResponseHeaders(headers types.HeaderMap, requestInfo types.RequestInfo)
- func (rri *RouteRuleImplBase) GlobalTimeout() time.Duration
- func (rri *RouteRuleImplBase) MetadataMatchCriteria(clusterName string) types.MetadataMatchCriteria
- func (rri *RouteRuleImplBase) PerFilterConfig() map[string]interface{}
- func (rri *RouteRuleImplBase) Policy() types.Policy
- func (rri *RouteRuleImplBase) UpstreamProtocol() string
- func (rri *RouteRuleImplBase) VirtualHost() types.VirtualHost
- type RouterRuleFactory
- type RoutersWrapper
- type SofaRouteRuleImpl
- func (srri *SofaRouteRuleImpl) FinalizeRequestHeaders(headers types.HeaderMap, requestInfo types.RequestInfo)
- func (srri *SofaRouteRuleImpl) Match(headers types.HeaderMap, randomValue uint64) types.Route
- func (srri *SofaRouteRuleImpl) MatchType() types.PathMatchType
- func (srri *SofaRouteRuleImpl) Matcher() string
- func (srri *SofaRouteRuleImpl) PathMatchCriterion() types.PathMatchCriterion
- func (srri *SofaRouteRuleImpl) RouteRule() types.RouteRule
- type VirtualHostImpl
- func (vh *VirtualHostImpl) AddRoute(route *v2.Router) error
- func (vh *VirtualHostImpl) GetAllRoutesFromEntries(headers types.HeaderMap, randomValue uint64) []types.Route
- func (vh *VirtualHostImpl) GetRouteFromEntries(headers types.HeaderMap, randomValue uint64) types.Route
- func (vh *VirtualHostImpl) GetRouteFromHeaderKV(key, value string) types.Route
- func (vh *VirtualHostImpl) Name() string
- func (vh *VirtualHostImpl) RemoveAllRoutes()
Constants ¶
const RouterLogFormat = "[router] [%s] [%s] %v"
[sub module] & [function] & msg
Variables ¶
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") )
var ConfigUtilityInst = &configUtility{}
Functions ¶
func GetRouterHeaders ¶
func GetRouterHeaders(headers []v2.HeaderMatcher) []*types.HeaderData
GetRouterHeaders exports getRouterHeaders
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 ¶
type MakeHandlerChain func(context.Context, types.HeaderMap, types.Routers, types.ClusterManager) *RouteHandlerChain
MakeHandlerChain creates a RouteHandlerChain, should not returns a nil handler chain, or the stream filters will be ignored
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 ¶
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) 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) 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) 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 ¶
func (hc *RouteHandlerChain) Next() types.RouteHandler
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) 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) GetAllRoutesFromEntries ¶
func (*VirtualHostImpl) GetRouteFromEntries ¶
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()