flag

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const VariationSDKDefault string = "SdkDefault"

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorCode added in v0.27.0

type ErrorCode = string

ErrorCode is an enum following the open-feature specs about error code.

const (
	ErrorCodeProviderNotReady ErrorCode = "PROVIDER_NOT_READY"
	ErrorCodeFlagNotFound     ErrorCode = "FLAG_NOT_FOUND"
	ErrorCodeParseError       ErrorCode = "PARSE_ERROR"
	ErrorCodeTypeMismatch     ErrorCode = "TYPE_MISMATCH"
	ErrorCodeGeneral          ErrorCode = "GENERAL"
)

type EvaluationContext added in v0.27.0

type EvaluationContext struct {
	// Environment is the name of your current env
	// this value will be added to the custom information of your user and,
	// it will allow to create rules based on this environment,
	Environment string

	// DefaultSdkValue is the default value of the SDK when calling the variation.
	DefaultSdkValue interface{}
}

type Flag

type Flag interface {
	// Value is returning the Value associate to the flag (True / False / Default )
	Value(flagName string, user ffuser.User, evaluationCtx EvaluationContext) (interface{}, ResolutionDetails)

	// String display correctly a flag with the right formatting
	String() string

	// GetVersion is the getter for the field Version
	// Default: 0.0
	GetVersion() float64

	// GetTrackEvents is the getter of the field TrackEvents
	// Default: true
	GetTrackEvents() bool

	// GetDisable is the getter for the field Disable
	// Default: false
	GetDisable() bool

	// GetDefaultVariation return the name of the default variation (if something goes wrong)
	GetDefaultVariation() string

	// GetVariationValue return the value of variation from his name
	GetVariationValue(variationName string) interface{}

	// GetRawValues is returning a raw value of the Flag used by the notifiers
	// We should not have any logic based on these values, this is only to
	// display  the information.
	GetRawValues() map[string]string
}

type ResolutionDetails added in v0.27.0

type ResolutionDetails struct {
	// Variant indicates the name of the variant used when evaluating the flag
	Variant string

	// Reason indicates the reason of the decision
	Reason ResolutionReason

	// ErrorCode indicates the error code for this evaluation
	ErrorCode string
}

type ResolutionReason added in v0.27.0

type ResolutionReason = string

ResolutionReason is an enum following the open-feature specs about resolution reasons.

const (
	// ReasonTargetingMatch Indicates that the feature flag is targeting
	// 100% of the targeting audience,
	// e.g. 100% rollout percentage
	ReasonTargetingMatch ResolutionReason = "TARGETING_MATCH"

	// ReasonSplit Indicates that the feature flag is targeting
	// a subset of the targeting audience,
	// e.g. less than 100% rollout percentage
	ReasonSplit ResolutionReason = "SPLIT"

	// ReasonDisabled Indicates that the feature flag is disabled
	ReasonDisabled ResolutionReason = "DISABLED"

	// ReasonDefault Indicates that the feature flag evaluated to the default value
	ReasonDefault ResolutionReason = "DEFAULT"

	// ReasonStatic	Indicates that the feature flag evaluated to a
	// static value, for example, the default value for the flag
	//
	// Note: Typically means that no dynamic evaluation has been
	// executed for the feature flag
	ReasonStatic ResolutionReason = "STATIC"

	// ReasonUnknown Indicates an unknown issue occurred during evaluation
	ReasonUnknown ResolutionReason = "UNKNOWN"

	// ReasonError Indicates that an error occurred during evaluation
	// Note: The `errorCode`-field contains the details of this error
	ReasonError ResolutionReason = "ERROR"
)

Jump to

Keyboard shortcuts

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