Documentation
¶
Index ¶
- Constants
- func BuildBFERateLimitRedisKey(policyID int64, ruleType string, name string) string
- func BuildRateLimitRedisKeys(policyID int64, rules *RateLimitRules) []string
- func DiffRateLimitRedisKeys(policyID int64, oldRules, newRules *RateLimitRules) []string
- type AiRouteFallbackParam
- type AiRouteRuleParam
- type AiRouteTargetParam
- type BalanceSummary
- type EntityFilter
- type EntityStorager
- type EntitySummary
- type QuotaPlanParam
- type QuotaPlanStorager
- type RPMConfig
- type RateLimitPolicyParam
- type RateLimitPolicyStorager
- type RateLimitRules
- type RouteRulesFilter
- type RouteRulesParam
- type RouteRulesStorager
- type RouteTableParam
- type TPMConfig
Constants ¶
const ( RouteRulesTypeAPIKey = "apikey" RouteRulesTypeEntity = "entity" RouteRulesTypeGlobal = "global" )
Variables ¶
This section is empty.
Functions ¶
func BuildBFERateLimitRedisKey ¶ added in v0.0.8
BuildBFERateLimitRedisKey 构造 BFE 实际使用的完整 Redis Key。 控制面在导出时直接下发完整 Key,BFE 侧优先使用该 Key 而不再拼接前缀。
func BuildRateLimitRedisKeys ¶ added in v0.0.8
func BuildRateLimitRedisKeys(policyID int64, rules *RateLimitRules) []string
BuildRateLimitRedisKeys 根据限流规则生成 BFE 实际使用的完整 Redis Key 列表。 该函数供 API-Key / Entity 删除或更新时清理 Redis Key 使用。
func DiffRateLimitRedisKeys ¶ added in v0.0.8
func DiffRateLimitRedisKeys(policyID int64, oldRules, newRules *RateLimitRules) []string
DiffRateLimitRedisKeys 比较新旧限流策略,返回被删除规则的 Redis Key 列表。 规则按 name 匹配;旧策略中存在但新策略中不存在的 name 视为被删除。
Types ¶
type AiRouteFallbackParam ¶
type AiRouteFallbackParam struct {
ClusterName *string `json:"cluster_name"`
Model *string `json:"model"`
}
func (*AiRouteFallbackParam) UnmarshalJSON ¶
func (f *AiRouteFallbackParam) UnmarshalJSON(data []byte) error
UnmarshalJSON accepts both the new snake_case keys and the legacy camel-case keys for backward compatibility.
type AiRouteRuleParam ¶
type AiRouteRuleParam struct {
Name *string `json:"name"`
Cond *string `json:"cond"`
Targets []*AiRouteTargetParam `json:"targets"`
Fallbacks []*AiRouteFallbackParam `json:"fallbacks"`
}
func (*AiRouteRuleParam) UnmarshalJSON ¶
func (r *AiRouteRuleParam) UnmarshalJSON(data []byte) error
UnmarshalJSON accepts both the new snake_case keys and the legacy camel-case keys for backward compatibility.
type AiRouteTargetParam ¶
type AiRouteTargetParam struct {
ClusterName *string `json:"cluster_name"`
Model *string `json:"model"`
Weight *int `json:"weight"`
}
func (*AiRouteTargetParam) UnmarshalJSON ¶
func (t *AiRouteTargetParam) UnmarshalJSON(data []byte) error
UnmarshalJSON accepts both the new snake_case keys and the legacy camel-case keys for backward compatibility with existing database records and old clients. Serialization continues to emit only the new keys.
type BalanceSummary ¶
type EntityFilter ¶
type EntityStorager ¶
type EntityStorager interface {
FetchEntity(ctx context.Context, filter *EntityFilter) (*EntitySummary, error)
}
type EntitySummary ¶
type QuotaPlanParam ¶
type QuotaPlanParam struct {
Unlimited *bool `json:"unlimited"`
PassWhenNoEnoughQuota *bool `json:"pass_when_no_enough_quota"`
Quota *float64 `json:"quota"`
Unit *string `json:"unit"`
ResetPeriod *string `json:"reset_period"`
LastResetAt *time.Time `json:"last_reset_at,omitempty"`
Balance *BalanceSummary `json:"balance,omitempty"`
}
type QuotaPlanStorager ¶
type QuotaPlanStorager interface {
CreateQuotaPlan(ctx context.Context, param *QuotaPlanParam) (int64, error)
UpdateQuotaPlan(ctx context.Context, id int64, param *QuotaPlanParam) (int64, error)
DeleteQuotaPlan(ctx context.Context, id int64) error
FetchQuotaPlan(ctx context.Context, id int64) (*QuotaPlanParam, error)
}
type RateLimitPolicyParam ¶
type RateLimitPolicyParam struct {
Enabled *bool `json:"enabled"`
Rules *RateLimitRules `json:"rules"`
}
type RateLimitPolicyStorager ¶
type RateLimitPolicyStorager interface {
CreateRateLimitPolicy(ctx context.Context, param *RateLimitPolicyParam) (int64, error)
UpdateRateLimitPolicy(ctx context.Context, id int64, param *RateLimitPolicyParam) (int64, error)
DeleteRateLimitPolicy(ctx context.Context, id int64) error
FetchRateLimitPolicy(ctx context.Context, id int64) (*RateLimitPolicyParam, error)
}
type RateLimitRules ¶
type RouteRulesFilter ¶
type RouteRulesFilter struct {
Type *string `form:"type"`
Owner *string `form:"owner"`
Enabled *bool `form:"enabled"`
Page *int `form:"page"`
PageSize *int `form:"page_size"`
SortBy *string `form:"sort_by"`
SortOrder *string `form:"sort_order"`
}
RouteRulesFilter defines filters for querying route rules
type RouteRulesParam ¶
type RouteRulesParam struct {
ID *int64 `json:"-"`
Enabled *bool `json:"enabled"`
Rules []*AiRouteRuleParam `json:"rules"`
}
type RouteRulesStorager ¶
type RouteRulesStorager interface {
CreateRouteRules(ctx context.Context, ruleType string, owner *string, param *RouteRulesParam) (int64, error)
FetchRouteRules(ctx context.Context, ruleType string, owner *string) (*RouteRulesParam, error)
FetchRouteRulesList(ctx context.Context, filter *RouteRulesFilter) ([]*RouteTableParam, int64, error)
UpdateRouteRules(ctx context.Context, id int64, param *RouteRulesParam) (int64, error)
DeleteRouteRules(ctx context.Context, id int64) error
FetchRouteRulesByID(ctx context.Context, id int64) (*RouteRulesParam, error)
// FetchAllRouteRules returns all route rules without pagination.
// Used by reference checkers that must scan every rule table.
FetchAllRouteRules(ctx context.Context) ([]*RouteRulesParam, error)
}
RouteRulesStorager defines storage operations for route rules