rule

package
v0.0.0-...-c53c3a1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2020 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Evaluate

func Evaluate(rules *[]*Rule, ctx *fasthttp.RequestCtx) types.ResponseState

func RulesLength

func RulesLength(rules []*Rule) uint64

Types

type Aggregation

type Aggregation struct {
	sync.RWMutex
	Values   map[string]uint64
	Selector *selector.Selector
}

func (*Aggregation) Get

func (a *Aggregation) Get(ctx *fasthttp.RequestCtx) uint64

type Rule

type Rule struct {
	Interval uint64 `json:"interval"`
	Limit    uint64 `json:"limit"`
	Name     string `json:"name"`

	MatchCount uint64 `json:"match_count"`

	Filters         []*selector.Selector `json:"-"`
	RawFilters      []string             `json:"filters"`
	Aggregations    []*Aggregation       `json:"-"`
	RawAggregations []string             `json:"aggregations"`
	Actions         []action.Action      `json:"-"`
	RawActions      []action.ActionJSON  `json:"actions"`
	SubRules        []*Rule              `json:"subrules"`
	Disabled        bool                 `json:"disabled"`
	Stop            bool                 `json:"stop"`
	// contains filtered or unexported fields
}

func New

func New(name string, interval, limit uint64, filters []string) (*Rule, error)

func ParseJSON

func ParseJSON(jsonData []byte) ([]*Rule, error)

func ParseJSONFile

func ParseJSONFile(filename string) ([]*Rule, error)

func (*Rule) Init

func (r *Rule) Init() error

func (*Rule) ParseAggregations

func (r *Rule) ParseAggregations(aggregations []string) error

func (*Rule) ParseFilters

func (r *Rule) ParseFilters(filters []string) error

func (*Rule) Validate

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL