exporter

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2022 License: MIT Imports: 8 Imported by: 11

Documentation

Overview

Package exporter defines the data exporter of go-feature-flag

These exporters are usable in your init configuration.

ffclient.Init(ffclient.Config{
  //...
  DataExporter: ffclient.DataExporter{
      FlushInterval:   10 * time.Second,
      MaxEventInMemory: 1000,
      Exporter: &fileexporter.Exporter{
          OutputDir: "/output-data/",
      },
  },
  //...
})

Check in this package available exporters.

Index

Constants

View Source
const DefaultCsvTemplate = "{{ .Kind}};{{ .ContextKind}};{{ .UserKey}};{{ .CreationDate}};{{ .Key}};{{ .Variation}};" +
	"{{ .Value}};{{ .Default}}\n"
View Source
const DefaultFilenameTemplate = "flag-variation-{{ .Hostname}}-{{ .Timestamp}}.{{ .Format}}"

Variables

This section is empty.

Functions

func ComputeFilename

func ComputeFilename(template *template.Template, format string) (string, error)

ComputeFilename is computing the filename to use for the export file

func FormatEventInCSV

func FormatEventInCSV(csvTemplate *template.Template, event FeatureEvent) ([]byte, error)

func FormatEventInJSON

func FormatEventInJSON(event FeatureEvent) ([]byte, error)

func ParseTemplate

func ParseTemplate(name string, templateToParse string, defaultTemplate string) *template.Template

ParseTemplate is parsing the template given by the config or use the default template

Types

type FeatureEvent

type FeatureEvent struct {
	// 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"`

	// ContextKind is 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"`

	// UserKey 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"`

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

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

	// 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 string `json:"variation"`

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

	// Default 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"`

	// Version contains the version of the flag. If the field is omitted for the flag in the configuration file
	// the default version will be 0.
	Version float64 `json:"version"`
}

func NewFeatureEvent

func NewFeatureEvent(
	user ffuser.User,
	flagKey string,
	value interface{},
	variation string,
	failed bool,
	version float64,
) FeatureEvent

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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