storage

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2022 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 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
}

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

Jump to

Keyboard shortcuts

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