Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoMatchedRule = errors.New("no matched rules")
Functions ¶
This section is empty.
Types ¶
type CounterService ¶
type CounterService interface { Increment(ctx context.Context, key string, n uint32, ttl int64, syncRate int) (uint32, error) IncrementOnStorage(ctx context.Context, key string, n uint32, ttl int64) (uint32, error) Get(ctx context.Context, key string) (uint32, error) GetFromStorage(ctx context.Context, key string) (uint32, error) }
type DescriptorLabel ¶
type DomainRules ¶
type LimiterService ¶
type LimiterService struct {
// contains filtered or unexported fields
}
func NewLimiterService ¶
func NewLimiterService( rulesService RulesService, counterService CounterService, logger *logrus.Logger, registerer prometheus.Registerer) *LimiterService
func (*LimiterService) ShouldRateLimit ¶
func (l *LimiterService) ShouldRateLimit(ctx context.Context, req *pb.RateLimitRequest) (response *pb.RateLimitResponse, err error)
type Rule ¶
type Rule struct { Name string `yaml:"name"` Labels []DescriptorLabel `yaml:"labels"` Limit Limit `yaml:"limit"` SyncRate int `yaml:"syncRate"` InnerRank int }
type RulesConfig ¶
type RulesConfig struct {
Domains []*DomainRules `yaml:"domains"`
}
type RulesService ¶
type RulesService interface {
GetRatelimitRule(domain string, requestDescriptor *rl.RateLimitDescriptor) (*Rule, error)
}
Click to show internal directories.
Click to hide internal directories.