dto

package
v1.24.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LegacyRuleName = "legacyRuleV0"
)

Functions

func ConvertV0DtoToInternalFlag

func ConvertV0DtoToInternalFlag(d DTO, isScheduledStep bool) flag.InternalFlag

ConvertV0DtoToInternalFlag is converting a flag in the config file to the internal format. this function convert only the old format of the flag (before v1.0.0), to keep backward support of the configurations.

func ConvertV1DtoToInternalFlag

func ConvertV1DtoToInternalFlag(dto DTO) flag.InternalFlag

ConvertV1DtoToInternalFlag is converting a DTO to a flag.InternalFlag

Types

type CommonRollout

type CommonRollout struct {
	// Experimentation is your struct to configure an experimentation, it will allow you to configure a start date and
	// an end date for your flag.
	// When the experimentation is not running, the flag will serve the default value.
	Experimentation *ExperimentationDto `json:"experimentation,omitempty" yaml:"experimentation,omitempty" toml:"experimentation,omitempty"` // nolint: lll

	// Progressive (only for v0) is your struct to configure a progressive rollout deployment of your flag.
	// It will allow you to ramp up the percentage of your flag over time.
	// You can decide at which percentage you start and at what percentage you ends in your release ramp.
	// Before the start date we will serve the initial percentage and, after we will serve the end percentage.
	Progressive *ProgressiveV0 `json:"progressive,omitempty" yaml:"progressive,omitempty" toml:"progressive,omitempty"` // nolint: lll
}

type DTO

type DTO struct {
	DTOv1 `json:",inline" yaml:",inline" toml:",inline"`
	DTOv0 `json:",inline" yaml:",inline" toml:",inline"`

	// TrackEvents is false if you don't want to export the data in your data exporter.
	// Default value is true
	TrackEvents *bool `json:"trackEvents,omitempty" yaml:"trackEvents,omitempty" toml:"trackEvents,omitempty"`

	// Disable is true if the flag is disabled.
	Disable *bool `json:"disable,omitempty" yaml:"disable,omitempty" toml:"disable,omitempty"`

	// Version (optional) This field contains the version of the flag.
	// The version is manually managed when you configure your flags and, it is used to display the information
	// in the notifications and data collection.
	Version *string `json:"version,omitempty" yaml:"version,omitempty" toml:"version,omitempty"`

	// Converter (optional) is the name of converter to use, if no converter specified we try to determine
	// which converter to use based on the fields we receive for the flag
	Converter *string `json:"converter,omitempty" yaml:"converter,omitempty" toml:"converter,omitempty"`
}

DTO is representing all the fields we can have in a flag. This DTO supports all flag formats and convert them into an InternalFlag using a converter.

func (*DTO) Convert

func (d *DTO) Convert() flag.InternalFlag

type DTOv0

type DTOv0 struct {
	// Rule is the query use to select on which user the flag should apply.
	// Rule format is based on the nikunjy/rules module.
	// If no rule set, the flag apply to all users (percentage still apply).
	Rule *string `json:"rule,omitempty" yaml:"rule,omitempty" toml:"rule,omitempty"`

	// Percentage of the users affected by the flag.
	// Default value is 0
	Percentage *float64 `json:"percentage,omitempty" yaml:"percentage,omitempty" toml:"percentage,omitempty"`

	// True is the value return by the flag if apply to the user (rule is evaluated to true)
	// and user is in the active percentage.
	True *interface{} `json:"true,omitempty" yaml:"true,omitempty" toml:"true,omitempty"`

	// False is the value return by the flag if apply to the user (rule is evaluated to true)
	// and user is not in the active percentage.
	False *interface{} `json:"false,omitempty" yaml:"false,omitempty" toml:"false,omitempty"`

	// Default is the value return by the flag if not apply to the user (rule is evaluated to false).
	Default *interface{} `json:"default,omitempty" yaml:"default,omitempty" toml:"default,omitempty"`

	// Rollout is the object to configure how the flag is rolled out.
	// You have different rollout strategy available but only one is used at a time.
	Rollout *Rollout `json:"rollout,omitempty" yaml:"rollout,omitempty" toml:"rollout,omitempty"`
}

DTOv0 describe the fields of a flag.

type DTOv1

