// ================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// You can delete these comments if you wish manually maintain this interface file.
// ================================================================================

package service

import (
	"context"
	"kami/internal/model"
)

type (
	IRate interface {
		// Check 检查限流
		Check(ctx context.Context, limiterType model.LimiterType, key string) *model.LimiterResult
		// CheckWithConfig 使用自定义配置检查限流
		CheckWithConfig(ctx context.Context, config *model.LimiterConfig, key string) *model.LimiterResult
		// Allow 简单的限流检查，返回是否允许通过
		Allow(ctx context.Context, limiterType model.LimiterType, key string) bool
		// GetLimiterConfig 获取限流器配置
		GetLimiterConfig(limiterType model.LimiterType) *model.LimiterConfig
		// SetLimiterConfig 设置限流器配置（运行时修改）
		SetLimiterConfig(limiterType model.LimiterType, config *model.LimiterConfig) error
		// Reset 重置指定key的限流计数
		Reset(ctx context.Context, limiterType model.LimiterType, key string) error
		// GetRemaining 获取剩余可用次数
		GetRemaining(ctx context.Context, limiterType model.LimiterType, key string) int
	}
)

var (
	localRate IRate
)

func Rate() IRate {
	if localRate == nil {
		panic("implement not found for interface IRate, forgot register?")
	}
	return localRate
}

func RegisterRate(i IRate) {
	localRate = i
}
