feature_flags

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

README

sequenceDiagram
    Main->>+Config: LoadConfig(configFile)
    Config->>-Main: config
    Main->>FFManager: config.Features
    Main->>+CommandChannelService: InitialFetch
    CommandChannelService->>+CommandChannelAPI: GetCommands
    CommandChannelAPI->>-CommandChannelService: commands
    loop commands
        CommandChannelService->>+FFHandler: handle(command)
        FFHandler->>FFManager: Set(FFlag)
        alt not ExistsFromConfig (FFlag)
            FFManager->>FFManager: Store (FFlag)
        end
    end

Documentation

Overview

Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

nolint

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFeatureFlagAlreadyExists = errors.New("feature flag already exists")
)

Functions

This section is empty.

Types

type FeatureFlagRetrieverMock added in v0.1.0

type FeatureFlagRetrieverMock struct {
	mock.Mock
}

func (*FeatureFlagRetrieverMock) GetFeatureFlag added in v0.1.0

func (f *FeatureFlagRetrieverMock) GetFeatureFlag(name string) (enabled, exists bool)

func (*FeatureFlagRetrieverMock) ShouldGetExistingFeatureFlag added in v0.1.0

func (f *FeatureFlagRetrieverMock) ShouldGetExistingFeatureFlag(name string, enabled bool)

func (*FeatureFlagRetrieverMock) ShouldGetFeatureFlag added in v0.1.0

func (f *FeatureFlagRetrieverMock) ShouldGetFeatureFlag(name string, enabled bool, exists bool)

func (*FeatureFlagRetrieverMock) ShouldNotGetFeatureFlag added in v0.1.0

func (f *FeatureFlagRetrieverMock) ShouldNotGetFeatureFlag(name string)

type FeatureFlags

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

func NewManager

func NewManager(initialFeatureFlags map[string]bool) *FeatureFlags

func (*FeatureFlags) GetFeatureFlag

func (f *FeatureFlags) GetFeatureFlag(name string) (enabled, exists bool)

GetFeatureFlag returns if a FF is enabled and exists

func (*FeatureFlags) SetFeatureFlag

func (f *FeatureFlags) SetFeatureFlag(name string, enabled bool) error

SetFeatureFlag adds a new FF to the config. FFs can be defined in the agent's config file or they may come from the Command Channel. As the command channel runs asynchronously, we need to lock the feature flags.

type Manager

type Manager interface {
	Setter
	Retriever
}

Manager allows you to add or get feature flags.

type Retriever

type Retriever interface {
	GetFeatureFlag(name string) (enabled, exists bool)
}

type Setter

type Setter interface {
	// SetFeatureFlag enables or disables FF on the config if not already set.
	SetFeatureFlag(name string, enabled bool) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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