Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewProcessor ¶
func NewProcessor(cfg *common.Config) (processors.Processor, error)
NewProcessor returns new processor instance.
Types ¶
type BucketLimiter ¶
type BucketLimiter struct {
// contains filtered or unexported fields
}
func NewBucketLimiter ¶
func NewBucketLimiter(bucketInterval, limit, buckets int64, now time.Time) *BucketLimiter
func (*BucketLimiter) Allow ¶
func (bl *BucketLimiter) Allow(t time.Time) bool
Allow returns TRUE if event is allowed to be processed.
func (*BucketLimiter) LastUpdate ¶
func (bl *BucketLimiter) LastUpdate() time.Time
LastUpdate returns last Allow method call time.
func (*BucketLimiter) SetLimit ¶
func (bl *BucketLimiter) SetLimit(limit int64)
SetLimit updates limit value. Note: it's allowed only to change limit, not bucketInterval.
func (*BucketLimiter) WriteStatus ¶
func (bl *BucketLimiter) WriteStatus(w io.Writer) error
WriteStatus writes text based status into Writer.
type ConditionLimiter ¶
type ConditionLimiter struct {
// contains filtered or unexported fields
}
ConditionLimiter first checks if event is valid for specified conditions and then applies rate limiting.
func NewConditionLimiter ¶
func NewConditionLimiter(fields map[string]string, bucketInterval, limit, buckets int64, now time.Time) (*ConditionLimiter, error)
NewConditionLimiter returns new ConditionLimiter instance.
func (*ConditionLimiter) Allow ¶
func (cl *ConditionLimiter) Allow(t time.Time) bool
Allow returns TRUE if event is allowed to be processed.
func (*ConditionLimiter) Check ¶
func (cl *ConditionLimiter) Check(e *beat.Event) bool
Check checks if event satisfies condition.
func (*ConditionLimiter) SetLimit ¶
func (cl *ConditionLimiter) SetLimit(limit int64)
SetLimit updates limit value. Note: it's allowed only to change limit, not bucketInterval.
func (*ConditionLimiter) WriteStatus ¶
func (cl *ConditionLimiter) WriteStatus(w io.Writer) error
WriteStatus writes text based status into Writer.
type Config ¶
type Config struct { PolicyHost string `config:"policy_host"` PolicyUpdateInterval time.Duration `config:"policy_update_interval"` PrometheusPort int `config:"prometheus_port"` BucketSize int64 `config:"bucket_size"` Buckets int64 `config:"buckets"` MetricName string `config:"metric_name"` MetricLabels []LabelMapping `config:"metric_labels"` }
Config defines processor configuration.
func (Config) GetMetricLabels ¶
type LabelMapping ¶
type Processor ¶
type Processor struct {
// contains filtered or unexported fields
}
Processor make rate-limiting for messages.
func (*Processor) RunHTTPHandlers ¶
RunHTTPHandlers runs prometheus handler on specified port.
type RemoteConfig ¶
type RemoteConfig struct { Key string `yaml:"key"` DefaultLimit int64 `yaml:"default_limit"` Rules []RuleConfig `yaml:"rules"` }
type RemoteLimiter ¶
type RemoteLimiter struct {
// contains filtered or unexported fields
}
func NewRemoteLimiter ¶
func NewRemoteLimiter(url string, bucketInterval, buckets int64) (*RemoteLimiter, error)
NewRemoteLimiter creates new remote limiter instance.
func (*RemoteLimiter) Allow ¶
func (rl *RemoteLimiter) Allow(e *beat.Event) bool
Allow returns TRUE if event is allowed to be processed.
func (*RemoteLimiter) Update ¶
func (rl *RemoteLimiter) Update(ctx context.Context) error
Update retrieves policies from Policy Manager.
func (*RemoteLimiter) UpdateWithInterval ¶
UpdateWithInterval runs update with some interval.
func (*RemoteLimiter) WriteStatus ¶
func (rl *RemoteLimiter) WriteStatus(w io.Writer) error
type Rule ¶
type Rule struct {
// contains filtered or unexported fields
}