toggo

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2025 License: MIT Imports: 8 Imported by: 0

README

Toggo 🚀

A flexible, performant, and production-ready feature flag and A/B testing SDK for Go.

Go Version License

Features

  • Simple on/off feature flags - Control features with boolean flags
  • 📊 Percentage-based rollouts - Gradually roll out features with deterministic hashing
  • 🎯 Conditional targeting - Target users based on attributes (country, plan, custom fields)
  • 🧪 A/B testing - Run experiments with multiple variants
  • ⏱️ Switchback testing - Time-based experimentation for marketplace and system-wide tests
  • 🔒 Thread-safe - Safe for concurrent access
  • 📝 JSON/YAML configuration - Load flags from configuration files
  • 🎨 Flexible operators - Support for ==, !=, in, >, <, contains, regex, and more
  • 🚀 Zero dependencies (except yaml parser)
  • 📦 Clean API - Simple and intuitive interface

Installation

go get github.com/pedrampdd/toggo

Quick Start

package main

import (
    "fmt"
    "github.com/pedrampdd/toggo"
)

func main() {
    // Create a feature flag store
    store := toggo.NewStore()

    // Define a feature flag
    flag := &toggo.Flag{
        Name:    "new_checkout",
        Enabled: true,
        Rollout: 50, // 50% of users
    }
    
    store.AddFlag(flag)

    // Check if enabled for a user
    ctx := toggo.Context{
        "user_id": "12345",
        "country": "US",
    }

    if store.IsEnabled("new_checkout", ctx) {
        // Show new checkout flow
    }
}

Core Concepts

Context

A Context is a map of user attributes used for flag evaluation:

ctx := toggo.Context{
    "user_id": "12345",
    "country": "US",
    "plan":    "premium",
    "age":     25,
}
Flags

Flags control feature availability:

flag := &toggo.Flag{
    Name:       "feature_name",
    Enabled:    true,
    Rollout:    100,        // 0-100 percentage
    RolloutKey: "user_id",  // Context key for hashing (default: "user_id")
    Conditions: []toggo.Condition{
        // Optional targeting conditions
    },
}
Conditions

Target specific users with conditions:

condition := toggo.Condition{
    Attribute: "country",
    Operator:  toggo.OperatorIn,
    Value:     []interface{}{"US", "CA", "UK"},
}
Supported Operators
Operator Description Example
== Equal plan == "premium"
!= Not equal country != "US"
in In list country in ["US", "CA"]
not_in Not in list country not_in ["DE", "FR"]
> Greater than age > 18
>= Greater than or equal age >= 21
< Less than age < 65
<= Less than or equal age <= 25
contains String contains email contains "@company.com"
starts_with String starts with name starts_with "John"
ends_with String ends with file ends_with ".pdf"
regex Regex match email regex ".*@example\\.com"

Usage Examples

Simple Feature Flag
store := toggo.NewStore()

flag := &toggo.Flag{
    Name:    "dark_mode",
    Enabled: true,
    Rollout: 100,
}

store.AddFlag(flag)

ctx := toggo.Context{"user_id": "123"}
if store.IsEnabled("dark_mode", ctx) {
    // Enable dark mode
}
Percentage Rollout
flag := &toggo.Flag{
    Name:       "new_ui",
    Enabled:    true,
    Rollout:    25, // 25% of users
    RolloutKey: "user_id",
}

store.AddFlag(flag)

// Same user always gets same result (deterministic)
ctx := toggo.Context{"user_id": "user_42"}
enabled := store.IsEnabled("new_ui", ctx) // Consistent for this user
Conditional Targeting
flag := &toggo.Flag{
    Name:    "premium_feature",
    Enabled: true,
    Rollout: 100,
    Conditions: []toggo.Condition{
        {
            Attribute: "plan",
            Operator:  toggo.OperatorEqual,
            Value:     "premium",
        },
        {
            Attribute: "country",
            Operator:  toggo.OperatorIn,
            Value:     []interface{}{"US", "CA", "UK"},
        },
    },
}

store.AddFlag(flag)

ctx := toggo.Context{
    "user_id": "123",
    "plan":    "premium",
    "country": "US",
}

