flags

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: MIT Imports: 7 Imported by: 0

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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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

func NewClient(baseURL string) *Client

NewClient returns a Client routed through the local nginx proxy (port 3305). Callers should rely on the default URL; override only in tests.

func (*Client) Disable

func (c *Client) Disable(ctx context.Context, key string) (*Flag, error)

Disable sets a flag to enabled=false and broadcasts pubsub invalidation.

func (*Client) Enable

func (c *Client) Enable(ctx context.Context, key string) (*Flag, error)

Enable sets a flag to enabled=true.

func (*Client) Get

func (c *Client) Get(ctx context.Context, key string) (*Flag, error)

Get returns a single flag by key.

func (*Client) History

func (c *Client) History(ctx context.Context, key string) ([]AuditEntry, error)

History returns the audit log for a single flag.

func (*Client) Kill

func (c *Client) Kill(ctx context.Context, key, reason string) (*Flag, error)

Kill performs an emergency kill-switch on a flag. reason is required.

func (*Client) List

func (c *Client) List(ctx context.Context, flagType string) ([]Flag, error)

List returns all feature flags, optionally filtered by type.

func (*Client) Prune

func (c *Client) Prune(ctx context.Context, dryRun bool) ([]Flag, error)

Prune lists flags that have exceeded their stale_after_days threshold. When dryRun is true, no flags are deleted.

func (*Client) Set

func (c *Client) Set(ctx context.Context, key string, req SetFlagRequest) (*Flag, error)

Set updates a flag's enabled state and/or rollout percentage.

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"`
	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 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.

Jump to

Keyboard shortcuts

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