bullettrain

package module
v0.0.0-...-9634b98 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2021 License: BSD-3-Clause Imports: 6 Imported by: 0

README

Go GoReportCard GoDoc

Flagsmith Go SDK

Flagsmith allows you to manage feature flags and remote config across multiple projects, environments and organisations.

This is the SDK for go for https://www.flagsmith.com/.

Adding to your project

For full documentation visit https://docs.flagsmith.com/clients/go/

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Getting Help

If you encounter a bug or feature request we would like to hear about it. Before you submit an issue please search existing issues in order to prevent duplicates.

Get in touch

If you have any questions about our projects you can email support@flagsmith.com.

Documentation

Index

Constants

View Source
const (
	// DefaultTimeout is a default timeout for HTTP client
	DefaultTimeout = 5 * time.Second
	// DefaultBaseURI is a default URI
	DefaultBaseURI = "https://api.bullet-train.io/api/v1/"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client provides various methods to query BulletTrain API

func DefaultClient

func DefaultClient(apiKey string) *Client

DefaultClient returns new Client with default configuration

func NewClient

func NewClient(apiKey string, config Config) *Client

NewClient creates instance of Client with given configuration

func (*Client) FeatureEnabled

func (c *Client) FeatureEnabled(name string) (bool, error)

FeatureEnabled returns information whether given feature flag is enabled

func (*Client) FeatureEnabledWithContext

func (c *Client) FeatureEnabledWithContext(ctx context.Context, name string) (bool, error)

FeatureEnabledWithContext returns information whether given feature flag is enabled

func (*Client) GetFeatures

func (c *Client) GetFeatures() ([]Flag, error)

GetFeatures returns all features available in given environment

func (*Client) GetFeaturesWithContext

func (c *Client) GetFeaturesWithContext(ctx context.Context) ([]Flag, error)

GetFeaturesWithContext returns all features available in given environment

func (*Client) GetTrait

func (c *Client) GetTrait(user User, key string) (*Trait, error)

GetTrait returns trait defined for given user

func (*Client) GetTraitWithContext

func (c *Client) GetTraitWithContext(ctx context.Context, user User, key string) (*Trait, error)

GetTraitWithContext returns trait defined for given user

func (*Client) GetTraits

func (c *Client) GetTraits(user User, keys ...string) ([]*Trait, error)

GetTraits returns traits defined for given user

If keys are provided, GetTrais returns only corresponding traits, otherwise all traits for given user are returned.

func (*Client) GetTraitsWithContext

func (c *Client) GetTraitsWithContext(ctx context.Context, user User, keys ...string) ([]*Trait, error)

GetTraitsWithContext returns traits defined for given user

If keys are provided, GetTrais returns only corresponding traits, otherwise all traits for given user are returned.

func (*Client) GetUserFeatures

func (c *Client) GetUserFeatures(user User) ([]Flag, error)

GetUserFeatures returns all features as defined for given user

func (*Client) GetUserFeaturesWithContext

func (c *Client) GetUserFeaturesWithContext(ctx context.Context, user User) ([]Flag, error)

GetUserFeaturesWithContext returns all features as defined for given user

func (*Client) GetUserValue

func (c *Client) GetUserValue(user User, name string) (interface{}, error)

GetUserValue return value of given feature (remote config) as defined for given user

Returned value can have one of following types: bool, int, string

func (*Client) GetUserValueWithContext

func (c *Client) GetUserValueWithContext(ctx context.Context, user User, name string) (interface{}, error)

GetUserValueWithContext return value of given feature (remote config) as defined for given user

Returned value can have one of following types: bool, int, string

func (*Client) GetValue

func (c *Client) GetValue(name string) (interface{}, error)

GetValue returns value of given feature (remote config)

Returned value can have one of following types: bool, int, string

func (*Client) GetValueWithContext

func (c *Client) GetValueWithContext(ctx context.Context, name string) (interface{}, error)

GetValueWithContext returns value of given feature (remote config)

Returned value can have one of following types: bool, int, string

func (*Client) HasFeature

func (c *Client) HasFeature(name string) (bool, error)

HasFeature returns information whether given feature is defined

func (*Client) HasFeatureWithContext

func (c *Client) HasFeatureWithContext(ctx context.Context, name string) (bool, error)

HasFeatureWithContext returns information whether given feature is defined

func (*Client) HasUserFeature

func (c *Client) HasUserFeature(user User, name string) (bool, error)

HasUserFeature returns information whether given feature is defined for given user

func (*Client) HasUserFeatureWithContext

func (c *Client) HasUserFeatureWithContext(ctx context.Context, user User, name string) (bool, error)

HasUserFeatureWithContext returns information whether given feature is defined for given user

func (*Client) RemoveProxy

func (c *Client) RemoveProxy()

func (*Client) SetProxy

func (c *Client) SetProxy(proxyUrl string)

func (*Client) UpdateTrait

func (c *Client) UpdateTrait(user User, toUpdate *Trait) (*Trait, error)

UpdateTrait updates trait value

func (*Client) UpdateTraitWithContext

func (c *Client) UpdateTraitWithContext(ctx context.Context, user User, toUpdate *Trait) (*Trait, error)

UpdateTraitWithContext updates trait vaule with context

func (*Client) UpdateTraits

func (c *Client) UpdateTraits(user User, object interface{}) ([]*Trait, error)

UpdateTraits updates trait values in bulk. The object argument may be a []Trait, []*Trait or a struct. If object is []Trait or []*Trait then their Identity field may be mutated. If object is a struct then the struct will be inspected and each key value pair will be considered as a separate trait to be updated.

func (*Client) UpdateTraitsWithContext

func (c *Client) UpdateTraitsWithContext(ctx context.Context, user User, object interface{}) ([]*Trait, error)

UpdateTraitsWithContext updates trait values in bulk. The object argument may be a []Trait, []*Trait or a struct. If object is []Trait or []*Trait then their Identity field may be mutated. If object is a struct then the struct will be inspected and each key value pair will be considered as a separate trait to be updated.

func (*Client) UserFeatureEnabled

func (c *Client) UserFeatureEnabled(user User, name string) (bool, error)

UserFeatureEnabled returns information whether given feature flag is enabled for given user

func (*Client) UserFeatureEnabledWithContext

func (c *Client) UserFeatureEnabledWithContext(ctx context.Context, user User, name string) (bool, error)

UserFeatureEnabled returns information whether given feature flag is enabled for given user

type Config

type Config struct {
	BaseURI string
	Timeout time.Duration
}

Config contains all configurable Client settings

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns default configuration

type Feature

type Feature struct {
	Name        string `json:"name"`
	Type        string `json:"type"`
	Description string `json:"description"`
}

Feature contains core information about feature

type Flag

type Flag struct {
	Feature    Feature     `json:"feature"`
	StateValue interface{} `json:"feature_state_value"`
	Enabled    bool        `json:"enabled"`
}

Flag contains information about Feature and it's value

type Trait

type Trait struct {
	Identity User   `json:"identity"`
	Key      string `json:"trait_key"`
	Value    string `json:"trait_value"`
}

Trait holds information about User's trait

type User

type User struct {
	Identifier string `json:"identifier"`
}

User holds identity information:w:w

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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