eval

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2023 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Disabled = "DISABLED"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AnyValue added in v0.3.1

type AnyValue struct {
	Value   interface{}
	Variant string
	Reason  string
	FlagKey string
}

func NewAnyValue added in v0.3.1

func NewAnyValue(value interface{}, variant string, reason string, flagKey string) AnyValue

type Evaluators added in v0.0.8

type Evaluators struct {
	Evaluators map[string]json.RawMessage `json:"$evaluators"`
}

type Flag added in v0.0.3

type Flag struct {
	State          string          `json:"state"`
	DefaultVariant string          `json:"defaultVariant"`
	Variants       map[string]any  `json:"variants"`
	Targeting      json.RawMessage `json:"targeting,omitempty"`
	Source         string          `json:"source"`
}

type Flags

type Flags struct {
	Flags map[string]Flag `json:"flags"`
}

func (Flags) Merge added in v0.0.4

func (f Flags) Merge(logger *logger.Logger, source string, ff Flags) (Flags, map[string]interface{})

type IEvaluator

type IEvaluator interface {
	GetState() (string, error)
	SetState(source string, state string) (map[string]interface{}, error)

	ResolveBooleanValue(
		reqID string,
		flagKey string,
		context *structpb.Struct) (value bool, variant string, reason string, err error)
	ResolveStringValue(
		reqID string,
		flagKey string,
		context *structpb.Struct) (value string, variant string, reason string, err error)
	ResolveIntValue(
		reqID string,
		flagKey string,
		context *structpb.Struct) (value int64, variant string, reason string, err error)
	ResolveFloatValue(
		reqID string,
		flagKey string,
		context *structpb.Struct) (value float64, variant string, reason string, err error)
	ResolveObjectValue(
		reqID string,
		flagKey string,
		context *structpb.Struct) (value map[string]any, variant string, reason string, err error)
	ResolveAllValues(
		reqID string,
		context *structpb.Struct) (values []AnyValue)
}

IEvaluator implementations store the state of the flags, do parsing and validation of the flag state and evaluate flags in response to handlers.

type JSONEvaluator added in v0.0.3

type JSONEvaluator struct {
	Logger *logger.Logger
	// contains filtered or unexported fields
}

func NewJSONEvaluator added in v0.2.7

func NewJSONEvaluator(logger *logger.Logger) *JSONEvaluator

func (*JSONEvaluator) GetState added in v0.0.3

func (je *JSONEvaluator) GetState() (string, error)

func (*JSONEvaluator) ResolveAllValues added in v0.3.1

func (je *JSONEvaluator) ResolveAllValues(reqID string, context *structpb.Struct) []AnyValue

func (*JSONEvaluator) ResolveBooleanValue added in v0.0.3

func (je *JSONEvaluator) ResolveBooleanValue(reqID string, flagKey string, context *structpb.Struct) (
	value bool,
	variant string,
	reason string,
	err error,
)

func (*JSONEvaluator) ResolveFloatValue added in v0.0.6

func (je *JSONEvaluator) ResolveFloatValue(reqID string, flagKey string, context *structpb.Struct) (
	value float64,
	variant string,
	reason string,
	err error,
)

func (*JSONEvaluator) ResolveIntValue added in v0.0.6

func (je *JSONEvaluator) ResolveIntValue(reqID string, flagKey string, context *structpb.Struct) (
	value int64,
	variant string,
	reason string,
	err error,
)

func (*JSONEvaluator) ResolveObjectValue added in v0.0.3

func (je *JSONEvaluator) ResolveObjectValue(reqID string, flagKey string, context *structpb.Struct) (
	value map[string]any,
	variant string,
	reason string,
	err error,
)

func (*JSONEvaluator) ResolveStringValue added in v0.0.3

func (je *JSONEvaluator) ResolveStringValue(reqID string, flagKey string, context *structpb.Struct) (
	value string,
	variant string,
	reason string,
	err error,
)

func (*JSONEvaluator) SetState added in v0.0.3

func (je *JSONEvaluator) SetState(source string, state string) (map[string]interface{}, error)

type StateChangeNotification added in v0.2.3

type StateChangeNotification struct {
	Type    StateChangeNotificationType `json:"type"`
	Source  string                      `json:"source"`
	FlagKey string                      `json:"flagKey"`
}

type StateChangeNotificationType added in v0.2.3

type StateChangeNotificationType string
const (
	NotificationDelete StateChangeNotificationType = "delete"
	NotificationCreate StateChangeNotificationType = "write"
	NotificationUpdate StateChangeNotificationType = "update"
)

Directories

Path Synopsis
Package evalmock is a generated GoMock package.
Package evalmock is a generated GoMock package.

Jump to

Keyboard shortcuts

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