HOOQTV / fished

Fish answers from rules and facts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fished

Migrated to https://github.coupang.net/coupang/couplay-fished

Fish answers from rules and facts

Install

$ go get -u github.com/jonathansudibya/fished

or using dep

$ dep ensure -add github.com/jonathansudibya/fished

Structs

Rule :

type Rule struct {
	Output 			string   `json:"output"`
	Input  			[]string `json:"input"`
	Expression   	string   `json:"expression"`
	...
}

Engine:

type Engine struct {
    Facts         map[string]interface{}
	Rules         []Rule
	RuleFunctions map[string]govaluate.ExpressionFunction
	Jobs          chan int
    ...
}

Example

Please see in test file especially TestRun() function.

package main

import "github.com/jonathansudibya/fished"

func main() {
	e := fished.New(nil)
	e.SetRules([]Rule{
		Rule{
			Input: []string{"hello"},
			Output: "result_end",
			Expression: "hello == 'world'",
		}
	})
	e.SetFacts = map[string]interface{}{
		"hello": "world"
	}
	res, errs := e.Run()

	fmt.Println(res) // will result true
}

Notes

Remember it is more expensive to set new rules than to set facts.

Credits

This project is powered by

LICENSE

See LICENSE.md

About

Fish answers from rules and facts

License:MIT License


Languages

Language:Go 100.0%