Documentation
¶
Overview ¶
Package flags evaluates optional product behavior. Flags never grant permissions, change tenant isolation, or replace subscription entitlements.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Evaluator ¶
Evaluator returns the explicit fallback with Defaulted set on every error. Evaluate once before an operation, using facts loaded by its trusted owner.
Example ¶
package main
import (
"context"
"fmt"
"github.com/google/uuid"
"github.com/septagon-oss/platformkit/kit/flags"
)
// A product can supply immutable definitions without importing any SDK.
type definitions map[string]bool
func (d definitions) Boolean(ctx context.Context, key string, _ flags.Subject, fallback bool) (flags.Decision, error) {
failed := flags.Decision{Value: fallback, Defaulted: true}
if err := ctx.Err(); err != nil {
return failed, err
}
value, ok := d[key]
if !ok {
return failed, flags.ErrNotFound
}
return flags.Decision{Value: value}, nil
}
func main() {
var evaluator flags.Evaluator = definitions{"preview": false}
subject := flags.Subject{TenantID: uuid.MustParse("bce3e021-5053-4c36-b4bd-c0a03c6f77b7"), TargetingKey: "member-1"}
decision, err := evaluator.Boolean(context.Background(), "preview", subject, true)
fmt.Println(decision.Value, decision.Defaulted, err)
decision, err = evaluator.Boolean(context.Background(), "missing", subject, true)
fmt.Println(decision.Value, decision.Defaulted, err)
}
Output: false false <nil> true true flags: flag not found
Directories
¶
| Path | Synopsis |
|---|---|
|
providers
|
|
|
ofrep
Package ofrep connects flags to an explicitly configured OFREP endpoint.
|
Package ofrep connects flags to an explicitly configured OFREP endpoint. |
|
openfeature
Package openfeature adapts a selected OpenFeature SDK provider to flags.
|
Package openfeature adapts a selected OpenFeature SDK provider to flags. |
Click to show internal directories.
Click to hide internal directories.