// Enabled only if ALL conditions match
if store.IsEnabled("premium_feature", ctx) {
    // Show premium feature
}
A/B Testing
flag := &toggo.Flag{
    Name:           "pricing_test",
    Enabled:        true,
    RolloutKey:     "user_id",
    DefaultVariant: "control",
    Variants: []toggo.Variant{
        {Name: "control", Weight: 33},
        {Name: "price_low", Weight: 33},
        {Name: "price_high", Weight: 34},
    },
}

store.AddFlag(flag)

ctx := toggo.Context{"user_id": "user_42"}
variant, _ := store.GetVariant("pricing_test", ctx)

switch variant {
case "control":
    price = 99.99
case "price_low":
    price = 79.99
case "price_high":
    price = 119.99
}
Switchback Testing

Switchback testing is a time-based experimentation method where all users see the same variant at the same time, and the variant switches at regular intervals. This is useful for:

  • Testing marketplace interventions (e.g., driver incentives, pricing strategies)
  • Comparing system-wide behaviors that can't be tested per-user
  • Controlling for time-of-day effects by alternating patterns daily
// Create a store with switchback strategy
store := toggo.NewStore(
    toggo.WithSwitchback(
        toggo.WithIntervalMinutes(30),  // Switch every 30 minutes
        toggo.WithDailySwap(true),      // Reverse pattern each day
    ),
)

// Define variants to switch between
flag := &toggo.Flag{
    Name:           "driver_rebate",
    Enabled:        true,
    DefaultVariant: "standard_rebate",
    Variants: []toggo.Variant{
        {Name: "standard_rebate", Weight: 50},  // 10% cashback
        {Name: "premium_rebate", Weight: 50},   // 15% cashback
    },
}

store.AddFlag(flag)

// All drivers get the same rebate type at the same time
ctx := toggo.Context{"driver_id": "DRV-12345"}
rebateType, _ := store.GetVariant("driver_rebate", ctx)

switch rebateType {
case "standard_rebate":
    applyCashback(0.10)
case "premium_rebate":
    applyCashback(0.15)
}

// Check timing information
if info := toggo.GetSwitchbackInfo(store); info != nil {
    fmt.Printf("Current interval: %d\n", info.CurrentInterval)
    fmt.Printf("Time until next switch: %v\n", info.TimeUntilSwitch)
}

Switchback Schedule Example (30-minute intervals, 2 variants):

Day 0:

  • 00:00-00:30 → standard_rebate
  • 00:30-01:00 → premium_rebate
  • 01:00-01:30 → standard_rebate
  • ... (pattern continues)

Day 1 (with daily swap):

  • 00:00-00:30 → premium_rebate (reversed)
  • 00:30-01:00 → standard_rebate (reversed)
  • 01:00-01:30 → premium_rebate (reversed)
  • ... (pattern continues)

Key Differences from Standard A/B Testing:

  • Standard A/B: Each user is randomly assigned to a variant (stays consistent)
  • Switchback: All users see the same variant at the same time (switches periodically)
Loading from Configuration Files
JSON
{
  "flags": [
    {
      "name": "new_checkout",
      "enabled": true,
      "rollout": 50,
      "conditions": [
        {
          "attribute": "country",
          "operator": "in",
          "value": ["US", "CA"]
        }
      ]
    }
  ]
}
import "github.com/pedrampdd/toggo/loader"

store := toggo.NewStore()
l := loader.NewJSONFile("flags.json")
l.LoadIntoStore(store)
YAML
flags:
  - name: dark_mode
    enabled: true
    rollout: 100
  - name: beta_features
    enabled: true
    rollout: 25
    conditions:
      - attribute: beta_tester
        operator: "=="
        value: true
import "github.com/pedrampdd/toggo/loader"

store := toggo.NewStore()
l := loader.NewYAMLFile("flags.yaml")
l.LoadIntoStore(store)

API Reference

Store
NewStore(opts ...StoreOption) *Store

Creates a new feature flag store.

AddFlag(flag *Flag) error

Adds or updates a flag in the store. Returns error if validation fails.

IsEnabled(name string, ctx Context) bool

Checks if a feature flag is enabled for the given context. Returns false if flag not found or conditions don't match.

GetVariant(name string, ctx Context) (string, bool)

Returns the variant name for A/B testing. Second return value indicates if flag is enabled.

GetFlag(name string) (*Flag, error)

Retrieves a flag by name. Returns ErrFlagNotFound if not found.

ListFlags() []string

Returns all flag names.

RemoveFlag(name string)

Removes a flag from the store.

Clear()

