rule

package
v0.0.0-...-f1540b3 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2016 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	Rules RuleRepository
}

func NewHandler

func NewHandler() *Handler

func (*Handler) Add

func (h *Handler) Add(w http.ResponseWriter, r *http.Request)

func (*Handler) AddRules

func (h *Handler) AddRules(rules RuleRepository)

func (*Handler) Delete

func (h *Handler) Delete(w http.ResponseWriter, r *http.Request)

func (*Handler) RemoveRule

func (h *Handler) RemoveRule(id int)

func (*Handler) SetRoutes

func (h *Handler) SetRoutes(r *mux.Router)

type Rule

type Rule struct {
	Id int `json:"id"`

	Setup string `json:"setup,omitempty"`

	When string `json:"when"`
	Then string `json:"then"`
}

Rules will have when-then structure. Rule execution should be decoupled. When a rule is executed, it won't have a link to the next rule. It will be applied to all the applicable rules. When and Then clauses will be P* code.

type RuleRepository

type RuleRepository []Rule

func (*RuleRepository) ToString

func (r *RuleRepository) ToString() string

Build a rule file from a rule repository:

Setup: def AnInt: {sint64 i} def AFloat: {fp32 f} When: when (Numbers numbers): return Then: then (Numbers numbers): return

Jump to

Keyboard shortcuts

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