fs

package
v1.41.1 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// IndexFileName is the name of the index file on disk
	IndexFileName = ".flipt.yml"
)

Variables

View Source
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

func WalkDocuments(logger *zap.Logger, src fs.FS, fn func(*ext.Document) error) error

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 WithNotify(t *testing.T, n func(modified bool)) containers.Option[Poller]

func WithValidatorOption added in v1.36.0

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

func OpenFliptIndex(logger *zap.Logger, src fs.FS) (*FliptIndex, error)

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
}

func NewPoller added in v1.34.0

func NewPoller(logger *zap.Logger, ctx context.Context, update UpdateFunc, opts ...containers.Option[Poller]) *Poller

func (*Poller) Close added in v1.34.0

func (p *Poller) Close() error

func (*Poller) Poll added in v1.34.0

func (p *Poller) Poll()

Poll is a utility function for a common polling strategy used by lots of declarative store implementations.

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

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 (ss *Snapshot) CountFlags(ctx context.Context, p storage.NamespaceRequest) (uint64, error)

func (*Snapshot) CountNamespaces added in v1.34.0

func (ss *Snapshot) CountNamespaces(ctx context.Context, _ storage.ReferenceRequest) (uint64, error)

func (*Snapshot) CountRollouts added in v1.34.0

func (ss *Snapshot) CountRollouts(ctx context.Context, flag storage.ResourceRequest) (uint64, error)

func (*Snapshot) CountRules added in v1.34.0

func (ss *Snapshot) CountRules(ctx context.Context, req storage.ResourceRequest) (uint64, error)

func (*Snapshot) CountSegments added in v1.34.0

func (ss *Snapshot) CountSegments(ctx context.Context, p storage.NamespaceRequest) (uint64, error)

func (*Snapshot) GetEvaluationDistributions added in v1.34.0

func (ss *Snapshot) GetEvaluationDistributions(ctx context.Context, rule storage.IDRequest) ([]*storage.EvaluationDistribution, error)

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) GetFlag added in v1.34.0

func (ss *Snapshot) GetFlag(ctx context.Context, req storage.ResourceRequest) (*flipt.Flag, error)

func (*Snapshot) GetNamespace added in v1.34.0

func (ss *Snapshot) GetNamespace(ctx context.Context, p storage.NamespaceRequest) (*flipt.Namespace, error)

func (*Snapshot) GetRollout added in v1.34.0

func (ss *Snapshot) GetRollout(ctx context.Context, p storage.NamespaceRequest, id string) (*flipt.Rollout, error)

func (*Snapshot) GetRule added in v1.34.0

func (ss *Snapshot) GetRule(ctx context.Context, p storage.NamespaceRequest, id string) (rule *flipt.Rule, _ error)

func (*Snapshot) GetSegment added in v1.34.0

func (ss *Snapshot) GetSegment(ctx context.Context, req storage.ResourceRequest) (*flipt.Segment, error)

func (*Snapshot) ListFlags added in v1.34.0

func (*Snapshot) ListNamespaces added in v1.34.0

func (*Snapshot) ListRollouts added in v1.34.0

func (*Snapshot) ListRules added in v1.34.0

func (*Snapshot) ListSegments added in v1.34.0

func (Snapshot) String added in v1.34.0

func (ss Snapshot) String() string

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 (s *Store) CountFlags(ctx context.Context, p storage.NamespaceRequest) (count uint64, err error)

func (*Store) CountNamespaces

func (s *Store) CountNamespaces(ctx context.Context, req storage.ReferenceRequest) (count uint64, err error)

func (*Store) CountRollouts added in v1.24.0

func (s *Store) CountRollouts(ctx context.Context, flag storage.ResourceRequest) (count uint64, err error)

func (*Store) CountRules

func (s *Store) CountRules(ctx context.Context, flag storage.ResourceRequest) (count uint64, err error)

func (*Store) CountSegments

func (s *Store) CountSegments(ctx context.Context, p storage.NamespaceRequest) (count uint64, err error)

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 (s *Store) CreateFlag(ctx context.Context, r *flipt.CreateFlagRequest) (*flipt.Flag, error)

func (*Store) CreateNamespace added in v1.34.0

func (s *Store) CreateNamespace(ctx context.Context, r *flipt.CreateNamespaceRequest) (*flipt.Namespace, error)

func (*Store) CreateRollout added in v1.24.0

func (s *Store) CreateRollout(ctx context.Context, r *flipt.CreateRolloutRequest) (*flipt.Rollout, error)

func (*Store) CreateRule added in v1.34.0

func (s *Store) CreateRule(ctx context.Context, r *flipt.CreateRuleRequest) (*flipt.Rule, error)

func (*Store) CreateSegment added in v1.34.0

func (s *Store) CreateSegment(ctx context.Context, r *flipt.CreateSegmentRequest) (*flipt.Segment, error)

func (*Store) CreateVariant added in v1.34.0

func (s *Store) CreateVariant(ctx context.Context, r *flipt.CreateVariantRequest) (*flipt.Variant, error)

func (*Store) DeleteConstraint added in v1.34.0

func (s *Store) DeleteConstraint(ctx context.Context, r *flipt.DeleteConstraintRequest) error

func (*Store) DeleteDistribution added in v1.34.0

func (s *Store) DeleteDistribution(ctx context.Context, r *flipt.DeleteDistributionRequest) error

func (*Store) DeleteFlag added in v1.34.0

func (s *Store) DeleteFlag(ctx context.Context, r *flipt.DeleteFlagRequest) error

func (*Store) DeleteNamespace added in v1.34.0

func (s *Store) DeleteNamespace(ctx context.Context, r *flipt.DeleteNamespaceRequest) error

func (*Store) DeleteRollout added in v1.24.0

func (s *Store) DeleteRollout(ctx context.Context, r *flipt.DeleteRolloutRequest) error

func (*Store) DeleteRule added in v1.34.0

func (s *Store) DeleteRule(ctx context.Context, r *flipt.DeleteRuleRequest) error

func (*Store) DeleteSegment added in v1.34.0

func (s *Store) DeleteSegment(ctx context.Context, r *flipt.DeleteSegmentRequest) error

func (*Store) DeleteVariant added in v1.34.0

func (s *Store) DeleteVariant(ctx context.Context, r *flipt.DeleteVariantRequest) error

func (*Store) GetEvaluationDistributions

func (s *Store) GetEvaluationDistributions(ctx context.Context, rule storage.IDRequest) (dists []*storage.EvaluationDistribution, err error)

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) GetFlag

func (s *Store) GetFlag(ctx context.Context, req storage.ResourceRequest) (flag *flipt.Flag, err error)

func (*Store) GetNamespace

func (s *Store) GetNamespace(ctx context.Context, p storage.NamespaceRequest) (ns *flipt.Namespace, err error)

func (*Store) GetRollout added in v1.24.0

func (s *Store) GetRollout(ctx context.Context, p storage.NamespaceRequest, id string) (rollout *flipt.Rollout, err error)

func (*Store) GetRule

func (s *Store) GetRule(ctx context.Context, p storage.NamespaceRequest, id string) (rule *flipt.Rule, err error)

func (*Store) GetSegment

func (s *Store) GetSegment(ctx context.Context, p storage.ResourceRequest) (segment *flipt.Segment, err error)

func (*Store) ListFlags

func (*Store) ListNamespaces

func (*Store) ListRollouts added in v1.24.0

func (*Store) ListRules

func (*Store) ListSegments

func (*Store) OrderRollouts added in v1.24.0

func (s *Store) OrderRollouts(ctx context.Context, r *flipt.OrderRolloutsRequest) error

func (*Store) OrderRules added in v1.34.0

func (s *Store) OrderRules(ctx context.Context, r *flipt.OrderRulesRequest) error

func (*Store) String

func (s *Store) String() string

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)

func (*Store) UpdateFlag added in v1.34.0

func (s *Store) UpdateFlag(ctx context.Context, r *flipt.UpdateFlagRequest) (*flipt.Flag, error)

func (*Store) UpdateNamespace added in v1.34.0

func (s *Store) UpdateNamespace(ctx context.Context, r *flipt.UpdateNamespaceRequest) (*flipt.Namespace, error)

func (*Store) UpdateRollout added in v1.24.0

func (s *Store) UpdateRollout(ctx context.Context, r *flipt.UpdateRolloutRequest) (*flipt.Rollout, error)

func (*Store) UpdateRule added in v1.34.0

func (s *Store) UpdateRule(ctx context.Context, r *flipt.UpdateRuleRequest) (*flipt.Rule, error)

func (*Store) UpdateSegment added in v1.34.0

func (s *Store) UpdateSegment(ctx context.Context, r *flipt.UpdateSegmentRequest) (*flipt.Segment, error)

func (*Store) UpdateVariant added in v1.34.0

func (s *Store) UpdateVariant(ctx context.Context, r *flipt.UpdateVariantRequest) (*flipt.Variant, error)

type UpdateFunc added in v1.34.0

type UpdateFunc func(context.Context) (bool, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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