go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/sdk/featureflag/flag_config.go (about)

     1  /*
     2  
     3  Copyright (c) 2024 - Present. Will Charczuk. All rights reserved.
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository.
     5  
     6  */
     7  
     8  package featureflag
     9  
    10  type FlagConfig struct {
    11  	Name       string        `yaml:"name"`
    12  	Parameters []string      `yaml:"parameters"`
    13  	Rollout    []RolloutRule `yaml:"rollout"`
    14  }
    15  
    16  // RolloutRule is a specific cohort to enable the flag for
    17  // according to some split percentage.
    18  type RolloutRule struct {
    19  	// Match filters the parameters the flag applies to.
    20  	Match Predicate `yaml:"match"`
    21  	// EnabledRatio is the fraction of parameters to
    22  	// randomly and consistently select for the flag
    23  	// to be enabled for. It should be on the
    24  	// interval [0.0,1.0].
    25  	EnabledRatio float64 `yaml:"enabled_ratio"`
    26  }
    27  
    28  // Predicate is a rollout rule logical filter.
    29  type Predicate struct {
    30  	Parameter string   `yaml:"parameter"`
    31  	In        []string `yaml:"in"`
    32  }