Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow nested composites #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

becoded
Copy link

@becoded becoded commented Apr 12, 2018

Add support to nest composites

@huttotw
Copy link
Owner

huttotw commented Apr 12, 2018

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.

@becoded
Copy link
Author

becoded commented Apr 12, 2018

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"
                  }
                ]
              }
            ]
          }
        ]
      }
    ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants