evaluation

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EvaluationContext

type EvaluationContext struct {
	Attributes map[string]string
	// contains filtered or unexported fields
}

EvaluationContext holds the context for rule evaluation and implements context.Context.

This context is request-scoped and should be created per operation, not stored long-term. By embedding context.Context, it provides both evaluation attributes and standard context lifecycle management (timeouts, cancellation, request-scoped values).

Example usage:

// Simple usage with default background context
ctx := evaluation.NewEvaluationContext(map[string]string{
	"user_id": "123",
	"region": "us-west",
})
err := client.GetFig("my-config", &config, ctx)

// With timeout
baseCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
ctx := evaluation.NewEvaluationContextWithContext(baseCtx, map[string]string{
	"user_id": "123",
})
err := client.GetFig("my-config", &config, ctx)

// In HTTP handlers (inherits request cancellation)
ctx := evaluation.NewEvaluationContextWithContext(r.Context(), map[string]string{
	"user_id": getUserID(r),
})
err := client.GetFig("feature-flags", &config, ctx)

func NewEvaluationContext

func NewEvaluationContext(attributes map[string]string) *EvaluationContext

NewEvaluationContext creates a new EvaluationContext with context.Background(). The context should be request-scoped and created per operation.

For operations that need timeout or cancellation support, use NewEvaluationContextWithContext.

func NewEvaluationContextWithContext added in v0.2.0

func NewEvaluationContextWithContext(ctx context.Context, attributes map[string]string) *EvaluationContext

NewEvaluationContextWithContext creates a new EvaluationContext with the given context. This allows you to pass in a parent context for timeout, cancellation, or request-scoped values.

The context should be request-scoped and created per operation, not stored long-term. If ctx is nil, context.Background() is used.

func (*EvaluationContext) Deadline added in v0.2.0

func (c *EvaluationContext) Deadline() (deadline time.Time, ok bool)

Deadline implements context.Context.

func (*EvaluationContext) Done added in v0.2.0

func (c *EvaluationContext) Done() <-chan struct{}

Done implements context.Context.

func (*EvaluationContext) Err added in v0.2.0

func (c *EvaluationContext) Err() error

Err implements context.Context.

func (*EvaluationContext) Merge

Merge merges another context into this one, preserving the original context.Context.

func (*EvaluationContext) Value added in v0.2.0

func (c *EvaluationContext) Value(key interface{}) interface{}

Value implements context.Context.

type Evaluator

type Evaluator interface {
	Evaluate(figFamily *model.FigFamily, context *EvaluationContext) (*model.Fig, error)
}

Evaluator defines the interface for evaluating rollouts.

type RuleBasedEvaluator

type RuleBasedEvaluator struct{}

RuleBasedEvaluator implements rule-based rollout evaluation.

func NewRuleBasedEvaluator

func NewRuleBasedEvaluator() *RuleBasedEvaluator

NewRuleBasedEvaluator creates a new RuleBasedEvaluator.

func (*RuleBasedEvaluator) Evaluate

func (e *RuleBasedEvaluator) Evaluate(figFamily *model.FigFamily, context *EvaluationContext) (*model.Fig, error)

Jump to

Keyboard shortcuts

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