dipper-engine

command module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2022 License: GPL-3.0 Imports: 3 Imported by: 0

README

Rule Engine Golang

Go CodeQL Coverage Status

Setup

$ go build

Run

$ dipper-engine -h

NAME:
   Dipper Engine - Rule Engine

USAGE:
   Dipper Engine [global options] command [command options] [arguments...]

COMMANDS:
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --bus value, -b value       Bus type: [chan, redis] (default: "chan")
   --config value, -c value    Config file (default: "config.json")
   --help, -h                  show help (default: false)
   --plugin, -p                Load Plugin (default: false)
   --queue value, -q value     Queue type: [chan, redis] (default: "chan")
   --redis-host value          Redis host (default: "127.0.0.1:6379")
   --redis-pass value          Redis pass
   --redis-timeout value       Redis Time out
   --session-from-queue, --sq  Session from queue (default: false)
   --store value, -s value     Store type: [memory, redis] (default: "memory")


$ dipper-engine

Start Dipper Engine

Rules: 5
-----------------------------------------------------------
No Rule Name   Worker Status
1  log-core    1      enable
2  arithmetic  1      enable
3  fork        1      enable
4  conditional 1      enable
5  switch      1      enable
-----------------------------------------------------------

Running Engine...

Example Developer Test


c := engine.New()

c.Hook(engine.AfterStart, func(dipper *core.DipperEngine, c *cli.Context) error {
    return dipper.Add(context.Background(), &data.Session{
        Data: map[string]interface{}{
            "default": map[string]interface{}{
                "a": 10, 
                "b": 20, 
                "d": 5,
            },
        },
        ChanId:   "test-1",
        RootNode: "1",
        MapNode: map[string]*data.NodeRule{
            "1": {
                Debug: true,
                Option: map[string]interface{}{
                    "list": map[string]interface{}{
						"default.c": map[string]interface{}{
                            "right": map[string]interface{}{
                                "value": "default.a",
                                "type":  "val",
                            },
                            "left": map[string]interface{}{
                                "type":  "val",
                                "value": "default.b",
                            },
                            "operator": "add",
                            "type":     "operator",
                        },
                    },
                    "next_error":   "2",
                    "next_success": "3",
                    "debug":        true,
                },
                NodeId: "4",
                RuleId: "arithmetic",
                End:    false,
            },
            "2": {
                Debug: true,
                Option: map[string]interface{}{
                    "debug": true,
                },
                NodeId: "2",
                RuleId: "log-core",
                End:    true,
            },
            "3": {
                Debug: true,
                Option: map[string]interface{}{
                    "next_success": []string{"5", "2"},
                    "debug":        true,
                },
                NodeId: "3",
                RuleId: "fork",
                End:    false,
            },
            "5": {
                Debug: true,
                Option: map[string]interface{}{
                    "operator": map[string]interface{}{ 
						"right": map[string]interface{}{
                            "value": "default.a",
                            "type":  "val",
                        },
                        "left": map[string]interface{}{
                            "type":  "val",
                            "value": "default.b",
                        },
                        "operator": "==",
                        "type":     "operator",
                    },
                    "set_param_result_to": "default.cond_a_b",
                    "next_error":          "2",
                    "next_true":           "2",
                    "next_false":          "2",
                    "debug":               true,
                },
                NodeId: "5",
                RuleId: "conditional",
                End:    false,
            },
		},
    })
})

if err := c.Run(os.Args); err != nil {
    log.Fatal(err)
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
daq
examples
base module
redis-queue module
internal
rules
log

Jump to

Keyboard shortcuts

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