Documentation
¶
Index ¶
- Variables
- func AdminAuth() func(c *gin.Context)
- func CORS() gin.HandlerFunc
- func Cache() func(c *gin.Context)
- func CriticalRateLimit() func(c *gin.Context)
- func Distribute() func(c *gin.Context)
- func DownloadRateLimit() func(c *gin.Context)
- func GlobalAPIRateLimit() func(c *gin.Context)
- func GlobalWebRateLimit() func(c *gin.Context)
- func GzipDecodeMiddleware() gin.HandlerFunc
- func Language() gin.HandlerFunc
- func RelayPanicRecover() gin.HandlerFunc
- func RequestId() func(c *gin.Context)
- func RootAuth() func(c *gin.Context)
- func SelectChannel(ctx context.Context, group, requestModel string, lastFailedChannelId int, ...) (*model.Channel, string, error)
- func SetUpLogger(server *gin.Engine)
- func SetupContextForSelectedChannel(c *gin.Context, channel *model.Channel, modelName string)
- func TokenAuth() func(c *gin.Context)
- func TokenModelMapping() func(c *gin.Context)
- func TurnstileCheck() gin.HandlerFunc
- func UploadRateLimit() func(c *gin.Context)
- func UserAuth() func(c *gin.Context)
- type AffinityManager
- type CooldownManager
- type ModelRequest
Constants ¶
This section is empty.
Variables ¶
View Source
var AffinityGlobal = NewAffinityManager(config.AffinityExpireSeconds)
View Source
var CooldownGlobal = NewCooldownManager(config.ChannelCooldownSeconds)
Functions ¶
func CORS ¶
func CORS() gin.HandlerFunc
func CriticalRateLimit ¶
func Distribute ¶
func DownloadRateLimit ¶
func GlobalAPIRateLimit ¶
func GlobalWebRateLimit ¶
func GzipDecodeMiddleware ¶
func GzipDecodeMiddleware() gin.HandlerFunc
func Language ¶
func Language() gin.HandlerFunc
func RelayPanicRecover ¶
func RelayPanicRecover() gin.HandlerFunc
func SelectChannel ¶
func SetUpLogger ¶
func TokenModelMapping ¶
TokenModelMapping 根据 token 的 ModelMapping 配置,把 ctxkey.RequestModel 映射为目标模型名 只修改 ctxkey.RequestModel,不修改原始请求体 token 的 ModelMapping 字符串由 TokenAuth 中间件预先解析并放入 context 后续的 Distribute 中间件会基于映射后的 RequestModel 选择渠道 后续渠道级的模型映射依然按原有逻辑执行
func TurnstileCheck ¶
func TurnstileCheck() gin.HandlerFunc
func UploadRateLimit ¶
Types ¶
type AffinityManager ¶
type AffinityManager struct {
// contains filtered or unexported fields
}
func NewAffinityManager ¶
func NewAffinityManager(seconds int) *AffinityManager
func (*AffinityManager) Get ¶
func (am *AffinityManager) Get(userId int, model string) (channelId int, ok bool)
func (*AffinityManager) Remove ¶
func (am *AffinityManager) Remove(userId int, model string)
type CooldownManager ¶
type CooldownManager struct {
// contains filtered or unexported fields
}
func NewCooldownManager ¶
func NewCooldownManager(seconds int) *CooldownManager
func (*CooldownManager) IsCoolingDown ¶
func (cm *CooldownManager) IsCoolingDown(channelId int) bool
func (*CooldownManager) Put ¶
func (cm *CooldownManager) Put(channelId int)
func (*CooldownManager) Reset ¶
func (cm *CooldownManager) Reset(channelId int)
type ModelRequest ¶
type ModelRequest struct {
Model string `json:"model" form:"model"`
}
Click to show internal directories.
Click to hide internal directories.