|
| 1 | +## RuleAction |
| 2 | +RuleAction is a flogo action which allows events to be injected into the rules engine via a flogo trigger. |
| 3 | + |
| 4 | +### Configuration |
| 5 | +RuleAction configuration contains 2 parts, settings and resources. |
| 6 | + |
| 7 | +#### settings |
| 8 | + |
| 9 | +| Name | Type | Description | |
| 10 | +|:-----------|:--------|:--------------| |
| 11 | +| id | string | id is referenced by an element in another section of flogo configuration such as trigger handler action's id | |
| 12 | +| rulesessionURI | uri | Uri that starts with 'res://rulesession:'. It's referenced in the resources section | |
| 13 | +| tds | array | Tuple definitions | |
| 14 | + |
| 15 | + |
| 16 | +#### tds |
| 17 | +| Name | Type | Description | |
| 18 | +|:-----------|:--------|:--------------| |
| 19 | +| name | string | Tuple type name | |
| 20 | +| properties | array | Properties of the tuple | |
| 21 | + |
| 22 | + |
| 23 | +#### properties |
| 24 | +| Name | Type | Description | |
| 25 | +|:-----------|:--------|:--------------| |
| 26 | +| name | string | Property name | |
| 27 | +| type | string | Data type of the property | |
| 28 | +| pk-index | int | Tuple key order. If -1, not used as part of tuple key | |
| 29 | + |
| 30 | +#### resources |
| 31 | + |
| 32 | +| Name | Type | Description | |
| 33 | +|:-----------|:--------|:--------------| |
| 34 | +| id | string | id is referenced by an element in another section of flogo configuration such as action settings's rulesessionURI | |
| 35 | +| data | object | metadata and rule defintions | |
| 36 | + |
| 37 | +#### metadata |
| 38 | +It contains an array of input element comprised of 2 parameters, values and tupletype. |
| 39 | + |
| 40 | +| Name | Type | Description | |
| 41 | +|:-----------|:--------|:--------------| |
| 42 | +| values | string | Tuple values | |
| 43 | +| tupletype | string | Tupple type that the values parameter adheres to | |
| 44 | + |
| 45 | +#### rules |
| 46 | +| Name | Type | Description | |
| 47 | +|:-----------|:--------|:--------------| |
| 48 | +| name | string | Name of the rule | |
| 49 | +| conditions | array | Conditions that the rule evaluates given input | |
| 50 | +| actionFunction | string | Rule action function to be fired when conditions are true. The function must exist in functions.go | |
| 51 | + |
| 52 | +#### conditions |
| 53 | + |
| 54 | +| Name | Type | Description | |
| 55 | +|:-----------|:--------|:--------------| |
| 56 | +| name | string | Name of the condition | |
| 57 | +| identifiers | array | Tuple types the condition evaluates upon | |
| 58 | +| evaluator | string | Function that envaluates the condition. The function must exist in functions.go | |
| 59 | + |
| 60 | + |
| 61 | +### Usage |
| 62 | + |
| 63 | +Upon a configuration of flogo.json containing ruleaction configuration and creation of functions.go which contains the evaluator and actionFunction implementations, place flogo.json in a folder of your choice to run |
| 64 | +``` |
| 65 | +flogo create -f flogo.json myrules |
| 66 | +cp functions.go myrules/src |
| 67 | +cd myrules |
| 68 | +flogo build |
| 69 | +``` |
| 70 | +To run the flogo rules binary, |
| 71 | +``` |
| 72 | +bin/myrules |
| 73 | +``` |
| 74 | + |
| 75 | + |
| 76 | +### Examples |
| 77 | +For examples, see [rules flogo examples](https://github.com/project-flogo/rules/tree/master/examples/flogo). |
0 commit comments