grules
grules copied to clipboard
Allow nested composites
Add support to nest composites
Thanks for the PR! What use case are you trying to solve with nested composites? Is it something that can be solved with multiple rules potentially?
I have used this package pretty extensively and have not come across this need, so I'm interested to hear your use case.
Hello @huttotw I'm working on a system that distribute S3 events to multiple queues based on some business rules. Each queue has 3 different priorities. Based on some metadata (origin, amount of pages in a document, ...), type of the file, name of the file and the expected processing priority, the right queue + priority is selected.
I have some business rules that looks like ( ( A && B && C ) || (E && F && ( G || H) )
Or converted to json:
"composites": [
{
"operator": "or",
"composites": [
{
"operator": "and",
"rules": [
{
"comparator": "eq",
"path": "pathToA",
"value": "A"
},
{
"comparator": "eq",
"path": "pathToB",
"value": "B"
},
{
"comparator": "eq",
"path": "pathToC",
"value": "C"
}
]
}, {
"operator": "and",
"rules": [
{
"comparator": "eq",
"path": "pathToE",
"value": "E"
},
{
"comparator": "eq",
"path": "pathToF",
"value": "F"
}
],
"composites": [
{
"operator": "or",
"rules": [
{
"comparator": "eq",
"path": "pathToG",
"value": "G"
},
{
"comparator": "eq",
"path": "pathToH",
"value": "H"
}
]
}
]
}
]
}
]