type DTOv1 struct {
	// Variations are all the variations available for this flag. The minimum is 2 variations and, we don't have any max
	// limit except if the variationValue is a bool, the max is 2.
	Variations *map[string]*interface{} `` // nolint:lll
	/* 284-byte string literal not displayed */

	// Rules is the list of Rule for this flag.
	// This an optional field.
	Rules *[]flag.Rule `` // nolint: lll
	/* 199-byte string literal not displayed */

	// DefaultRule is the rule applied after checking that any other rules
	// matched the user.
	DefaultRule *flag.Rule `` // nolint: lll
	/* 220-byte string literal not displayed */

	// Scheduled is your struct to configure an update on some fields of your flag over time.
	// You can add several steps that updates the flag, this is typically used if you want to gradually add more user
	// in your flag.
	Scheduled *[]flag.ScheduledStep `` // nolint: lll
	/* 208-byte string literal not displayed */

	// Experimentation is your struct to configure an experimentation.
	// It will allow you to configure a start date and an end date for your flag.
	// When the experimentation is not running, the flag will serve the default value.
	Experimentation *ExperimentationDto `` // nolint: lll
	/* 250-byte string literal not displayed */

	// Metadata is a field containing information about your flag such as an issue tracker link, a description, etc ...
	Metadata *map[string]interface{} `` // nolint: lll
	/* 215-byte string literal not displayed */
}

DTOv1 is the new format of the flags since version 1.X.X

type ExperimentationDto

type ExperimentationDto struct {
	// Start is the starting time of the experimentation
	Start *time.Time `` // nolint: lll
	/* 156-byte string literal not displayed */

	// End is the ending time of the experimentation
	End *time.Time `` // nolint: lll
	/* 148-byte string literal not displayed */
}

type ProgressivePercentageV0

type ProgressivePercentageV0 struct {
	// Initial is the initial percentage before the rollout start date.
	// This field is optional
	// Default: 0.0
	Initial float64 `json:"initial,omitempty" yaml:"initial,omitempty" toml:"initial,omitempty"`

	// End is the target percentage we want to reach at the end of the rollout phase.
	// This field is optional
	// Default: 100.0
	End float64 `json:"end,omitempty" yaml:"end,omitempty" toml:"end,omitempty"`
}

type ProgressiveReleaseRampV0

type ProgressiveReleaseRampV0 struct {
	// Start is the starting time of the ramp
	Start *time.Time `json:"start,omitempty" yaml:"start,omitempty" toml:"start,omitempty"`

	// End is the ending time of the ramp
	End *time.Time `json:"end,omitempty" yaml:"end,omitempty" toml:"end,omitempty"`
}

type ProgressiveV0

type ProgressiveV0 struct {
	// Percentage is where you can configure at what percentage your progressive rollout start
	// and at what percentage it ends.
	// This field is optional
	Percentage ProgressivePercentageV0 `json:"percentage,omitempty" yaml:"percentage,omitempty" toml:"percentage,omitempty"` // nolint: lll

	// ReleaseRamp is the defining when the progressive rollout starts and ends.
	// This field is mandatory if you want to use a progressive rollout.
	// If any field missing we ignore the progressive rollout.
	ReleaseRamp ProgressiveReleaseRampV0 `json:"releaseRamp,omitempty" yaml:"releaseRamp,omitempty" toml:"releaseRamp,omitempty"` // nolint: lll
}

ProgressiveV0 is the configuration struct to define a progressive rollout.

type Rollout

type Rollout struct {
	// CommonRollout is the struct containing the configuration for rollout that applies for
	// all types of flag in your input file.
	CommonRollout `json:",inline" yaml:",inline" toml:",inline"`

	// V0Rollout contains the configuration available only for the flags version v0.X.X
	V0Rollout `json:",inline" yaml:",inline" toml:",inline"` // nolint: govet
}

type ScheduledRolloutV0

type ScheduledRolloutV0 struct {
	// Steps is the list of updates to do in a specific date.
	Steps []ScheduledStepV0 `json:"steps,omitempty" yaml:"steps,omitempty" toml:"steps,omitempty"`
}

type ScheduledStepV0

type ScheduledStepV0 struct {
	DTO  `yaml:",inline"`
	Date *time.Time `json:"date,omitempty" yaml:"date,omitempty" toml:"date,omitempty"`
}

type V0Rollout

type V0Rollout struct {
	// Scheduled is your struct to configure an update on some fields of your flag over time.
	// You can add several steps that updates the flag, this is typically used if you want to gradually add more user
	// in your flag.
	Scheduled *ScheduledRolloutV0 `json:"scheduled,omitempty" yaml:"scheduled,omitempty" toml:"scheduled,omitempty"` // nolint: lll
}

Jump to

Keyboard shortcuts

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