ffcontext

package
v1.37.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: MIT Imports: 1 Imported by: 24

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context interface {
	// GetKey return the unique key for the context.
	GetKey() string
	// IsAnonymous return if the context is about an anonymous user or not.
	IsAnonymous() bool
	// GetCustom return all the custom properties added to the context.
	GetCustom() map[string]interface{}
	// AddCustomAttribute allows to add a custom attribute into the context.
	AddCustomAttribute(name string, value interface{})
	// ExtractGOFFProtectedFields extract the goff specific attributes from the evaluation context.
	ExtractGOFFProtectedFields() GoffContextSpecifics
}

type EvaluationContext

type EvaluationContext struct {
	// contains filtered or unexported fields
}

EvaluationContext contains specific attributes for your evaluation. Most of the time it is identifying a user browsing your site. The only mandatory property is the Key, which must a unique identifier. For authenticated users, this may be a username or e-mail address. For anonymous users, this could be an IP address or session ID.

EvaluationContext fields are immutable and can be accessed only via getter methods. To construct an EvaluationContext, use either a simple constructor (NewEvaluationContext) or the builder pattern with NewEvaluationContextBuilder.

func NewAnonymousEvaluationContext deprecated

func NewAnonymousEvaluationContext(key string) EvaluationContext

Deprecated: NewAnonymousEvaluationContext is here for compatibility reason. Please use NewEvaluationContext instead and add a custom attribute to know that it is an anonymous user.

ctx := NewEvaluationContext("my-key") ctx.AddCustomAttribute("anonymous", true)

func NewEvaluationContext

func NewEvaluationContext(key string) EvaluationContext

NewEvaluationContext creates a new evaluation context identified by the given key.

func (EvaluationContext) AddCustomAttribute

func (u EvaluationContext) AddCustomAttribute(name string, value interface{})

AddCustomAttribute allows to add a custom attribute into the user.

func (EvaluationContext) ExtractGOFFProtectedFields added in v1.32.0

func (u EvaluationContext) ExtractGOFFProtectedFields() GoffContextSpecifics

ExtractGOFFProtectedFields extract the goff specific attributes from the evaluation context.

func (EvaluationContext) GetCustom

func (u EvaluationContext) GetCustom() map[string]interface{}

GetCustom return all the custom properties of a user.

func (EvaluationContext) GetKey

func (u EvaluationContext) GetKey() string

GetKey return the unique key for the user.

func (EvaluationContext) IsAnonymous

func (u EvaluationContext) IsAnonymous() bool

IsAnonymous return if the user is anonymous or not.

type EvaluationContextBuilder

type EvaluationContextBuilder interface {
	// Deprecated: Anonymous is to flag the context for an anonymous context or not.
	// This function is here for compatibility reason, please consider to use AddCustom("anonymous", true)
	// instead of using this function.
	Anonymous(bool) EvaluationContextBuilder

	AddCustom(string, interface{}) EvaluationContextBuilder
	Build() EvaluationContext
}

EvaluationContextBuilder is a builder to create an EvaluationContext.

func NewEvaluationContextBuilder

func NewEvaluationContextBuilder(key string) EvaluationContextBuilder

NewEvaluationContextBuilder constructs a new EvaluationContextBuilder, specifying the user key.

For authenticated users, the key may be a username or e-mail address. For anonymous users, this could be an IP address or session ID.

type GoffContextSpecifics added in v1.32.0

type GoffContextSpecifics struct {
	// CurrentDateTime is the current date time to use for the evaluation.
	CurrentDateTime *time.Time `json:"currentDateTime"`
	// FlagList is the list of flags to evaluate in a bulk evaluation.
	FlagList []string `json:"flagList"`
}

Jump to

Keyboard shortcuts

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