storage

package
v1.24.2 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 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
)
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.

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
	RolloutType  flipt.RolloutType
	Rank         int32
	Threshold    *RolloutThreshold
	Segment      *RolloutSegment
}

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

type EvaluationRule

type EvaluationRule struct {
	ID               string                 `json:"id"`
	NamespaceKey     string                 `json:"namespace_key,omitempty"`
	FlagKey          string                 `json:"flag_key,omitempty"`
	SegmentKey       string                 `json:"segment_key,omitempty"`
	SegmentMatchType flipt.MatchType        `json:"segment_match_type,omitempty"`
	Rank             int32                  `json:"rank,omitempty"`
	Constraints      []EvaluationConstraint `json:"constraints,omitempty"`
}

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

EvaluationStore returns data necessary for evaluation

type FlagStore

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

type NamespaceStore interface {
	GetNamespace(ctx context.Context, key string) (*flipt.Namespace, error)
	ListNamespaces(ctx context.Context, opts ...QueryOption) (ResultSet[*flipt.Namespace], error)
	CountNamespaces(ctx context.Context) (uint64, error)
	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 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 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 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 {
	Key         string
	MatchType   flipt.MatchType
	Value       bool
	Constraints []EvaluationConstraint
}

RolloutSegment represents Segment(s) for use in evaluation.

type RolloutStore added in v1.24.0

type RolloutStore interface {
	GetRollout(ctx context.Context, namespaceKey, id string) (*flipt.Rollout, error)
	ListRollouts(ctx context.Context, namespaceKey, flagKey string, opts ...QueryOption) (ResultSet[*flipt.Rollout], error)
	CountRollouts(ctx context.Context, namespaceKey, flagKey string) (uint64, error)
	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
}

type RolloutThreshold added in v1.24.0

type RolloutThreshold struct {
	Percentage float32
	Value      bool
}

RolloutThreshold represents Percentage(s) for use in evaluation.

type RuleStore

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

Jump to

Keyboard shortcuts

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