rules

package
v0.0.0-...-5e23df6 Latest Latest
Warning

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

Go to latest
Published: May 20, 2016 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const RuleActionApprove = "approve"
View Source
const RuleActionChallenge = "challenge"
View Source
const RuleActionReject = "reject"

Variables

This section is empty.

Functions

func BenchmarkHello

func BenchmarkHello(b *testing.B)

func GetAvailableRules

func GetAvailableRules() []string

func RegisterRule

func RegisterRule(name string, f CreateRuleFunc)

func Run

func Run()

Run the rules server

Types

type CreateRuleFunc

type CreateRuleFunc func() IsRule

type IsRule

type IsRule interface {
	Exec() (r *RuleResult, err error)
}

func MakeRuleInstance

func MakeRuleInstance(name string) IsRule

type RuleContext

type RuleContext struct {
	Config  map[string]string
	Context map[string]string
	Event   map[string]string
}

type RuleModel

type RuleModel struct {
	Name   string
	Code   string
	Params string
}

func NewRule

func NewRule(name string, code string) *RuleModel

func (*RuleModel) GetRuleCode

func (m *RuleModel) GetRuleCode() (IsRule, error)

type RuleResult

type RuleResult struct {
	IsMatched      bool
	Action         string
	Score          int
	Channels       []string
	ContextActions map[string]string
}

func (*RuleResult) ActionPrio

func (m *RuleResult) ActionPrio(currentAction string) string

ActionPrio If current action has a higher priority return that, else return the result action

type RulesService

type RulesService interface {
	Check(model m.RuleAPIRequest) (res m.RuleAPIResponse, err error)
	Rules() (rules []string, err error)
}

type SimpleRule

type SimpleRule struct {
}

SimpleRule Test rule that does not do much

func (*SimpleRule) Exec

func (c *SimpleRule) Exec() (*RuleResult, error)

Exec Execute it

type SimpleRuleService

type SimpleRuleService struct {
}

func (SimpleRuleService) Check

func (s SimpleRuleService) Check(request m.RuleAPIRequest) (res *m.RuleAPIResponse, err error)

func (SimpleRuleService) Rules

func (s SimpleRuleService) Rules() (rules []string, err error)

type VelocityCheckRule

type VelocityCheckRule struct {
}

func (*VelocityCheckRule) Exec

func (c *VelocityCheckRule) Exec() (*RuleResult, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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