Removes all flags from the store.

Size() int

Returns the number of flags in the store.

Flag
type Flag struct {
    Name           string
    Enabled        bool
    Rollout        int        // 0-100
    RolloutKey     string     // Default: "user_id"
    Conditions     []Condition
    Variants       []Variant
    DefaultVariant string
}
Condition
type Condition struct {
    Attribute string
    Operator  Operator
    Value     interface{}
    Negate    bool
}
Variant
type Variant struct {
    Name       string
    Weight     int           // 0-100
    Conditions []Condition
}

Project Structure

toggo/
├── toggo.go              # Main package file with documentation
├── context.go            # Context type and methods
├── flag.go              # Flag and Variant types
├── condition.go         # Condition type
├── operator.go          # Operator constants
├── store.go             # Store implementation
├── rollout.go           # Rollout strategy
├── errors.go            # Error definitions
├── internal/            # Internal implementation details
│   ├── evaluator/      # Condition evaluation logic
│   └── hash/           # Hashing for rollouts
├── loader/             # Configuration loaders
│   ├── json.go
│   └── yaml.go
├── examples/           # Usage examples
│   ├── simple/
│   ├── abtest/
│   ├── conditional/
│   └── config_loader/
└── testdata/          # Test fixtures

Testing

Run all tests:

go test ./...

Run with coverage:

go test -cover ./...

Run specific package:

go test ./internal/evaluator

Examples

Explore the examples/ directory for complete working examples:

  • simple - Basic feature flag usage
  • abtest - A/B testing with variants
  • conditional - Conditional targeting
  • switchback - Time-based switchback experiments
  • config_loader - Loading flags from JSON/YAML

Run an example:

cd examples/simple
go run main.go

Best Practices

  1. Use deterministic rollout keys - Always use stable user identifiers (user_id, session_id) for rollout keys to ensure consistent experience.

  2. Validate flags - Flags are validated when added to the store. Handle errors appropriately.

  3. Keep conditions simple - Complex condition trees can impact performance. Consider splitting into multiple flags.

  4. Use variants for A/B tests - Don't use multiple flags for variants of the same experiment.

  5. Load from config files - Store flag definitions in version-controlled YAML/JSON files for easier management.

  6. Test coverage - Always test both enabled and disabled states of features.

Performance

  • Thread-safe - Uses sync.RWMutex for concurrent reads
  • Fast evaluation - O(1) flag lookup, O(n) condition evaluation where n is number of conditions
  • Deterministic hashing - FNV-1a hash for consistent, fast rollout decisions
  • Zero allocations - Designed to minimize allocations in hot paths

Roadmap

  • Remote flag management integration
  • Metrics and analytics hooks
  • Flag scheduling (enable/disable at specific times)
  • User segments for reusable targeting
  • Admin UI for flag management
  • WebSocket/SSE for real-time flag updates

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE file for details

Authors

Built with ❤️ for the Go community


Questions? Open an issue or start a discussion!

Documentation

Overview

Package toggo provides a flexible and performant feature flag and A/B testing SDK for Go.

Toggo enables you to manage feature rollouts, conduct A/B tests, and control feature access with fine-grained targeting conditions. It supports:

  • Simple on/off feature flags
  • Percentage-based rollouts with deterministic hashing
  • Complex conditional targeting (country, plan, custom attributes)
  • A/B testing with multiple variants
  • Thread-safe operations
  • Configuration loading from JSON/YAML files

Basic Usage

Create a store and add a feature flag:

store := toggo.NewStore()
flag := &toggo.Flag{
	Name:    "new_checkout",
	Enabled: true,
	Rollout: 50,
}
store.AddFlag(flag)

Check if a feature is enabled:

ctx := toggo.Context{
	"user_id": "12345",
	"country": "US",
}
if store.IsEnabled("new_checkout", ctx) {
	// Use new checkout flow
}

A/B Testing

For A/B testing with variants:

flag := &toggo.Flag{
	Name:           "pricing_test",
	Enabled:        true,
	DefaultVariant: "control",
	Variants: []toggo.Variant{
		{Name: "control", Weight: 50},
		{Name: "variant_a", Weight: 50},
	},
}
store.AddFlag(flag)

variant, _ := store.GetVariant("pricing_test", ctx)
switch variant {
case "control":
	// Original pricing
case "variant_a":
	// New pricing
}

