// Package abstract ... // // Description : abstract ... // // Author : go_developer@163.com<白茶清欢> // // Date : 2024-06-20 11:33 package abstract import "context" // IRateLimit 流控实现接口约束 // // Author : go_developer@163.com<白茶清欢> // // Date : 11:33 2024/6/20 type IRateLimit interface { Second(ctx context.Context, key string, total, rate int) (bool, error) // 每秒访问次数限制 Minute(ctx context.Context, key string, total, rate int) (bool, error) // 每分钟访问次数限制 Hour(ctx context.Context, key string, total, rate int) (bool, error) // 每小时访问次数限制 Day(ctx context.Context, key string, total, rate int) (bool, error) // 每天访问次数限制 Month(ctx context.Context, key string, total, rate int) (bool, error) // 每月访问次数限制 Year(ctx context.Context, key string, total, rate int) (bool, error) // 每年访问次数限制 Custom(ctx context.Context, timeInfo int64, key string, total, rate int) (bool, error) // 自定义指定时间内的访问次数, timeInfo 单位 : s }