Documentation ¶
Index ¶
- Constants
- Variables
- func WalkDocuments(logger *zap.Logger, src fs.FS, fn func(*ext.Document) error) error
- func WithInterval(interval time.Duration) containers.Option[Poller]
- func WithNotify(t *testing.T, n func(modified bool)) containers.Option[Poller]
- func WithValidatorOption(opts ...validation.FeaturesValidatorOption) containers.Option[SnapshotOption]
- type CacheBuildFunc
- type FliptIndex
- type Poller
- type ReferencedSnapshotStore
- type SingleReferenceSnapshotStore
- type Snapshot
- func SnapshotFromFS(logger *zap.Logger, src fs.FS, opts ...containers.Option[SnapshotOption]) (*Snapshot, error)
- func SnapshotFromFiles(logger *zap.Logger, files []fs.File, opts ...containers.Option[SnapshotOption]) (*Snapshot, error)
- func SnapshotFromPaths(logger *zap.Logger, ffs fs.FS, paths []string, ...) (*Snapshot, error)
- func (ss *Snapshot) CountFlags(ctx context.Context, p storage.NamespaceRequest) (uint64, error)
- func (ss *Snapshot) CountNamespaces(ctx context.Context, _ storage.ReferenceRequest) (uint64, error)
- func (ss *Snapshot) CountRollouts(ctx context.Context, flag storage.ResourceRequest) (uint64, error)
- func (ss *Snapshot) CountRules(ctx context.Context, req storage.ResourceRequest) (uint64, error)
- func (ss *Snapshot) CountSegments(ctx context.Context, p storage.NamespaceRequest) (uint64, error)
- func (ss *Snapshot) GetEvaluationDistributions(ctx context.Context, rule storage.IDRequest) ([]*storage.EvaluationDistribution, error)
- func (ss *Snapshot) GetEvaluationRollouts(ctx context.Context, flag storage.ResourceRequest) ([]*storage.EvaluationRollout, error)
- func (ss *Snapshot) GetEvaluationRules(ctx context.Context, flag storage.ResourceRequest) ([]*storage.EvaluationRule, error)
- func (ss *Snapshot) GetFlag(ctx context.Context, req storage.ResourceRequest) (*flipt.Flag, error)
- func (ss *Snapshot) GetNamespace(ctx context.Context, p storage.NamespaceRequest) (*flipt.Namespace, error)
- func (ss *Snapshot) GetRollout(ctx context.Context, p storage.NamespaceRequest, id string) (*flipt.Rollout, error)
- func (ss *Snapshot) GetRule(ctx context.Context, p storage.NamespaceRequest, id string) (rule *flipt.Rule, _ error)
- func (ss *Snapshot) GetSegment(ctx context.Context, req storage.ResourceRequest) (*flipt.Segment, error)
- func (ss *Snapshot) GetVersion(context.Context, storage.NamespaceRequest) (string, error)
- func (ss *Snapshot) ListFlags(ctx context.Context, req *storage.ListRequest[storage.NamespaceRequest]) (set storage.ResultSet[*flipt.Flag], err error)
- func (ss *Snapshot) ListNamespaces(ctx context.Context, req *storage.ListRequest[storage.ReferenceRequest]) (set storage.ResultSet[*flipt.Namespace], err error)
- func (ss *Snapshot) ListRollouts(ctx context.Context, req *storage.ListRequest[storage.ResourceRequest]) (set storage.ResultSet[*flipt.Rollout], err error)
- func (ss *Snapshot) ListRules(ctx context.Context, req *storage.ListRequest[storage.ResourceRequest]) (set storage.ResultSet[*flipt.Rule], _ error)
- func (ss *Snapshot) ListSegments(ctx context.Context, req *storage.ListRequest[storage.NamespaceRequest]) (set storage.ResultSet[*flipt.Segment], err error)
- func (ss Snapshot) String() string
- type SnapshotCache
- func (c *SnapshotCache[K]) AddFixed(ctx context.Context, ref string, k K, s *Snapshot)
- func (c *SnapshotCache[K]) AddOrBuild(ctx context.Context, ref string, k K, build CacheBuildFunc[K]) (s *Snapshot, err error)
- func (c *SnapshotCache[K]) Get(ref string) (s *Snapshot, ok bool)
- func (c *SnapshotCache[K]) References() []string
- type SnapshotOption
- type SnapshotStore
- type Store
- func (s *Store) CountFlags(ctx context.Context, p storage.NamespaceRequest) (count uint64, err error)
- func (s *Store) CountNamespaces(ctx context.Context, req storage.ReferenceRequest) (count uint64, err error)
- func (s *Store) CountRollouts(ctx context.Context, flag storage.ResourceRequest) (count uint64, err error)
- func (s *Store) CountRules(ctx context.Context, flag storage.ResourceRequest) (count uint64, err error)
- func (s *Store) CountSegments(ctx context.Context, p storage.NamespaceRequest) (count uint64, err error)
- func (s *Store) CreateConstraint(ctx context.Context, r *flipt.CreateConstraintRequest) (*flipt.Constraint, error)
- func (s *Store) CreateDistribution(ctx context.Context, r *flipt.CreateDistributionRequest) (*flipt.Distribution, error)
- func (s *Store) CreateFlag(ctx context.Context, r *flipt.CreateFlagRequest) (*flipt.Flag, error)
- func (s *Store) CreateNamespace(ctx context.Context, r *flipt.CreateNamespaceRequest) (*flipt.Namespace, error)
- func (s *Store) CreateRollout(ctx context.Context, r *flipt.CreateRolloutRequest) (*flipt.Rollout, error)
- func (s *Store) CreateRule(ctx context.Context, r *flipt.CreateRuleRequest) (*flipt.Rule, error)
- func (s *Store) CreateSegment(ctx context.Context, r *flipt.CreateSegmentRequest) (*flipt.Segment, error)
- func (s *Store) CreateVariant(ctx context.Context, r *flipt.CreateVariantRequest) (*flipt.Variant, error)
- func (s *Store) DeleteConstraint(ctx context.Context, r *flipt.DeleteConstraintRequest) error
- func (s *Store) DeleteDistribution(ctx context.Context, r *flipt.DeleteDistributionRequest) error
- func (s *Store) DeleteFlag(ctx context.Context, r *flipt.DeleteFlagRequest) error
- func (s *Store) DeleteNamespace(ctx context.Context, r *flipt.DeleteNamespaceRequest) error
- func (s *Store) DeleteRollout(ctx context.Context, r *flipt.DeleteRolloutRequest) error
- func (s *Store) DeleteRule(ctx context.Context, r *flipt.DeleteRuleRequest) error
- func (s *Store) DeleteSegment(ctx context.Context, r *flipt.DeleteSegmentRequest) error
- func (s *Store) DeleteVariant(ctx context.Context, r *flipt.DeleteVariantRequest) error
- func (s *Store) GetEvaluationDistributions(ctx context.Context, rule storage.IDRequest) (dists []*storage.EvaluationDistribution, err error)
- func (s *Store) GetEvaluationRollouts(ctx context.Context, flag storage.ResourceRequest) (rollouts []*storage.EvaluationRollout, err error)
- func (s *Store) GetEvaluationRules(ctx context.Context, flag storage.ResourceRequest) (rules []*storage.EvaluationRule, err error)
- func (s *Store) GetFlag(ctx context.Context, req storage.ResourceRequest) (flag *flipt.Flag, err error)
- func (s *Store) GetNamespace(ctx context.Context, p storage.NamespaceRequest) (ns *flipt.Namespace, err error)
- func (s *Store) GetRollout(ctx context.Context, p storage.NamespaceRequest, id string) (rollout *flipt.Rollout, err error)
- func (s *Store) GetRule(ctx context.Context, p storage.NamespaceRequest, id string) (rule *flipt.Rule, err error)
- func (s *Store) GetSegment(ctx context.Context, p storage.ResourceRequest) (segment *flipt.Segment, err error)
- func (s *Store) GetVersion(context.Context, storage.NamespaceRequest) (string, error)
- func (s *Store) ListFlags(ctx context.Context, req *storage.ListRequest[storage.NamespaceRequest]) (set storage.ResultSet[*flipt.Flag], err error)
- func (s *Store) ListNamespaces(ctx context.Context, req *storage.ListRequest[storage.ReferenceRequest]) (set storage.ResultSet[*flipt.Namespace], err error)
- func (s *Store) ListRollouts(ctx context.Context, req *storage.ListRequest[storage.ResourceRequest]) (set storage.ResultSet[*flipt.Rollout], err error)
- func (s *Store) ListRules(ctx context.Context, req *storage.ListRequest[storage.ResourceRequest]) (set storage.ResultSet[*flipt.Rule], err error)
- func (s *Store) ListSegments(ctx context.Context, req *storage.ListRequest[storage.NamespaceRequest]) (set storage.ResultSet[*flipt.Segment], err error)
- func (s *Store) OrderRollouts(ctx context.Context, r *flipt.OrderRolloutsRequest) error
- func (s *Store) OrderRules(ctx context.Context, r *flipt.OrderRulesRequest) error
- func (s *Store) String() string
- func (s *Store) UpdateConstraint(ctx context.Context, r *flipt.UpdateConstraintRequest) (*flipt.Constraint, error)
- func (s *Store) UpdateDistribution(ctx context.Context, r *flipt.UpdateDistributionRequest) (*flipt.Distribution, error)
- func (s *Store) UpdateFlag(ctx context.Context, r *flipt.UpdateFlagRequest) (*flipt.Flag, error)
- func (s *Store) UpdateNamespace(ctx context.Context, r *flipt.UpdateNamespaceRequest) (*flipt.Namespace, error)
- func (s *Store) UpdateRollout(ctx context.Context, r *flipt.UpdateRolloutRequest) (*flipt.Rollout, error)
- func (s *Store) UpdateRule(ctx context.Context, r *flipt.UpdateRuleRequest) (*flipt.Rule, error)
- func (s *Store) UpdateSegment(ctx context.Context, r *flipt.UpdateSegmentRequest) (*flipt.Segment, error)
- func (s *Store) UpdateVariant(ctx context.Context, r *flipt.UpdateVariantRequest) (*flipt.Variant, error)
- type UpdateFunc
Constants ¶
const (
// IndexFileName is the name of the index file on disk
IndexFileName = ".flipt.yml"
)
Variables ¶
var ( // ErrNotImplemented is returned when a method has intentionally not been implemented // This is usually reserved for the store write actions when the store is read-only // but still needs to implement storage.Store ErrNotImplemented = errors.New("not implemented") )
Functions ¶
func WalkDocuments ¶ added in v1.31.0
WalkDocuments walks all the Flipt feature documents found in the target fs.FS based on either the default index file or an index file located in the root
func WithInterval ¶ added in v1.34.0
func WithInterval(interval time.Duration) containers.Option[Poller]
func WithNotify ¶ added in v1.34.0
func WithValidatorOption ¶ added in v1.36.0
func WithValidatorOption(opts ...validation.FeaturesValidatorOption) containers.Option[SnapshotOption]
Types ¶
type CacheBuildFunc ¶ added in v1.36.0
type CacheBuildFunc[K comparable] func(context.Context, K) (*Snapshot, error)
CacheBuildFunc is a function that can build a snapshot for a given content key (K).
type FliptIndex ¶
type FliptIndex struct {
// contains filtered or unexported fields
}
FliptIndex is a set of glob include and exclude patterns which can be used to filter a set of provided paths.
func DefaultFliptIndex ¶ added in v1.35.0
func DefaultFliptIndex() (*FliptIndex, error)
DefaultFliptIndex returns the default value for the FliptIndex. It used when a .flipt.yml can not be located.
func OpenFliptIndex ¶ added in v1.35.0
OpenFliptIndex attempts to retrieve a FliptIndex from the provided source fs.FS implementation. If the index cannot be found then it returns the instance returned by defaultFliptIndex().
func ParseFliptIndex ¶ added in v1.35.0
func ParseFliptIndex(r io.Reader) (*FliptIndex, error)
ParseFliptIndex reads and parses the provided io.Reader and returns a *FliptIndex it deemed valid.
func (*FliptIndex) Match ¶ added in v1.35.0
func (i *FliptIndex) Match(path string) bool
Match returns true if the path should be kept because it matches the underlying index filter
type Poller ¶ added in v1.34.0
type Poller struct {
// contains filtered or unexported fields
}
type ReferencedSnapshotStore ¶ added in v1.35.0
type ReferencedSnapshotStore interface { // View accepts a function which takes a storage.ReadOnlyStore (*StoreSnapshot). // The ReferencedSnapshotStore will supply a snapshot which is valid // for the lifetime of the provided function call. // It expects a reference to be supplied on calls to View. // Empty reference will be regarded as the default reference by the store. View(context.Context, storage.Reference, func(storage.ReadOnlyStore) error) error fmt.Stringer }
ReferencedSnapshotStore is a type which has a single function View. View is a functional transaction interface for reading a snapshot during the lifetime of a supplied function.
type SingleReferenceSnapshotStore ¶ added in v1.35.0
type SingleReferenceSnapshotStore struct { SnapshotStore // contains filtered or unexported fields }
SingleReferenceSnapshotStore implements ReferencedSnapshotStore but delegates to a SnapshotStore implementation. Calls with View with a non-empty reference log a warning with the requested reference.
func NewSingleReferenceStore ¶ added in v1.35.0
func NewSingleReferenceStore(logger *zap.Logger, s SnapshotStore) *SingleReferenceSnapshotStore
NewSingleReferenceStore adapts a SnapshotStore implementation into a ReferencedSnapshotStore implementation which expects to be called with an empty reference.
func (*SingleReferenceSnapshotStore) View ¶ added in v1.35.0
func (s *SingleReferenceSnapshotStore) View(ctx context.Context, ref storage.Reference, fn func(storage.ReadOnlyStore) error) error
View delegates to the embedded snapshot store implementation and drops the reference. It logs a warning if a non-empty reference is supplied as the wrapped store isn't intended for use with custom references.
type Snapshot ¶ added in v1.34.0
type Snapshot struct {
// contains filtered or unexported fields
}
Snapshot contains the structures necessary for serving flag state to a client.
func SnapshotFromFS ¶ added in v1.27.0
func SnapshotFromFS(logger *zap.Logger, src fs.FS, opts ...containers.Option[SnapshotOption]) (*Snapshot, error)
SnapshotFromFS is a convenience function for building a snapshot directly from an implementation of fs.FS using the list state files function to source the relevant Flipt configuration files.
func SnapshotFromFiles ¶ added in v1.31.0
func SnapshotFromFiles(logger *zap.Logger, files []fs.File, opts ...containers.Option[SnapshotOption]) (*Snapshot, error)
SnapshotFromFiles constructs a StoreSnapshot from the provided slice of fs.File implementations.
func SnapshotFromPaths ¶ added in v1.27.0
func SnapshotFromPaths(logger *zap.Logger, ffs fs.FS, paths []string, opts ...containers.Option[SnapshotOption]) (*Snapshot, error)
SnapshotFromPaths constructs a StoreSnapshot from the provided slice of paths resolved against the provided fs.FS.
func (*Snapshot) CountFlags ¶ added in v1.34.0
func (*Snapshot) CountNamespaces ¶ added in v1.34.0
func (*Snapshot) CountRollouts ¶ added in v1.34.0
func (*Snapshot) CountRules ¶ added in v1.34.0
func (*Snapshot) CountSegments ¶ added in v1.34.0
func (*Snapshot) GetEvaluationDistributions ¶ added in v1.34.0
func (*Snapshot) GetEvaluationRollouts ¶ added in v1.34.0
func (ss *Snapshot) GetEvaluationRollouts(ctx context.Context, flag storage.ResourceRequest) ([]*storage.EvaluationRollout, error)
func (*Snapshot) GetEvaluationRules ¶ added in v1.34.0
func (ss *Snapshot) GetEvaluationRules(ctx context.Context, flag storage.ResourceRequest) ([]*storage.EvaluationRule, error)
func (*Snapshot) GetNamespace ¶ added in v1.34.0
func (*Snapshot) GetRollout ¶ added in v1.34.0
func (*Snapshot) GetSegment ¶ added in v1.34.0
func (*Snapshot) GetVersion ¶ added in v1.46.0
func (*Snapshot) ListNamespaces ¶ added in v1.34.0
func (*Snapshot) ListRollouts ¶ added in v1.34.0
func (*Snapshot) ListSegments ¶ added in v1.34.0
type SnapshotCache ¶ added in v1.36.0
type SnapshotCache[K comparable] struct { // contains filtered or unexported fields }
SnapshotCache contains a fixed set of non-evictable reference entries along with additional capacity for references stored in an LRU. The SnapshotCache is keyed by reference (R') with an indirect index (K') through into a target set of stored snapshots (S').
R1 ---> K1 ---> S1 R2 -----^ R3 ---> K2 ---> S2
The type K is generic to support the different kinds of content address types we expect to support (commit SHA and OCI digest).
func NewSnapshotCache ¶ added in v1.36.0
func NewSnapshotCache[K comparable](logger *zap.Logger, extra int) (_ *SnapshotCache[K], err error)
NewSnapshotCache constructs and configures a snapshot cache with the provided size for extra cache entries. These are opposed to the fixed entries which are added via AddFixed and do not count towards this extra total.
func (*SnapshotCache[K]) AddFixed ¶ added in v1.36.0
func (c *SnapshotCache[K]) AddFixed(ctx context.Context, ref string, k K, s *Snapshot)
AddFixed adds the reference, key and value tuple to fixed storage. The supplied *reference* will NEVER be evicted. Subsequent calls to Add with the same value for ref will update the fixed entries. This should be called during initialization of a store.
func (*SnapshotCache[K]) AddOrBuild ¶ added in v1.36.0
func (c *SnapshotCache[K]) AddOrBuild(ctx context.Context, ref string, k K, build CacheBuildFunc[K]) (s *Snapshot, err error)
AddOrBuild adds the reference, key and value tuple. If the reference r is already tracked in the fixed set, then it is updated there. Otherwise, the entry is added to the LRU cache.
func (*SnapshotCache[K]) Get ¶ added in v1.36.0
func (c *SnapshotCache[K]) Get(ref string) (s *Snapshot, ok bool)
Get attempts to resolve a snapshot for a given reference r.
func (*SnapshotCache[K]) References ¶ added in v1.36.0
func (c *SnapshotCache[K]) References() []string
References returns all the references currently tracked within the cache.
type SnapshotOption ¶ added in v1.36.0
type SnapshotOption struct {
// contains filtered or unexported fields
}
type SnapshotStore ¶ added in v1.34.0
type SnapshotStore interface { // View accepts a function which takes a storage.ReadOnlyStore (*SnapshotStore). // The SnapshotStore will supply a snapshot which is valid // for the lifetime of the provided function call. View(context.Context, func(storage.ReadOnlyStore) error) error fmt.Stringer }
SnapshotStore is a type which has a single function View. View is a functional transaction interface for reading a snapshot during the lifetime of a supplied function.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store embeds a StoreSnapshot and wraps the Store methods with a read-write mutex to synchronize reads with atomic replacements of the embedded snapshot.
func NewStore ¶
func NewStore(viewer ReferencedSnapshotStore) *Store
func (*Store) CountFlags ¶
func (*Store) CountNamespaces ¶
func (*Store) CountRollouts ¶ added in v1.24.0
func (*Store) CountRules ¶
func (*Store) CountSegments ¶
func (*Store) CreateConstraint ¶ added in v1.34.0
func (s *Store) CreateConstraint(ctx context.Context, r *flipt.CreateConstraintRequest) (*flipt.Constraint, error)
func (*Store) CreateDistribution ¶ added in v1.34.0
func (s *Store) CreateDistribution(ctx context.Context, r *flipt.CreateDistributionRequest) (*flipt.Distribution, error)
func (*Store) CreateFlag ¶ added in v1.34.0
func (*Store) CreateNamespace ¶ added in v1.34.0
func (*Store) CreateRollout ¶ added in v1.24.0
func (*Store) CreateRule ¶ added in v1.34.0
func (*Store) CreateSegment ¶ added in v1.34.0
func (*Store) CreateVariant ¶ added in v1.34.0
func (*Store) DeleteConstraint ¶ added in v1.34.0
func (*Store) DeleteDistribution ¶ added in v1.34.0
func (*Store) DeleteFlag ¶ added in v1.34.0
func (*Store) DeleteNamespace ¶ added in v1.34.0
func (*Store) DeleteRollout ¶ added in v1.24.0
func (*Store) DeleteRule ¶ added in v1.34.0
func (*Store) DeleteSegment ¶ added in v1.34.0
func (*Store) DeleteVariant ¶ added in v1.34.0
func (*Store) GetEvaluationDistributions ¶
func (*Store) GetEvaluationRollouts ¶ added in v1.29.0
func (s *Store) GetEvaluationRollouts(ctx context.Context, flag storage.ResourceRequest) (rollouts []*storage.EvaluationRollout, err error)
func (*Store) GetEvaluationRules ¶
func (s *Store) GetEvaluationRules(ctx context.Context, flag storage.ResourceRequest) (rules []*storage.EvaluationRule, err error)
func (*Store) GetNamespace ¶
func (*Store) GetRollout ¶ added in v1.24.0
func (*Store) GetSegment ¶
func (*Store) GetVersion ¶ added in v1.46.0
func (*Store) ListNamespaces ¶
func (*Store) ListRollouts ¶ added in v1.24.0
func (*Store) ListSegments ¶
func (*Store) OrderRollouts ¶ added in v1.24.0
func (*Store) OrderRules ¶ added in v1.34.0
func (*Store) UpdateConstraint ¶ added in v1.34.0
func (s *Store) UpdateConstraint(ctx context.Context, r *flipt.UpdateConstraintRequest) (*flipt.Constraint, error)
func (*Store) UpdateDistribution ¶ added in v1.34.0
func (s *Store) UpdateDistribution(ctx context.Context, r *flipt.UpdateDistributionRequest) (*flipt.Distribution, error)