Conditional Targeting

Add conditions to target specific users:

flag := &toggo.Flag{
	Name:    "premium_feature",
	Enabled: true,
	Rollout: 100,
	Conditions: []toggo.Condition{
		{
			Attribute: "plan",
			Operator:  toggo.OperatorEqual,
			Value:     "premium",
		},
		{
			Attribute: "country",
			Operator:  toggo.OperatorIn,
			Value:     []interface{}{"US", "CA", "UK"},
		},
	},
}

Loading from Configuration Files

Load flags from JSON or YAML:

loader := loader.NewYAMLFile("flags.yaml")
loader.LoadIntoStore(store)

Operators

Toggo supports various comparison operators:

  • == (equal)
  • != (not equal)
  • in (value in list)
  • not_in (value not in list)
  • > (greater than)
  • >= (greater than or equal)
  • < (less than)
  • <= (less than or equal)
  • contains (string contains)
  • starts_with (string starts with)
  • ends_with (string ends with)
  • regex (regular expression match)

Index

Constants

View Source
const (
	// Version is the current version of the toggo SDK
	Version = "1.0.0"
)

Variables

View Source
var (
	// ErrFlagNotFound is returned when a requested flag doesn't exist in the store
	ErrFlagNotFound = errors.New("flag not found")

	// ErrInvalidOperator is returned when an unsupported operator is encountered
	ErrInvalidOperator = errors.New("invalid operator")

	// ErrInvalidRollout is returned when rollout percentage is not between 0 and 100
	ErrInvalidRollout = errors.New("rollout must be between 0 and 100")

	// ErrInvalidCondition is returned when a condition is malformed
	ErrInvalidCondition = errors.New("invalid condition")

	// ErrRolloutKeyMissing is returned when the specified rollout key is not in context
	ErrRolloutKeyMissing = errors.New("rollout key missing from context")
)

Functions

This section is empty.

Types

type Condition

type Condition struct {
	// Attribute is the key to lookup in the context
	Attribute string `json:"attribute" yaml:"attribute"`

	// Operator is the comparison operator to use
	Operator Operator `json:"operator" yaml:"operator"`

	// Value is the value to compare against (can be string, number, array, etc.)
	Value interface{} `json:"value" yaml:"value"`

	// Negate inverts the condition result if true
	Negate bool `json:"negate,omitempty" yaml:"negate,omitempty"`
}

Condition represents a single evaluation condition

func (*Condition) Validate

func (c *Condition) Validate() error

Validate checks if the condition is properly formed

type Context

type Context map[string]interface{}

Context represents the evaluation context containing arbitrary attributes used for feature flag evaluation. It can hold any key-value pairs such as user_id, country, plan, etc.

func (Context) Get

func (c Context) Get(key string) (interface{}, bool)

Get retrieves a value from the context by key. Returns the value and a boolean indicating whether the key exists.

func (Context) GetString

func (c Context) GetString(key string) string

GetString retrieves a string value from the context. Returns empty string if the key doesn't exist or value is not a string.

func (Context) Set

func (c Context) Set(key string, value interface{})

Set adds or updates a key-value pair in the context.

type DefaultRolloutStrategy

type DefaultRolloutStrategy struct {
	// contains filtered or unexported fields
}

DefaultRolloutStrategy implements standard percentage-based rollout

func NewDefaultRolloutStrategy

func NewDefaultRolloutStrategy(hasher hash.Hasher) *DefaultRolloutStrategy

NewDefaultRolloutStrategy creates a new default rollout strategy

func (*DefaultRolloutStrategy) GetVariant

func (r *DefaultRolloutStrategy) GetVariant(flag *Flag, ctx Context) (string, error)

GetVariant determines which variant to return based on weights

func (*DefaultRolloutStrategy) ShouldRollout

func (r *DefaultRolloutStrategy) ShouldRollout(flag *Flag, ctx Context) (bool, error)

ShouldRollout determines if the flag should be enabled based on rollout percentage

type Flag

