Documentation ¶
Index ¶
- Constants
- func RegisterMetrics() error
- type Option
- func WithAPIKey(apiKey string) Option
- func WithEnableDebugLog(enableDebugLog bool) Option
- func WithErrorLogger(errorLogger log.BaseLogger) Option
- func WithEventFlushInterval(eventFlushInterval time.Duration) Option
- func WithEventFlushSize(eventFlushSize int) Option
- func WithEventQueueCapacity(eventQueueCapacity int) Option
- func WithHost(host string) Option
- func WithNumEventFlushWorkers(numEventFlushWorkers int) Option
- func WithPort(port int) Option
- func WithTag(tag string) Option
- type SDK
Constants ¶
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 ¶
WithAPIKey sets apiKey to use Bucketeer service. (Default: "")
func WithEnableDebugLog ¶
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 ¶
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 ¶
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 ¶
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 WithNumEventFlushWorkers ¶
WithNumEventFlushWorkers sets a number of workers to flush events. (Default: 50)
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.