storage

package
v1.19.3 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2023 License: GPL-3.0 Imports: 3 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
)

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.

Types

type EvaluationConstraint

type EvaluationConstraint struct {
	ID       string
	Type     flipt.ComparisonType
	Property string
	Operator string
	Value    string
}

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 EvaluationRule

type EvaluationRule struct {
	ID               string
	FlagKey          string
	SegmentKey       string
	SegmentMatchType flipt.MatchType
	Rank             int32
	Constraints      []EvaluationConstraint
}

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

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, flagKey string) ([]*EvaluationRule, error)
	GetEvaluationDistributions(ctx context.Context, ruleID string) ([]*EvaluationDistribution, error)
}

EvaluationStore returns data necessary for evaluation

type FlagStore

type FlagStore interface {
	GetFlag(ctx context.Context, key string) (*flipt.Flag, error)
	ListFlags(ctx context.Context, opts ...QueryOption) (ResultSet[*flipt.Flag], error)
	CountFlags(ctx context.Context) (uint64, error)
	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 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.

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 NewListRequest added in v1.15.0

func NewListRequest[T any](opts ...ListOption[T]) *ListRequest[T]

NewListRequest constructs a new ListRequest using the provided ListOption.

type Order

type Order uint8
const (
	OrderAsc Order = iota
	OrderDesc
)

func (Order) String

func (o Order) String() string

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 (*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 ResultSet

type ResultSet[T any] struct {
	Results       []T
	NextPageToken string
}

type RuleStore

type RuleStore interface {
	GetRule(ctx context.Context, id string) (*flipt.Rule, error)
	ListRules(ctx context.Context, flagKey string, opts ...QueryOption) (ResultSet[*flipt.Rule], error)
	CountRules(ctx context.Context) (uint64, error)
	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 {
	GetSegment(ctx context.Context, key string) (*flipt.Segment, error)
	ListSegments(ctx context.Context, opts ...QueryOption) (ResultSet[*flipt.Segment], error)
	CountSegments(ctx context.Context) (uint64, error)
	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

Directories

Path Synopsis
sql
sql
sql

Jump to

Keyboard shortcuts

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