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

Add metadata structure #8

Open eabili0 opened 4 years ago

eabili0 commented 4 years ago

The code would benefit a lot from a metadata structure that defines exactly what ruller-dsl expects from a json rule. With the usage of Go's json annotations, a good part of the parsing logic can be removed.

Proposal:

type RuleGroup struct {
    Label string `json:"label,omitempty"`
    Config Config `json:"_config"`
    Groups map[string]interface{} `json:"_groups"`
    Items []Item `json:"_items"`
} 

type Config struct {
    Seed int `json:"seed"`
    DefaultCondition interface{} `json:"default_condition,omitempty"` 
}

type Item struct {
    Label string `json:"label"`
    Items []Item `json:"label"`
    Custom map[string]interface{} `json:"-"` // unkown fields should go here
    Condition string `json:"_condition"`
}
flaviostutz commented 4 years ago

This is good for maintenance, but will require some work on this. Agree that this will enhance maintainability.