Skip to content
This repository has been archived by the owner on Jul 27, 2021. It is now read-only.

HOOQTV/fished

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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