exporter

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataExporterScheduler

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

DataExporterScheduler is the struct that handle the data collection.

func NewDataExporterScheduler

func NewDataExporterScheduler(ctx context.Context, flushInterval time.Duration, maxEventInMemory int64,
	exporter Exporter, logger *log.Logger) *DataExporterScheduler

NewDataExporterScheduler allows to create a new instance of DataExporterScheduler ready to be used to export data.

func (*DataExporterScheduler) AddEvent

func (dc *DataExporterScheduler) AddEvent(event FeatureEvent)

AddEvent allow to add an event to the local cache and to call the exporter if we reach the maximum number of events that can be present in the cache.

func (*DataExporterScheduler) Close

func (dc *DataExporterScheduler) Close()

Close will stop the daemon and send the data still in the cache

func (*DataExporterScheduler) StartDaemon

func (dc *DataExporterScheduler) StartDaemon()

StartDaemon will start a goroutine to check every X seconds if we should send the data. The daemon is started only if we have a bulk exporter.

type Exporter

type Exporter interface {
	// Export will send the data to the exporter.
	Export(context.Context, *log.Logger, []FeatureEvent) error

	// IsBulk return false if we should directly send the data as soon as it is produce
	// and true if we collect the data to send them in bulk.
	IsBulk() bool
}

Exporter is an interface to describe how a exporter looks like.

type FeatureEvent

type FeatureEvent struct {
	// The kind for a feature event is feature.
	// A feature event will only be generated if the trackEvents attribute of the flag is set to true.
	Kind string `json:"kind"`

	// The kind of context which generated an event. This will only be "anonymousUser" for events generated on behalf of
	// an anonymous user or the reserved word "user" for events generated on behalf of a non-anonymous user
	ContextKind string `json:"contextKind,omitempty"`

	// The key of the user object used in a feature flag evaluation. Details for the user object used in a feature flag
	// evaluation as reported by the "feature" event are transmitted periodically with a separate index event.
	UserKey string `json:"userKey"`

	// When the feature flag was requested at Unix epoch time in milliseconds.
	CreationDate int64 `json:"creationDate"`

	// The key of the feature flag requested.
	Key string `json:"key"`

	// The variation of the flag requested. Flag variation values can be "True", "False", "Default" or "SdkDefault"
	// depending on which value was taken during flag evaluation. "SdkDefault" is used when an error is detected and the
	// default value passed during the call to your variation is used.
	Variation model.VariationType `json:"variation"`

	// The value of the feature flag returned by feature flag evaluation.
	Value interface{} `json:"value"`

	// This value is set to true if feature flag evaluation failed, in which case the value returned was the default value
	// passed to variation. If the default field is omitted, it is assumed to be false.
	Default bool `json:"default"`
}

func NewFeatureEvent

func NewFeatureEvent(
	user ffuser.User,
	flagKey string,
	flag model.Flag,
	value interface{},
	variation model.VariationType,
	failed bool) FeatureEvent

Jump to

Keyboard shortcuts

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