Documentation
¶
Overview ¶
Package flags provides a runtime feature flag system for Drover. Supports gradual rollouts, kill switches, and per-project overrides.
Index ¶
- type Config
- type Flag
- type FlagRollout
- type FlagType
- type FlagUpdate
- type Manager
- func (m *Manager) AddBlacklist(flagID, projectID string) error
- func (m *Manager) AddWhitelist(flagID, projectID string) error
- func (m *Manager) Get(id string) *Flag
- func (m *Manager) GetBool(id string) bool
- func (m *Manager) GetBoolForProject(id, projectID string) bool
- func (m *Manager) GetFloat(id string) float64
- func (m *Manager) GetInt(id string) int
- func (m *Manager) GetRolloutConfig(id string) (*FlagRollout, error)
- func (m *Manager) GetString(id string) string
- func (m *Manager) List() []*Flag
- func (m *Manager) LoadFromFile(path string) error
- func (m *Manager) SaveToFile(path string) error
- func (m *Manager) Set(id string, value interface{}) error
- func (m *Manager) SetLogger(logger *log.Logger)
- func (m *Manager) SetPercentage(flagID string, percentage int) error
- func (m *Manager) SetRolloutConfig(id string, rollout *FlagRollout) error
- func (m *Manager) Stop()
- func (m *Manager) Watch(ctx context.Context) <-chan *FlagUpdate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Flag ¶
type Flag struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Type FlagType `json:"type"`
Default interface{} `json:"default"`
Value interface{} `json:"value"`
Rollout *FlagRollout `json:"rollout,omitempty"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
}
Flag represents a single feature flag
type FlagRollout ¶
type FlagRollout struct {
Enabled bool `json:"enabled"`
Percentage int `json:"percentage"` // 0-100
Whitelist []string `json:"whitelist"` // Project IDs that always get the feature
Blacklist []string `json:"blacklist"` // Project IDs that never get the feature
}
FlagRollout defines percent-based rollout configuration
type FlagUpdate ¶
FlagUpdate represents a flag change notification
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages feature flags with runtime configuration
func NewManager ¶
NewManager creates a new feature flag manager
func (*Manager) AddBlacklist ¶
AddBlacklist adds a project ID to a flag's blacklist
func (*Manager) AddWhitelist ¶
AddWhitelist adds a project ID to a flag's whitelist
func (*Manager) GetBoolForProject ¶
GetBoolForProject returns a boolean flag value for a specific project Takes rollout configuration into account
func (*Manager) GetRolloutConfig ¶
func (m *Manager) GetRolloutConfig(id string) (*FlagRollout, error)
GetRolloutConfig returns the rollout configuration for a flag
func (*Manager) LoadFromFile ¶
LoadFromFile loads flags from a JSON file
func (*Manager) SaveToFile ¶
SaveToFile saves flags to a JSON file
func (*Manager) SetPercentage ¶
SetPercentage sets the rollout percentage for a flag
func (*Manager) SetRolloutConfig ¶
func (m *Manager) SetRolloutConfig(id string, rollout *FlagRollout) error
SetRolloutConfig sets the rollout configuration for a flag