mid

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Copyright 2021 GoFast Author(http://chende.ren). All rights reserved. Use of this source code is governed by a MIT license

Copyright 2021 GoFast Author(http://chende.ren). All rights reserved. Use of this source code is governed by a MIT license

Copyright 2021 GoFast Author(http://chende.ren). All rights reserved. Use of this source code is governed by a MIT license

Copyright 2020 GoFast Author(http://chende.ren). All rights reserved. Use of this source code is governed by a MIT license

Copyright 2021 GoFast Author(http://chende.ren). All rights reserved. Use of this source code is governed by a MIT license

Copyright 2021 GoFast Author(http://chende.ren). All rights reserved. Use of this source code is governed by a MIT license

Copyright 2021 GoFast Author(http://chende.ren). All rights reserved. Use of this source code is governed by a MIT license

Copyright 2021 GoFast Author(http://chende.ren). All rights reserved. Use of this source code is governed by a MIT license

Copyright 2021 GoFast Author(http://chende.ren). All rights reserved. Use of this source code is governed by a MIT license

Copyright 2021 GoFast Author(http://chende.ren). All rights reserved. Use of this source code is governed by a MIT license

Copyright 2021 GoFast Author(http://chende.ren). All rights reserved. Use of this source code is governed by a MIT license

Copyright 2021 GoFast Author(http://chende.ren). All rights reserved. Use of this source code is governed by a MIT license

Index

Constants

This section is empty.

Variables

View Source
var AllAttrs allAttrs // 所有配置项汇总

Functions

func Breaker

func Breaker(kp *gate.RequestKeeper) fst.CtxHandler

请求分析,针对不同路由分别执行熔断策略

func Gunzip

func Gunzip(useGunzip bool) fst.CtxHandler

func HttpMaxConnections

func HttpMaxConnections(limit int32) fst.HttpHandler

限制最大并发连接数,相当于做一个请求资源数量连接池

func HttpMaxContentLength

func HttpMaxContentLength(limit int64) fst.HttpHandler

全局判断所有请求类型的最大长度

func HttpReqCountPos

func HttpReqCountPos(kp *gate.RequestKeeper, pos uint16) fst.HttpHandler

访问计数

func LoadShedding

func LoadShedding(kp *gate.RequestKeeper, useShedding bool, idx uint16) fst.CtxHandler

自适应降载,前面熔断还是有一定比例的请求会通过。这里通过各种参数动态调整熔断的敏感度 可能参考指标: 1. cpu利用率 > 95% 2. 通过的请求中超时的比例 3. 处理超时的严重程度 4. 业务优先级 5. 用户优先级

func Logger

func Logger(c *fst.Context)

func LoggerMini

func LoggerMini(c *fst.Context)

func MaxContentLength

func MaxContentLength(c *fst.Context)

限制当前路径的请求最大数据长度

func Prometheus

func Prometheus(c *fst.Context)

func Recovery

func Recovery(c *fst.Context)

截获异常,防止程序崩溃。

func ReqCount

func ReqCount(kp *gate.RequestKeeper) fst.CtxHandler

func ReqCountPos

func ReqCountPos(kp *gate.RequestKeeper, idx uint16) fst.CtxHandler

func TimeMetric

func TimeMetric(kp *gate.RequestKeeper) fst.CtxHandler

++++++++++++++++++++++ add by cd.net 2021.10.14 总说:定时统计(间隔60秒)系统资源利用情况 | 请求处理相应性能 | 请求量 等

func Timeout

func Timeout(kp *gate.RequestKeeper, useTimeout bool) fst.CtxHandler

方式二:设置请求处理的超时时间,单位是毫秒 TODO:注意下面的注释 NOTE:这个只是简易的方案,存在不严谨的情况。比如返回结果render了一部分,结果G被Cancel掉了。上面的标准库处理了这个问题。 方式一却自定义了 response write 加入了 输出缓存,返回结果全部好了之后才会一次性 render 给客户端。

func TimeoutHandler

func TimeoutHandler(duration time.Duration) func(http.Handler) http.Handler

方式一:标准库 这种方式有个问题,大量请求其实是不会超时的,每次外面都包一层浪费资源

func Tracing

func Tracing(appName string, useTracing bool) fst.CtxHandler

启动链路追踪

Types

type Attrs

type Attrs struct {
	RIndex    uint16 `v:""`                       // 索引位置
	Priority  int16  `v:"def=500,range=[0:1000]"` // 业务优先级
	MaxLen    int64  `v:""`                       // 最大请求长度,0不限制
	TimeoutMS int32  `v:""`                       // 超时时间毫秒

}

func (*Attrs) SetRouteIndex

func (ras *Attrs) SetRouteIndex(routeIdx uint16)

Jump to

Keyboard shortcuts

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