router

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: May 31, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

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 Router

type Router interface {
	Init() error
	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