featureflag

package
v14.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Delim is a delimiter used between a feature flag name and its value.
	Delim = ":"
)

Variables

View Source
var (
	// GoUpdateRemoteMirror enables the Go implementation of UpdateRemoteMirror
	GoUpdateRemoteMirror = FeatureFlag{Name: "go_update_remote_mirror", OnByDefault: true}
	// LFSPointersPipeline enables the alternative pipeline implementation of LFS-pointer
	// related RPCs.
	LFSPointersPipeline = FeatureFlag{Name: "lfs_pointers_pipeline", OnByDefault: true}
	// GoSetConfig enables git2go implementation of SetConfig.
	GoSetConfig = FeatureFlag{Name: "go_set_config", OnByDefault: false}
	// CreateRepositoryFromBundleAtomicFetch will add the `--atomic` flag to git-fetch(1) in
	// order to reduce the number of transactional votes.
	CreateRepositoryFromBundleAtomicFetch = FeatureFlag{Name: "create_repository_from_bundle_atomic_fetch", OnByDefault: false}
	ResolveConflictsWithHooks             = FeatureFlag{Name: "resolve_conflicts_with_hooks", OnByDefault: false}
	// ReplicateRepositoryDirectFetch will cause the ReplicateRepository RPC to perform fetches
	// via a direct call instead of doing an RPC call to its own server. This fixes calls of
	// `ReplicateRepository()` in case it's invoked via Praefect with transactions enabled.
	ReplicateRepositoryDirectFetch = FeatureFlag{Name: "replicate_repository_direct_fetch", OnByDefault: false}
	// FindAllTagsPipeline enables the alternative pipeline implementation for finding
	// tags via FindAllTags.
	FindAllTagsPipeline = FeatureFlag{Name: "find_all_tags_pipeline", OnByDefault: false}
	// TxRemoveRepository enables transactionsal voting for the RemoveRepository RPC.
	TxRemoveRepository = FeatureFlag{Name: "tx_remove_repository", OnByDefault: false}
)

A set of feature flags used in Gitaly and Praefect. In order to support coverage of combined features usage all feature flags should be marked as enabled for the test. NOTE: if you add a new feature flag please add it to the `All` list defined below.

All includes all feature flags.

Functions

func AllFlags

func AllFlags(ctx context.Context) []string

AllFlags returns all feature flags with their value that use the Gitaly metadata prefix. Note: results will not be sorted.

func IncomingCtxWithDisabledFeatureFlag

func IncomingCtxWithDisabledFeatureFlag(ctx context.Context, flag FeatureFlag) context.Context

IncomingCtxWithDisabledFeatureFlag marks feature flag as disabled in the incoming context.

func IncomingCtxWithFeatureFlag

func IncomingCtxWithFeatureFlag(ctx context.Context, flag FeatureFlag) context.Context

IncomingCtxWithFeatureFlag is used to enable a feature flag in the incoming context. This is NOT meant for use in clients that transfer the context across process boundaries.

func IncomingCtxWithRubyFeatureFlagValue

func IncomingCtxWithRubyFeatureFlagValue(ctx context.Context, flag FeatureFlag, enabled bool) context.Context

IncomingCtxWithRubyFeatureFlagValue sets the feature flags status in the context.

func OutgoingCtxWithDisabledFeatureFlags

func OutgoingCtxWithDisabledFeatureFlags(ctx context.Context, flags ...FeatureFlag) context.Context

OutgoingCtxWithDisabledFeatureFlags is used to explicitly disable "on by default" feature flags in the outgoing context metadata. The returned context is meant to be used in a client where the outcoming context is transferred to an incoming context.

func OutgoingCtxWithFeatureFlagValue

func OutgoingCtxWithFeatureFlagValue(ctx context.Context, flag FeatureFlag, val string) context.Context

OutgoingCtxWithFeatureFlagValue is used to set feature flags with an explicit value. only "true" or "false" are valid values. Any other value will be ignored.

func OutgoingCtxWithFeatureFlags

func OutgoingCtxWithFeatureFlags(ctx context.Context, flags ...FeatureFlag) context.Context

OutgoingCtxWithFeatureFlags is used to enable feature flags in the outgoing context metadata. The returned context is meant to be used in a client where the outcoming context is transferred to an incoming context.

func OutgoingCtxWithRubyFeatureFlagValue

func OutgoingCtxWithRubyFeatureFlagValue(ctx context.Context, flag FeatureFlag, val string) context.Context

OutgoingCtxWithRubyFeatureFlagValue returns context populated with outgoing metadata that contains ruby feature flags passed in.

func OutgoingWithRaw

func OutgoingWithRaw(ctx context.Context, flags Raw) context.Context

OutgoingWithRaw returns a new context with raw flags appended into the outgoing metadata.

Types

type FeatureFlag

type FeatureFlag struct {
	// Name is the name of the feature flag.
	Name string `json:"name"`
	// OnByDefault is the default value if the feature flag is not explicitly set in
	// the incoming context.
	OnByDefault bool `json:"on_by_default"`
}

FeatureFlag gates the implementation of new or changed functionality.

func (FeatureFlag) IsDisabled added in v14.1.0

func (ff FeatureFlag) IsDisabled(ctx context.Context) bool

IsDisabled determines whether the feature flag is disabled in the incoming context.

func (FeatureFlag) IsEnabled added in v14.1.0

func (ff FeatureFlag) IsEnabled(ctx context.Context) bool

IsEnabled checks if the feature flag is enabled for the passed context. Only returns true if the metadata for the feature flag is set to "true"

type Raw

type Raw map[string]string

Raw contains feature flags and their values in their raw form with header prefix in place and values unparsed.

func RawFromContext

func RawFromContext(ctx context.Context) Raw

RawFromContext returns a map that contains all feature flags with their values. The feature flags are in their raw format with the header prefix in place. If multiple values are set a flag, the first occurrence is used.

This is mostly intended for propagating the feature flags by other means than the metadata, for example into the hooks through the environment.

Jump to

Keyboard shortcuts

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