Documentation
¶
Overview ¶
Package pbflags provides core types for the pbflags evaluation context.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Dimension ¶
type Dimension interface {
// Apply sets this dimension's value on the given proto message.
// The message must be the EvaluationContext type. Apply silently
// does nothing if the named field does not exist on the message
// or if the field's proto kind does not match the dimension type.
Apply(msg protoreflect.Message)
}
Dimension represents a single key-value pair in an evaluation context. Implementations set a named field on the EvaluationContext proto message via protoreflect. Generated dimension constructors (in the dims package) return Dimension values; application code should not implement this interface directly.
func BoolDimension ¶
func BoolDimension(name protoreflect.Name, val bool) Dimension
BoolDimension creates a Dimension that sets a bool field.
func EnumDimension ¶
func EnumDimension(name protoreflect.Name, val protoreflect.EnumNumber) Dimension
EnumDimension creates a Dimension that sets an enum field by ordinal.
func Int64Dimension ¶
func Int64Dimension(name protoreflect.Name, val int64) Dimension
Int64Dimension creates a Dimension that sets an int64 field.
func StringDimension ¶
func StringDimension(name protoreflect.Name, val string) Dimension
StringDimension creates a Dimension that sets a string field.
type Evaluator ¶
type Evaluator interface {
// With returns a new Evaluator with additional context dimensions bound.
// Dimensions from the parent are preserved; new dimensions override
// any existing dimension with the same name.
With(dims ...Dimension) Evaluator
// Evaluate resolves a single flag against the bound context.
// Called by generated client code — not typically called directly.
Evaluate(ctx context.Context, flagID string) (*Result, error)
// BulkEvaluate resolves multiple flags against the bound context.
BulkEvaluate(ctx context.Context, flagIDs []string) ([]*Result, error)
}
Evaluator provides flag evaluation with bound context dimensions. Evaluators are immutable — With() returns a new Evaluator, it does not modify the receiver.
func Connect ¶
Connect creates an Evaluator backed by a FlagEvaluatorService at the given URL. contextMsg is a zero-value instance of the customer's EvaluationContext proto (e.g., &examplepb.EvaluationContext{}). It is used as a prototype for creating new context messages during evaluation.
func FromContext ¶
FromContext retrieves the Evaluator from a context.Context. Returns a no-op evaluator (all compiled defaults) if none is set or if the stored value is a typed-nil.