Documentation ¶
Index ¶
- Constants
- func ListAll[P, V any](ctx context.Context, fn ListFunc[P, V], params ListAllParams) (res []V, err error)
- type EvaluationConstraint
- type EvaluationDistribution
- type EvaluationRollout
- type EvaluationRule
- type EvaluationSegment
- type EvaluationStore
- type FlagStore
- type ListAllParams
- type ListFunc
- type ListOption
- type ListRequest
- type NamespaceStore
- type Order
- type QueryOption
- type QueryParams
- type ResultSet
- type RolloutSegment
- type RolloutStore
- type RolloutThreshold
- type RuleStore
- type SegmentStore
- type Store
Constants ¶
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 )
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"` 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, 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 ListFunc ¶ added in v1.15.0
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 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 RolloutSegment ¶ added in v1.24.0
type RolloutSegment struct { Value bool SegmentOperator flipt.SegmentOperator Segments map[string]*EvaluationSegment }
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
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
type Store ¶
type Store interface { NamespaceStore FlagStore SegmentStore RuleStore RolloutStore EvaluationStore fmt.Stringer }