bucketeer

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

View Source
const SourceIDGoServer = 5

Variables

This section is empty.

Functions

func RegisterMetrics

func RegisterMetrics() error

RegisterMetrics begins collecting data for the OpenCensus views.

NOTE: Currently, we only support OpenCensus to provide metrics, but we would support other libraries if there is a demand. In that time, we will add a breaking change to support them.

Types

type Option

type Option func(*options)

Option is the functional options type (Functional Options Pattern) to set sdk options.

func WithAPIKey

func WithAPIKey(apiKey string) Option

WithAPIKey sets apiKey to use Bucketeer service. (Default: "")

func WithEnableDebugLog

func WithEnableDebugLog(enableDebugLog bool) Option

WithEnableDebugLog sets if outpus debug logs or not. (Default: false)

Debug logs are for Bucketeer SDK developers.

func WithErrorLogger

func WithErrorLogger(errorLogger log.BaseLogger) Option

WithErrorLogger sets a looger to output error logs. (Default: log.DefaultErrorLogger)

Error logs are for Bucketeer SDK users.

func WithEventFlushInterval

func WithEventFlushInterval(eventFlushInterval time.Duration) Option

WithEventFlushInterval sets a interval of flushing events. (Default: 1 min)

Each worker sends the events to Bucketeer service every time eventFlushInterval elapses or its buffer exceeds eventFlushSize.

func WithEventFlushSize

func WithEventFlushSize(eventFlushSize int) Option

WithEventFlushSize sets a size of the buffer for each worker. (Default: 100)

Each worker sends the events to Bucketeer service every time eventFlushInterval elapses or its buffer exceeds eventFlushSize.

func WithEventQueueCapacity

func WithEventQueueCapacity(eventQueueCapacity int) Option

WithEventQueueCapacity sets a capacity of the event queue. (Default: 100_000)

The SDK buffers events up to the capacity in memory before processing. If the capacity is exceeded, events will be discarded.

func WithHost

func WithHost(host string) Option

WithHost sets host name for the Bucketeer service. (Default: "")

func WithNumEventFlushWorkers

func WithNumEventFlushWorkers(numEventFlushWorkers int) Option

WithNumEventFlushWorkers sets a number of workers to flush events. (Default: 50)

func WithPort

func WithPort(port int) Option

WithPort sets port for the Bucketeer service. (Default: 443)

func WithTag

func WithTag(tag string) Option

WithTag sets tag specified in getting evaluation. (Default: "")

type SDK

type SDK interface {
	// BoolVariation returns the value of a feature flag (whose variations are booleans) for the given user.
	//
	// BoolVariation returns defaultValue if an error occurs.
	BoolVariation(ctx context.Context, user *user.User, featureID string, defaultValue bool) bool

	// IntVariation returns the value of a feature flag (whose variations are ints) for the given user.
	//
	// IntVariation returns defaultValue if an error occurs.
	IntVariation(ctx context.Context, user *user.User, featureID string, defaultValue int) int

	// Int64Variation returns the value of a feature flag (whose variations are int64s) for the given user.
	//
	// Int64Variation returns defaultValue if an error occurs.
	Int64Variation(ctx context.Context, user *user.User, featureID string, defaultValue int64) int64

	// Float64Variation returns the value of a feature flag (whose variations are float64s) for the given user.
	//
	// Float64Variation returns defaultValue if an error occurs.
	Float64Variation(ctx context.Context, user *user.User, featureID string, defaultValue float64) float64

	// StringVariation returns the value of a feature flag (whose variations are strings) for the given user.
	//
	// StringVariation returns defaultValue if an error occurs.
	StringVariation(ctx context.Context, user *user.User, featureID, defaultValue string) string

	// JSONVariation parses the value of a feature flag (whose variations are jsons) for the given user,
	// and stores the result in dst.
	JSONVariation(ctx context.Context, user *user.User, featureID string, dst interface{})

	// Track reports that a user has performed a goal event.
	//
	// TODO: Track doesn't work correctly until Bucketeer service implements the new goal tracking architecture.
	Track(ctx context.Context, user *user.User, GoalID string)

	// TrackValue reports that a user has performed a goal event, and associates it with a custom value.
	//
	// TODO: TrackValue doesn't work correctly until Bucketeer service implements the new goal tracking architecture.
	TrackValue(ctx context.Context, user *user.User, GoalID string, value float64)

	// Close tears down all SDK activities and resources, after ensuring that all events have been delivered.
	//
	// After calling this, the SDK should no longer be used.
	Close(ctx context.Context) error
}

SDK is the Bucketeer SDK.

SDK represents the ability to get the value of a feature flag and to track goal events by communicating with the Bucketeer service.

A user application should instantiate a single SDK instance for the lifetime of the application and share it. SDK is safe for concurrent use by multiple goroutines.

func NewNopSDK

func NewNopSDK() SDK

NewNopSDK creates a new no-op Bucketeer SDK.

It never requests to Bucketeer Service, and just returns default value when XXXVariation methods called.

func NewSDK

func NewSDK(ctx context.Context, opts ...Option) (SDK, error)

NewSDK creates a new Bucketeer SDK.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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