type Flag struct {
	// Name is the unique identifier for this flag
	Name string `json:"name" yaml:"name"`

	// Enabled controls whether this flag is active
	Enabled bool `json:"enabled" yaml:"enabled"`

	// Rollout is the percentage (0-100) of users who should see this flag
	// when all conditions are met
	Rollout int `json:"rollout,omitempty" yaml:"rollout,omitempty"`

	// RolloutKey specifies which context attribute to use for rollout hashing
	// Defaults to "user_id" if not specified
	RolloutKey string `json:"rollout_key,omitempty" yaml:"rollout_key,omitempty"`

	// Conditions are the rules that must ALL be satisfied for the flag to be enabled
	Conditions []Condition `json:"conditions,omitempty" yaml:"conditions,omitempty"`

	// Variants enables A/B testing with multiple variations
	// If set, IsEnabled returns false and GetVariant should be used instead
	Variants []Variant `json:"variants,omitempty" yaml:"variants,omitempty"`

	// DefaultVariant is returned when no variant matches
	DefaultVariant string `json:"default_variant,omitempty" yaml:"default_variant,omitempty"`
}

Flag represents a feature flag configuration

func (*Flag) GetRolloutKey

func (f *Flag) GetRolloutKey() string

GetRolloutKey returns the key to use for rollout hashing

func (*Flag) HasVariants

func (f *Flag) HasVariants() bool

HasVariants returns true if this flag has A/B test variants configured

func (*Flag) Validate

func (f *Flag) Validate() error

Validate checks if the flag configuration is valid

type Operator

type Operator string

Operator represents a comparison operator for condition evaluation

const (
	// OperatorEqual checks if attribute equals value
	OperatorEqual Operator = "=="

	// OperatorNotEqual checks if attribute does not equal value
	OperatorNotEqual Operator = "!="

	// OperatorIn checks if attribute is in a list of values
	OperatorIn Operator = "in"

	// OperatorNotIn checks if attribute is not in a list of values
	OperatorNotIn Operator = "not_in"

	// OperatorGreaterThan checks if attribute is greater than value
	OperatorGreaterThan Operator = ">"

	// OperatorGreaterThanOrEqual checks if attribute is greater than or equal to value
	OperatorGreaterThanOrEqual Operator = ">="

	// OperatorLessThan checks if attribute is less than value
	OperatorLessThan Operator = "<"

	// OperatorLessThanOrEqual checks if attribute is less than or equal to value
	OperatorLessThanOrEqual Operator = "<="

	// OperatorContains checks if attribute string contains value
	OperatorContains Operator = "contains"

	// OperatorStartsWith checks if attribute string starts with value
	OperatorStartsWith Operator = "starts_with"

	// OperatorEndsWith checks if attribute string ends with value
	OperatorEndsWith Operator = "ends_with"

	// OperatorRegex checks if attribute matches regex pattern
	OperatorRegex Operator = "regex"
)

func (Operator) IsValid

func (o Operator) IsValid() bool

IsValid checks if the operator is supported

type RolloutStrategy

type RolloutStrategy interface {
	// ShouldRollout determines if a flag should be enabled based on rollout percentage
	ShouldRollout(flag *Flag, ctx Context) (bool, error)

	// GetVariant determines which variant to return for A/B testing
	GetVariant(flag *Flag, ctx Context) (string, error)
}

RolloutStrategy defines how rollout decisions are made

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store manages feature flags and provides thread-safe evaluation

func NewStore

func NewStore(opts ...StoreOption) *Store

NewStore creates a new feature flag store

func (*Store) AddFlag

func (s *Store) AddFlag(flag *Flag) error

AddFlag adds or updates a flag in the store

func (*Store) AddFlags

func (s *Store) AddFlags(flags []*Flag) error

AddFlags adds multiple flags to the store

func (*Store) Clear

func (s *Store) Clear()

Clear removes all flags from the store

func (*Store) GetFlag

func (s *Store) GetFlag(name string) (*Flag, error)

GetFlag retrieves a flag by name

func (*Store) GetRolloutStrategy

func (s *Store) GetRolloutStrategy() RolloutStrategy

GetRolloutStrategy returns the current rollout strategy This is useful for accessing strategy-specific features or for testing

func (*Store) GetVariant

func (s *Store) GetVariant(name string, ctx Context) (string, bool)

GetVariant returns the variant for A/B testing Returns the variant name and whether the flag is enabled

func (*Store) GetVariantWithError

func (s *Store) GetVariantWithError(name string, ctx Context) (string, bool, error)

GetVariantWithError returns the variant with detailed error information

func (*Store) IsEnabled

func (s *Store) IsEnabled(name string, ctx Context) bool

IsEnabled checks if a feature flag is enabled for the given context This is the primary method for simple on/off feature flags

