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

Plan file structure suggested changes #1

Open
ibrasho opened this issue Dec 14, 2017 · 0 comments
Open

Plan file structure suggested changes #1

ibrasho opened this issue Dec 14, 2017 · 0 comments

Comments

@ibrasho
Copy link

ibrasho commented Dec 14, 2017

I'd recommend the plan structs to be changed to the following:

type Rule struct {
    RuleSelector RuleSelector `json:"selector,omitempty"`
    RuleAction   RuleAction   `json:"action,omitempty"`
}

type RuleSelector struct {
	// SelectRule does prefix matching on this value
    ClientAddr string  `json:"client_addr,omitempty"`
    Command    string  `json:"command,omitempty"`
    Percentage float64 `json:"percentage,omitempty"`
}

type RuleAction struct {
	Delay       int  `json:"delay,omitempty"`
	Drop        bool `json:"drop,omitempty"`
	ReturnEmpty bool `json:"return_empty,omitempty"`
}

Which would result in the following JSON:

{
    "rules": [
        {
            "selector": {
                "command": "GET",
            },
            "action": {
                "delay": 1000
            },
        },
        {
            "selector": {
                "clientAddr": "159.0.147.225",
                "percentage": 50,
            },
            "action": {
                "drop": true
            },
        },
        {
            "selector": {
                "percentage": 50,
            },
            "action": {
                "returnEmpty": true
            }
        }
    ]
}

Adding support for YAML is recommended too.

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

No branches or pull requests

1 participant