router

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package router expose API for user to get or set route rule

Index

Constants

View Source
const RouterTLS = "router"

RouterTLS defines tls prefix

Variables

View Source
var ErrNoExist = errors.New("router not exists")

ErrNoExist means if there is no router implementation

View Source
var Templates = make(map[string]*model.Match)

Templates is for source match template settings

Functions

func BuildRouter

func BuildRouter(name string) error

BuildRouter create a router

func FitRate

func FitRate(tags []*model.RouteTag, dest string) *model.RouteTag

FitRate fit rate

func Init

func Init() error

Init initialize router config

func InstallRouterService

func InstallRouterService(name string, f func() (Router, error))

InstallRouterService install router service for developer

func Match

func Match(match model.Match, headers map[string]string, source *registry.SourceInfo) bool

Match check the route rule

func QuickSort

func QuickSort(left int, right int, rules []*model.RouteRule) (s []*model.RouteRule)

QuickSort for sorting the routes it will follow quicksort technique

func Route

func Route(header map[string]string, si *registry.SourceInfo, inv *invocation.Invocation) error

Route route the APIs

func SortRules

func SortRules(name string) []*model.RouteRule

SortRules sort route rules

func SourceMatch

func SourceMatch(match *model.Match, headers map[string]string, source *registry.SourceInfo) bool

SourceMatch check the source route

func ValidateRule

func ValidateRule(rules map[string][]*model.RouteRule) bool

ValidateRule validate the route rules of each service

Types

type Options added in v0.7.1

type Options struct {
	Endpoints []string
	EnableSSL bool
	TLSConfig *tls.Config
	Version   string
}

Options defines how to init router and its fetcher

func (Options) ToPilotOptions added in v0.7.1

func (o Options) ToPilotOptions() *client.PilotOptions

ToPilotOptions translate options to client options

type Router

type Router interface {
	Init(Options) error
	InitRouteRuleByKey(string)
	SetRouteRule(map[string][]*model.RouteRule)
	FetchRouteRule() map[string][]*model.RouteRule
	FetchRouteRuleByServiceName(string) []*model.RouteRule
}

Router return route rule, you can also set custom route rule

var DefaultRouter Router

DefaultRouter is current router implementation

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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