Documentation
¶
Overview ¶
Package flags provides a thin REST client over the nself feature-flags plugin (port 3305, nginx-proxied). All requests go through the nginx route so no direct port access is ever used.
Package flags — flag lifecycle helpers (sunset and removal date enforcement).
Index ¶
- func ApplyLifecycleDisable(flags []Flag, now time.Time) int
- type AuditEntry
- type Client
- func (c *Client) Disable(ctx context.Context, key string) (*Flag, error)
- func (c *Client) Enable(ctx context.Context, key string) (*Flag, error)
- func (c *Client) Get(ctx context.Context, key string) (*Flag, error)
- func (c *Client) History(ctx context.Context, key string) ([]AuditEntry, error)
- func (c *Client) Kill(ctx context.Context, key, reason string) (*Flag, error)
- func (c *Client) List(ctx context.Context, flagType string) ([]Flag, error)
- func (c *Client) Prune(ctx context.Context, dryRun bool) ([]Flag, error)
- func (c *Client) Set(ctx context.Context, key string, req SetFlagRequest) (*Flag, error)
- type Flag
- type KillRequest
- type LifecycleWarning
- type SetFlagRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuditEntry ¶
type AuditEntry struct {
ID string `json:"id"`
FlagKey string `json:"flag_key"`
Actor string `json:"actor"`
Action string `json:"action"`
Before json.RawMessage `json:"before"`
After json.RawMessage `json:"after"`
Reason *string `json:"reason"`
Ts time.Time `json:"ts"`
}
AuditEntry is a row from np_feature_flags_audit.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a thin REST client for the feature-flags plugin.
func NewClient ¶
NewClient returns a Client routed through the local nginx proxy (port 3305). Callers should rely on the default URL; override only in tests.
type Flag ¶
type Flag struct {
ID string `json:"id"`
Key string `json:"key"`
Name *string `json:"name"`
Description *string `json:"description"`
Type string `json:"type"`
Enabled bool `json:"enabled"`
RolloutPct *int `json:"rollout_pct"`
DefaultValue json.RawMessage `json:"default_value"`
Rules json.RawMessage `json:"rules"`
SunsetAt *time.Time `json:"sunset_at,omitempty"`
RemovalDate *time.Time `json:"removal_date,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Flag is a feature flag as returned by the plugin API.
type KillRequest ¶
type KillRequest struct {
Reason string `json:"reason"`
}
KillRequest is the body for the kill operation.
type LifecycleWarning ¶ added in v1.0.16
LifecycleWarning describes a sunset/removal enforcement event for a flag.
func CheckFlagLifecycle ¶ added in v1.0.16
func CheckFlagLifecycle(flags []Flag, now time.Time) []LifecycleWarning
CheckFlagLifecycle inspects each flag's SunsetAt and RemovalDate fields against the supplied "now" timestamp and returns warnings for flags that are past sunset (level=warn) or past removal (level=error).
A flag with no SunsetAt/RemovalDate produces no warning. A flag with SunsetAt in the future produces no warning.
type SetFlagRequest ¶
type SetFlagRequest struct {
Enabled *bool `json:"enabled,omitempty"`
RolloutPct *int `json:"rollout_pct,omitempty"`
Reason *string `json:"reason,omitempty"`
}
SetFlagRequest is the body for the set/update operation.