flaviostutz / ruller-dsl-feature-flag

A feature flag engine that can be used to enable, change or rollout features of a system dynamically based on system or user attributes
MIT License
2 stars 6 forks source link

Behavior when condition's needed input parameter is not found during evaluation #11

Closed flaviostutz closed 4 years ago

flaviostutz commented 4 years ago

This discussion is a continuation of https://github.com/flaviostutz/ruller/issues/5.

flaviostutz commented 4 years ago

So, what do you think about placing this option at the "config" node of the rules json? Something like:

{
    "_config": {
        "seed": 123,
        "default_condition": true,
        "lazy_evaluation": false,
        "flatten": true,
    },
    "_items": [{
            "provider": "aws",
            "_condition": "randomPerc(10, input:customerid)",
            "_items": [{
                    "region": "sa-east-1",
                    "login": "login.sa-east-1.test.com",
                    "bootcamp": "bootcamp.sa-east-1.test.com",
                    "_condition": "input:_ip_country=='Brazil'"
                },
                {
                    "region": "us-west-1",
                    "login": "login.us-west-1.test.com",
                    "events": "events.us-west-1.test.com",
                    "bootcamp": "bootcamp.us-west-1.test.com"
                }
            ]
        },
        {
            "provider": "azure",
            "_condition": "randomPercRange(10, 50, input:customerid)",
            "_items": [{
                    "region": "azure-brazil",
                    "login": "login.azure-brazil.test.com",
                    "_condition": "input:_ip_country=='Brazil'"
                },
                {
                    "region": "azure-ny",
                    "login": "login.azure-ny.test.com",
                    "events": "events.azure-ny.test.com",
                    "bootcamp": "bootcamp.azure-ny.test.com"
                }
            ]
        },
        {
            "provider": "vpsdime",
            "_items": [{
                "region": "vpsdime",
                "login": "login.vpsdime.test.com",
                "events": "events.azure-ny.test.com",
                "bootcamp": "bootcamp.azure-ny.test.com"
            }]
        }
    ]
}

I suggest "lazy_evaluation" default value to be "false" because we will stop throwing errors when a required input is not present, so that it will be much harder to detect when the caller is sending wrong values to ruller.

What do you think?