bow

package
v0.0.0-...-796898b Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package bow 网关服务包

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Route

func Route(engine *gin.Engine, filter func(result *response.Result) bool)

Route 网关服务路由

func RunBow

func RunBow(context *gin.Context, serviceName string, filter func(result *response.Result) bool)

RunBow 开启路由

func RunBowCallback

func RunBowCallback(context *gin.Context, serviceName string, filter func(result *response.Result) bool, f func() *response.Result)

RunBowCallback 开启路由并处理降级

func YamlServices

func YamlServices(data []byte)

YamlServices YML转路由对象数组

Types

type Bow

type Bow struct {
	AllWay map[string]*RouteService
}

Bow 路由入口对象

func GetBowInstance

func GetBowInstance() *Bow

GetBowInstance 获取路由管理对象 Bow 单例

func (*Bow) Add

func (s *Bow) Add(routeServiceArr ...*RouteService)

Add 新增路由服务数组

func (*Bow) AddService

func (s *Bow) AddService(serviceName, inURI, outRemote string)

AddService 新增路由服务

func (*Bow) AddServices

func (s *Bow) AddServices(routeServiceArr []*RouteService)

AddServices 新增路由服务数组

type Limit

type Limit struct {
	LimitMillisecond         int64    `yaml:"LimitMillisecond"`         // 请求限定的时间段(毫秒)
	LimitCount               int      `yaml:"LimitCount"`               // 请求限定的时间段内允许的请求次数
	LimitIntervalMillisecond int64    `yaml:"LimitIntervalMillisecond"` // 请求允许的最小间隔时间(毫秒),0表示不限
	LimitChan                chan int // 限流通道
	Times                    []int64  // 请求时间数组
}

Limit 限流对象

type RouteService

type RouteService struct {
	Name      string `yaml:"Name"`      // 服务名称
	InURI     string `yaml:"InURI"`     // 路由入口 URI
	OutRemote string `yaml:"OutRemote"` // 路由出口地址
	Limit     *Limit `yaml:"Limit"`     // 服务限流策略
}

RouteService 路由对象

type RouteServices

type RouteServices struct {
	Routes []*RouteService `yaml:"routes"`
}

RouteServices 路由对象数组

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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