Documentation ¶
Index ¶
- Constants
- func GetStringFromUserValue(ctx *fasthttp.RequestCtx, key string) string
- func InitGogate(gogateConfigFile, logConfigFile string)
- func RateLimitPreFilter(s *Server, ctx *fasthttp.RequestCtx, newRequest *fasthttp.Request) bool
- func ServiceMatchPreFilter(s *Server, ctx *fasthttp.RequestCtx, newRequest *fasthttp.Request) bool
- func UrlRewritePreFilter(s *Server, ctx *fasthttp.RequestCtx, newRequest *fasthttp.Request) bool
- type CanaryInfo
- type GogateResponse
- type InsInfoArrSyncMap
- type InsLbClientSyncMap
- type InstanceInfo
- type PostFilter
- type PostFilterFunc
- type PreFilter
- type PreFilterFunc
- type RateLimiterSyncMap
- type Router
- type ServInfoSyncMap
- type Server
- func (serv *Server) AppendPostFilter(post *PostFilter)
- func (serv *Server) AppendPreFilter(pre *PreFilter)
- func (serv *Server) ExportAllPostFilters() []*PostFilter
- func (serv *Server) ExportAllPreFilters() []*PreFilter
- func (serv *Server) ExtractRoute() string
- func (serv *Server) HandleRequest(ctx *fasthttp.RequestCtx)
- func (serv *Server) InsertPostFilterAhead(filter *PostFilter)
- func (serv *Server) InsertPostFilterBehind(filterName string, filter *PostFilter) bool
- func (serv *Server) InsertPreFilterAhead(filter *PreFilter)
- func (serv *Server) InsertPreFilterBehind(filterName string, filter *PreFilter) bool
- func (serv *Server) ReloadRoute() error
- func (serv *Server) Shutdown() error
- func (serv *Server) Start() error
- func (serv *Server) WaitForGracefullyClose() error
- type ServiceInfo
- type StrStrSyncMap
Constants ¶
View Source
const ( // 默认最大连接数 MAX_CONNECTION = 5000 // 注册信息更新间隔, 秒 REGISTRY_REFRESH_INTERVAL = 60 )
View Source
const ( SERVICE_NAME = "key_service_name" REQUEST_PATH = "key_request_path" ROUTE_INFO = "key_route_info" RELOAD_PATH = "/_mgr/reload" )
View Source
const META_VERSION = "version"
Variables ¶
This section is empty.
Functions ¶
func GetStringFromUserValue ¶
func GetStringFromUserValue(ctx *fasthttp.RequestCtx, key string) string
从请求上下文中取出string
func InitGogate ¶
func InitGogate(gogateConfigFile, logConfigFile string)
func RateLimitPreFilter ¶
控制QPS的前置过虑器
func ServiceMatchPreFilter ¶
func UrlRewritePreFilter ¶
Types ¶
type CanaryInfo ¶
type GogateResponse ¶
func NewResponse ¶
func NewResponse(path, msg string) *GogateResponse
func (*GogateResponse) Send ¶
func (resp *GogateResponse) Send(ctx *fasthttp.RequestCtx)
func (*GogateResponse) SendWithStatus ¶
func (resp *GogateResponse) SendWithStatus(ctx *fasthttp.RequestCtx, statusCode int)
func (*GogateResponse) ToJson ¶
func (resp *GogateResponse) ToJson() string
func (*GogateResponse) ToJsonBytes ¶
func (resp *GogateResponse) ToJsonBytes() []byte
type InsInfoArrSyncMap ¶
type InsInfoArrSyncMap struct {
// contains filtered or unexported fields
}
封装sync.map, 提供类型安全的方法调用
func NewInsInfoArrSyncMap ¶
func NewInsInfoArrSyncMap() *InsInfoArrSyncMap
func (*InsInfoArrSyncMap) Each ¶
func (ism *InsInfoArrSyncMap) Each(eachFunc func(key string, val []*InstanceInfo) bool)
func (*InsInfoArrSyncMap) Get ¶
func (ism *InsInfoArrSyncMap) Get(key string) ([]*InstanceInfo, bool)
func (*InsInfoArrSyncMap) GetMap ¶
func (ism *InsInfoArrSyncMap) GetMap() *sync.Map
func (*InsInfoArrSyncMap) Put ¶
func (ism *InsInfoArrSyncMap) Put(key string, val []*InstanceInfo)
type InsLbClientSyncMap ¶
type InsLbClientSyncMap struct {
// contains filtered or unexported fields
}
封装sync.map, 提供类型安全的方法调用
func NewInsMetaLbClientSyncMap ¶
func NewInsMetaLbClientSyncMap() *InsLbClientSyncMap
type InstanceInfo ¶
封装服务实例信息
type PostFilter ¶
type PostFilter struct { FilterFunc PostFilterFunc Name string }
后置过滤器对象
func NewPostFilter ¶
func NewPostFilter(name string, filter PostFilterFunc) *PostFilter
func (*PostFilter) String ¶
func (pf *PostFilter) String() string
type PostFilterFunc ¶
后置过滤器函数
type PreFilter ¶
type PreFilter struct { FilterFunc PreFilterFunc Name string }
前置过滤器对象
func NewPreFilter ¶
func NewPreFilter(name string, filter PreFilterFunc) *PreFilter
type PreFilterFunc ¶
type PreFilterFunc func(server *Server, ctx *fasthttp.RequestCtx, newRequest *fasthttp.Request) bool
前置过滤器函数
type RateLimiterSyncMap ¶
type RateLimiterSyncMap struct {
// contains filtered or unexported fields
}
封装sync.map, 提供类型安全的方法调用
func NewRateLimiterSyncMap ¶
func NewRateLimiterSyncMap() *RateLimiterSyncMap
func (*RateLimiterSyncMap) Get ¶
func (rsm *RateLimiterSyncMap) Get(key string) (throttle.RateLimiter, bool)
func (*RateLimiterSyncMap) Put ¶
func (rsm *RateLimiterSyncMap) Put(key string, val throttle.RateLimiter)
type Router ¶
type Router struct { ServInfos []*ServiceInfo // contains filtered or unexported fields }
func (*Router) Match ¶
func (r *Router) Match(reqPath string) *ServiceInfo
* 根据uri选择一个最匹配的appId * * RETURNS: * 返回最匹配的ServiceInfo
type ServInfoSyncMap ¶
type ServInfoSyncMap struct {
// contains filtered or unexported fields
}
封装sync.map, 提供类型安全的方法调用
func NewServInfoSyncMap ¶
func NewServInfoSyncMap() *ServInfoSyncMap
func (*ServInfoSyncMap) Each ¶
func (ssm *ServInfoSyncMap) Each(eachFunc func(key string, val *ServiceInfo) bool)
func (*ServInfoSyncMap) Get ¶
func (ssm *ServInfoSyncMap) Get(key string) (*ServiceInfo, bool)
func (*ServInfoSyncMap) GetMap ¶
func (ssm *ServInfoSyncMap) GetMap() *sync.Map
func (*ServInfoSyncMap) Put ¶
func (ssm *ServInfoSyncMap) Put(key string, val *ServiceInfo)
type Server ¶
type Server struct { // URI路由组件 Router *Router // contains filtered or unexported fields }
func NewGatewayServer ¶
func NewGatewayServer(host string, port int, routePath string, maxConn int, useGracefullyShutdown bool, maxWait time.Duration) (*Server, error)
* 创建网关服务对象 * * PARAMS: * - host: 主机名(ip) * - port: 端口 * - routePath: 路由配置文件路径 * - maxConn: 最大连接数, 0表示使用默认值 *
func (*Server) AppendPostFilter ¶
func (serv *Server) AppendPostFilter(post *PostFilter)
注册过滤器, 追加到末尾
func (*Server) ExportAllPostFilters ¶
func (serv *Server) ExportAllPostFilters() []*PostFilter
导出所有后置过滤器
func (*Server) ExportAllPreFilters ¶
导出所有前置过滤器
func (*Server) HandleRequest ¶
func (serv *Server) HandleRequest(ctx *fasthttp.RequestCtx)
HTTP请求处理方法.
func (*Server) InsertPostFilterAhead ¶
func (serv *Server) InsertPostFilterAhead(filter *PostFilter)
在最头部添加后置过滤器
func (*Server) InsertPostFilterBehind ¶
func (serv *Server) InsertPostFilterBehind(filterName string, filter *PostFilter) bool
在指定后置过滤器的后面添加; filterName: 在此过滤器后面添加filter, 如果要在队头添加, 则使用空字符串 filter: 过滤器对象
func (*Server) InsertPreFilterAhead ¶
在最头部添加前置过滤器
func (*Server) InsertPreFilterBehind ¶
在指定前置过滤器的后面添加
func (*Server) WaitForGracefullyClose ¶
需要在Shutdown()之后调用, 此方法会一直block直到所有连接关闭或者超时
type ServiceInfo ¶
type ServiceInfo struct { Id string Prefix string Host string StripPrefix bool `yaml:"strip-prefix"` Qps int Canary []*CanaryInfo }
func GetServiceInfoFromUserValue ¶
func GetServiceInfoFromUserValue(ctx *fasthttp.RequestCtx, key string) (*ServiceInfo, bool)
从请求上下文中取出*ServiceInfo
func (*ServiceInfo) String ¶
func (info *ServiceInfo) String() string
type StrStrSyncMap ¶
type StrStrSyncMap struct {
// contains filtered or unexported fields
}
封装sync.map, 提供类型安全的方法调用
func NewStrStrSyncMap ¶
func NewStrStrSyncMap() *StrStrSyncMap
func (*StrStrSyncMap) Each ¶
func (ssm *StrStrSyncMap) Each(eachFunc func(key string, val string) bool)
func (*StrStrSyncMap) GetMap ¶
func (ssm *StrStrSyncMap) GetMap() *sync.Map
func (*StrStrSyncMap) Put ¶
func (ssm *StrStrSyncMap) Put(key string, val string)
Source Files ¶
- filter_def.go
- filter_rate_limit.go
- filter_serv_match.go
- filter_url_rewrite.go
- init.go
- registry_refresh.go
- router.go
- server.go
- server_context.go
- server_filter.go
- server_handler.go
- server_request.go
- server_response.go
- syncmap_ins_info_arr.go
- syncmap_ins_meta_lbclient.go
- syncmap_rate_limiter.go
- syncmap_serv_info.go
- syncmap_str.go
Click to show internal directories.
Click to hide internal directories.