func (*Store) IsEnabledWithError

func (s *Store) IsEnabledWithError(name string, ctx Context) (bool, error)

IsEnabledWithError checks if a feature flag is enabled and returns any error

func (*Store) ListFlags

func (s *Store) ListFlags() []string

ListFlags returns all flag names

func (*Store) RemoveFlag

func (s *Store) RemoveFlag(name string)

RemoveFlag removes a flag from the store

func (*Store) Size

func (s *Store) Size() int

Size returns the number of flags in the store

type StoreOption

type StoreOption func(*Store)

StoreOption is a functional option for configuring the Store

func WithSwitchback

func WithSwitchback(opts ...SwitchbackOption) StoreOption

WithSwitchback is a StoreOption that configures switchback testing

type SwitchbackInfo

type SwitchbackInfo struct {
	CurrentInterval  int
	CurrentDay       int
	TimeUntilSwitch  time.Duration
	IntervalDuration time.Duration
}

GetSwitchbackInfo returns detailed information about current switchback state

func GetSwitchbackInfo

func GetSwitchbackInfo(store *Store) *SwitchbackInfo

GetSwitchbackInfo is a convenience method to get switchback info from a store Returns nil if the store is not using switchback strategy

type SwitchbackOption

type SwitchbackOption func(*SwitchbackRolloutStrategy)

SwitchbackOption configures a switchback strategy

func WithDailySwap

func WithDailySwap(enabled bool) SwitchbackOption

WithDailySwap enables swapping the variant order on alternating days Day 0: variants in order, Day 1: variants in reverse order, etc.

func WithIntervalMinutes

func WithIntervalMinutes(minutes int) SwitchbackOption

WithIntervalMinutes sets the duration of each switchback interval in minutes

func WithStartTime

func WithStartTime(t time.Time) SwitchbackOption

WithStartTime sets the reference start time for calculating intervals

type SwitchbackRolloutStrategy

type SwitchbackRolloutStrategy struct {
	// contains filtered or unexported fields
}

SwitchbackRolloutStrategy implements time-based switchback testing In switchback tests, all users see the same variant at the same time, and the variant switches at regular intervals

func NewSwitchbackRolloutStrategy

func NewSwitchbackRolloutStrategy(opts ...SwitchbackOption) *SwitchbackRolloutStrategy

NewSwitchbackRolloutStrategy creates a new switchback rollout strategy

func (*SwitchbackRolloutStrategy) GetCurrentDay

func (s *SwitchbackRolloutStrategy) GetCurrentDay() int

GetCurrentDay returns which day number we're in since start time

func (*SwitchbackRolloutStrategy) GetCurrentInterval

func (s *SwitchbackRolloutStrategy) GetCurrentInterval() int

GetCurrentInterval returns which time interval we're currently in

func (*SwitchbackRolloutStrategy) GetInfo

GetInfo returns detailed switchback timing information

func (*SwitchbackRolloutStrategy) GetTimeUntilNextSwitch

func (s *SwitchbackRolloutStrategy) GetTimeUntilNextSwitch() time.Duration

GetTimeUntilNextSwitch returns how much time until the next interval switch

func (*SwitchbackRolloutStrategy) GetVariant

func (s *SwitchbackRolloutStrategy) GetVariant(flag *Flag, ctx Context) (string, error)

GetVariant returns the current variant based on time interval All users get the same variant at the same time

func (*SwitchbackRolloutStrategy) ShouldRollout

func (s *SwitchbackRolloutStrategy) ShouldRollout(flag *Flag, ctx Context) (bool, error)

ShouldRollout always returns true for switchback tests since all users participate

func (*SwitchbackRolloutStrategy) String

func (s *SwitchbackRolloutStrategy) String() string

String returns a human-readable description of the switchback state

type Variant

type Variant struct {
	// Name is the variant identifier
	Name string `json:"name" yaml:"name"`

	// Weight is the percentage (0-100) of traffic allocated to this variant
	Weight int `json:"weight" yaml:"weight"`

	// Conditions are additional conditions specific to this variant
	Conditions []Condition `json:"conditions,omitempty" yaml:"conditions,omitempty"`
}

Variant represents an A/B test variant

Directories

Path Synopsis
examples
ab_testing command
abtest command
basic command
conditional command
conditions command
config_loader command
simple command
switchback command
yaml_config command
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL