storage

package
v1.42.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// DefaultListLimit is the default limit applied to any list operation page size when one is not provided.
	DefaultListLimit uint64 = 25

	// MaxListLimit is the upper limit applied to any list operation page size.
	MaxListLimit uint64 = 100
)
View Source
const DefaultNamespace = "default"

Variables

This section is empty.

Functions

func ListAll added in v1.15.0

func ListAll[P, V any](ctx context.Context, fn ListFunc[P, V], params ListAllParams) (res []V, err error)

ListAll can return the entire contents of some generic storage layer if given a ListFunc implementation for that store. It performs an entire paginated walk until an empty next page token is returned.

func WithReference added in v1.35.0

func WithReference(ref string) containers.Option[ReferenceRequest]

WithReference sets the provided reference identifier on a *ReferenceRequest.

Types

type EvaluationConstraint

type EvaluationConstraint struct {
	ID       string               `json:"id,omitempty"`
	Type     flipt.ComparisonType `json:"comparison_type,omitempty"`
	Property string               `json:"property,omitempty"`
	Operator string               `json:"operator,omitempty"`
	Value    string               `json:"value,omitempty"`
}

EvaluationConstraint represents a segment constraint that is used for evaluation

type EvaluationDistribution

type EvaluationDistribution struct {
	ID                string
	RuleID            string
	VariantID         string
	Rollout           float32
	VariantKey        string
	VariantAttachment string
}

EvaluationDistribution represents a rule distribution along with its variant for evaluation

type EvaluationRollout added in v1.24.0

type EvaluationRollout struct {
	NamespaceKey string            `json:"namespace_key,omitempty"`
	RolloutType  flipt.RolloutType `json:"rollout_type,omitempty"`
	Rank         int32             `json:"rank,omitempty"`
	Threshold    *RolloutThreshold `json:"threshold,omitempty"`
	Segment      *RolloutSegment   `json:"segment,omitempty"`
}

EvaluationRollout represents a rollout in the form that helps with evaluation.

type EvaluationRule

type EvaluationRule struct {
	ID              string                        `json:"id,omitempty"`
	NamespaceKey    string                        `json:"namespace_key,omitempty"`
	FlagKey         string                        `json:"flag_key,omitempty"`
	Segments        map[string]*EvaluationSegment `json:"segments,omitempty"`
	Rank            int32                         `json:"rank,omitempty"`
	SegmentOperator flipt.SegmentOperator         `json:"segmentOperator,omitempty"`
}

EvaluationRule represents a rule and constraints required for evaluating if a given flagKey matches a segment

type EvaluationSegment added in v1.25.0

type EvaluationSegment struct {
	SegmentKey  string                 `json:"segment_key,omitempty"`
	MatchType   flipt.MatchType        `json:"match_type,omitempty"`
	Constraints []EvaluationConstraint `json:"constraints,omitempty"`
}

type EvaluationStore

type EvaluationStore interface {
	// GetEvaluationRules returns rules applicable to flagKey provided
	// Note: Rules MUST be returned in order by Rank
	GetEvaluationRules(ctx context.Context, flag ResourceRequest) ([]*EvaluationRule, error)
	GetEvaluationDistributions(ctx context.Context, rule IDRequest) ([]*EvaluationDistribution, error)
	// GetEvaluationRollouts returns rollouts applicable to namespaceKey + flagKey provided
	// Note: Rollouts MUST be returned in order by rank
	GetEvaluationRollouts(ctx context.Context, flag ResourceRequest) ([]*EvaluationRollout, error)
}

EvaluationStore returns data necessary for evaluation

type FlagStore

type FlagStore interface {
	ReadOnlyFlagStore
	CreateFlag(ctx context.Context, r *flipt.CreateFlagRequest) (*flipt.Flag, error)
	UpdateFlag(ctx context.Context, r *flipt.UpdateFlagRequest) (*flipt.Flag, error)
	DeleteFlag(ctx context.Context, r *flipt.DeleteFlagRequest) error
	CreateVariant(ctx context.Context, r *flipt.CreateVariantRequest) (*flipt.Variant, error)
	UpdateVariant(ctx context.Context, r *flipt.UpdateVariantRequest) (*flipt.Variant, error)
	DeleteVariant(ctx context.Context, r *flipt.DeleteVariantRequest) error
}

FlagStore stores and retrieves flags and variants

type IDRequest added in v1.35.0

type IDRequest struct {
	ReferenceRequest
	ID string
}

IDRequest is used to identify any sub-resources which have a unique random identifier. This is used for sub-resources with no key identifiers (e.g. rules and rollouts).

func NewID added in v1.35.0

NewID constructs and configures a new *IDRequest with the provided ID string. Optionally, the target storage revision reference can also be supplied.

type ListAllParams added in v1.15.0

type ListAllParams struct {
	PerPage int
	Order   Order
}

type ListFunc added in v1.15.0

type ListFunc[P, V any] func(context.Context, *ListRequest[P]) (ResultSet[V], error)

ListFunc is a function which can return a set of results for a list request.

type ListOption added in v1.15.0

type ListOption[T any] func(*ListRequest[T])

ListOption is a function which can configure a ListRequest.

func ListWithQueryParamOptions added in v1.15.0

func ListWithQueryParamOptions[T any](opts ...QueryOption) ListOption[T]

ListWithQueryParamOptions takes a set of functional options for QueryParam and returns a ListOption which applies them in order on the provided ListRequest.

func ListWithReference added in v1.35.0

func ListWithReference(ref string) ListOption[ReferenceRequest]

ListWithReference is a ListOption constrained to ReferenceRequest types. It sets the reference on the resulting list request.

type ListRequest added in v1.15.0

type ListRequest[P any] struct {
	Predicate   P
	QueryParams QueryParams
}

ListRequest is a generic container for the parameters required to perform a list operation. It contains a generic type T intended for a list predicate. It also contains a QueryParams object containing pagination constraints.

func ListWithOptions added in v1.35.0

func ListWithOptions[T any](t T, opts ...ListOption[T]) *ListRequest[T]

ListWithOptions constructs a new ListRequest using the provided ListOption.

func ListWithParameters added in v1.35.0

func ListWithParameters[T any](t T, p PageParameter) *ListRequest[T]

ListWithParameters constructs a new ListRequest using the page parameters exposed by the provided PageParameter implementation.

type NamespaceRequest added in v1.35.0

type NamespaceRequest struct {
	ReferenceRequest
	// contains filtered or unexported fields
}

NamespaceRequest is used to identify a request predicated by both a revision and a namespace. This is used to identify namespaces and list resources directly beneath them (e.g. flags and segments).

func NewNamespace added in v1.35.0

func NewNamespace(key string, opts ...containers.Option[ReferenceRequest]) NamespaceRequest

NewNamespace constructs a *NamespaceRequest from the provided key string. Optionally, the target storage revision reference can also be supplied.

func (NamespaceRequest) Namespace added in v1.35.0

func (n NamespaceRequest) Namespace() string

Namespace returns the resolved target namespace key string. If the underlying key is the empty string, the default namespace ("default") is returned instead.

func (NamespaceRequest) String added in v1.35.0

func (n NamespaceRequest) String() string

String returns the resolved target namespace key string. If the underlying key is the empty string, the default namespace ("default") is returned instead.

type NamespaceStore added in v1.20.0

type NamespaceStore interface {
	ReadOnlyNamespaceStore
	CreateNamespace(ctx context.Context, r *flipt.CreateNamespaceRequest) (*flipt.Namespace, error)
	UpdateNamespace(ctx context.Context, r *flipt.UpdateNamespaceRequest) (*flipt.Namespace, error)
	DeleteNamespace(ctx context.Context, r *flipt.DeleteNamespaceRequest) error
}

NamespaceStore stores and retrieves namespaces

type OffsetPageParameter added in v1.35.0

type OffsetPageParameter interface {
	PageParameter
	GetOffset() int32
}

OffsetPageParameter is a type which exposes an additional offset accessor for legacy paging implementations (page token supersedes).

type Order

type Order uint8
const (
	OrderAsc Order = iota
	OrderDesc
)

func (Order) String

func (o Order) String() string

type PageParameter added in v1.35.0

type PageParameter interface {
	GetLimit() int32
	GetPageToken() string
}

PageParameter is any type which exposes limit and page token accessors used to identify pages.

type QueryOption

type QueryOption func(p *QueryParams)

func WithLimit

func WithLimit(limit uint64) QueryOption

func WithOffset

func WithOffset(offset uint64) QueryOption

func WithOrder

func WithOrder(order Order) QueryOption

func WithPageToken

func WithPageToken(pageToken string) QueryOption

type QueryParams

type QueryParams struct {
	Limit     uint64
	Offset    uint64 // deprecated
	PageToken string
	Order     Order // not exposed to the user yet
}

func NewQueryParams added in v1.23.0

func NewQueryParams(opts ...QueryOption) (params QueryParams)

func (*QueryParams) Normalize added in v1.15.0

func (q *QueryParams) Normalize()

Normalize adjusts query parameters within the enforced boundaries. For example, limit is adjusted to be in the range (0, max]. Given the limit is not supplied (0) it is set to the default limit.

type ReadOnlyFlagStore added in v1.34.0

type ReadOnlyFlagStore interface {
	GetFlag(ctx context.Context, req ResourceRequest) (*flipt.Flag, error)
	ListFlags(ctx context.Context, req *ListRequest[NamespaceRequest]) (ResultSet[*flipt.Flag], error)
	CountFlags(ctx context.Context, ns NamespaceRequest) (uint64, error)
}

ReadOnlyFlagStore supports retrieval of flags

type ReadOnlyNamespaceStore added in v1.34.0

type ReadOnlyNamespaceStore interface {
	GetNamespace(ctx context.Context, ns NamespaceRequest) (*flipt.Namespace, error)
	ListNamespaces(ctx context.Context, req *ListRequest[ReferenceRequest]) (ResultSet[*flipt.Namespace], error)
	CountNamespaces(ctx context.Context, req ReferenceRequest) (uint64, error)
}

ReadOnlyNamespaceStore support retrieval of namespaces only

type ReadOnlyRolloutStore added in v1.34.0

type ReadOnlyRolloutStore interface {
	GetRollout(ctx context.Context, ns NamespaceRequest, id string) (*flipt.Rollout, error)
	ListRollouts(ctx context.Context, req *ListRequest[ResourceRequest]) (ResultSet[*flipt.Rollout], error)
	CountRollouts(ctx context.Context, flag ResourceRequest) (uint64, error)
}

ReadOnlyRolloutStore supports retrieval of rollouts

type ReadOnlyRuleStore added in v1.34.0

type ReadOnlyRuleStore interface {
	GetRule(ctx context.Context, ns NamespaceRequest, id string) (*flipt.Rule, error)
	ListRules(ctx context.Context, req *ListRequest[ResourceRequest]) (ResultSet[*flipt.Rule], error)
	CountRules(ctx context.Context, flag ResourceRequest) (uint64, error)
}

ReadOnlyRuleStore supports retrieval of rules and distributions

type ReadOnlySegmentStore added in v1.34.0

type ReadOnlySegmentStore interface {
	GetSegment(ctx context.Context, req ResourceRequest) (*flipt.Segment, error)
	ListSegments(ctx context.Context, req *ListRequest[NamespaceRequest]) (ResultSet[*flipt.Segment], error)
	CountSegments(ctx context.Context, ns NamespaceRequest) (uint64, error)
}

ReadOnlySegmentStore supports retrieval of segments and constraints

type ReadOnlyStore added in v1.34.0

ReadOnlyStore is a storage implementation which only supports reading the various types of state configuring within Flipt

type Reference added in v1.35.0

type Reference string

Reference is a string which can refer to either a concrete revision or it can be an indirect named reference.

type ReferenceRequest added in v1.35.0

type ReferenceRequest struct {
	Reference
}

ReferenceRequest is used to identify a request predicated solely by a revision reference. This is primarily used for namespaces as it is the highest level domain model.

type ResourceRequest added in v1.35.0

type ResourceRequest struct {
	NamespaceRequest
	Key string
}

ResourceRequest is used to identify a request predicated by revision, namespace and a key. This is used for core resources (e.g. flag and segment) as well as to list sub-resources (e.g. rules and constraints).

func NewResource added in v1.35.0

func NewResource(ns, key string, opts ...containers.Option[ReferenceRequest]) ResourceRequest

NewResource constructs and configures and new *ResourceRequest from the provided namespace and resource keys. Optionally, the target storage revision reference can also be supplied.

func (ResourceRequest) String added in v1.35.0

func (p ResourceRequest) String() string

String returns a representation of the combined resource namespace and key separated by a '/'.

type ResultSet

type ResultSet[T any] struct {
	Results       []T    `json:"results"`
	NextPageToken string `json:"next_page_token"`
}

type RolloutSegment added in v1.24.0

type RolloutSegment struct {
	Value           bool                          `json:"value,omitempty"`
	SegmentOperator flipt.SegmentOperator         `json:"segment_operator,omitempty"`
	Segments        map[string]*EvaluationSegment `json:"segments,omitempty"`
}

RolloutSegment represents Segment(s) for use in evaluation.

type RolloutStore added in v1.24.0

type RolloutStore interface {
	ReadOnlyRolloutStore
	CreateRollout(ctx context.Context, r *flipt.CreateRolloutRequest) (*flipt.Rollout, error)
	UpdateRollout(ctx context.Context, r *flipt.UpdateRolloutRequest) (*flipt.Rollout, error)
	DeleteRollout(ctx context.Context, r *flipt.DeleteRolloutRequest) error
	OrderRollouts(ctx context.Context, r *flipt.OrderRolloutsRequest) error
}

RolloutStore supports storing and retrieving rollouts

type RolloutThreshold added in v1.24.0

type RolloutThreshold struct {
	Percentage float32 `json:"percentage,omitempty"`
	Value      bool    `json:"value,omitempty"`
}

RolloutThreshold represents Percentage(s) for use in evaluation.

type RuleStore

type RuleStore interface {
	ReadOnlyRuleStore
	CreateRule(ctx context.Context, r *flipt.CreateRuleRequest) (*flipt.Rule, error)
	UpdateRule(ctx context.Context, r *flipt.UpdateRuleRequest) (*flipt.Rule, error)
	DeleteRule(ctx context.Context, r *flipt.DeleteRuleRequest) error
	OrderRules(ctx context.Context, r *flipt.OrderRulesRequest) error
	CreateDistribution(ctx context.Context, r *flipt.CreateDistributionRequest) (*flipt.Distribution, error)
	UpdateDistribution(ctx context.Context, r *flipt.UpdateDistributionRequest) (*flipt.Distribution, error)
	DeleteDistribution(ctx context.Context, r *flipt.DeleteDistributionRequest) error
}

RuleStore stores and retrieves rules and distributions

type SegmentStore

type SegmentStore interface {
	ReadOnlySegmentStore
	CreateSegment(ctx context.Context, r *flipt.CreateSegmentRequest) (*flipt.Segment, error)
	UpdateSegment(ctx context.Context, r *flipt.UpdateSegmentRequest) (*flipt.Segment, error)
	DeleteSegment(ctx context.Context, r *flipt.DeleteSegmentRequest) error
	CreateConstraint(ctx context.Context, r *flipt.CreateConstraintRequest) (*flipt.Constraint, error)
	UpdateConstraint(ctx context.Context, r *flipt.UpdateConstraintRequest) (*flipt.Constraint, error)
	DeleteConstraint(ctx context.Context, r *flipt.DeleteConstraintRequest) error
}

SegmentStore stores and retrieves segments and constraints

type Store

Store supports reading and writing all the resources within Flipt

Jump to

Keyboard shortcuts

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