Documentation ¶
Overview ¶
Package ffexporter defines the data exporter of go-feature-flag
Theses exporters are usable in your init configuration.
ffclient.Init(ffclient.Config{ //... DataExporter: ffclient.DataExporter{ FlushInterval: 10 * time.Second, MaxEventInMemory: 1000, Exporter: &ffexporter.File{ 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 ¶
This section is empty.
Types ¶
type FeatureEvent ¶ added in v0.19.5
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 ¶ added in v0.19.5
type File ¶
type File struct { // Format is the output format you want in your exported file. // Available format are JSON and CSV. // Default: JSON Format string // OutputDir is the location of the directory where to store the exported files // It should finish with a / // Default: the current directory OutputDir string // Filename is the name of your output file // You can use a templated config to define the name of your export files. // Available replacement are {{ .Hostname}}, {{ .Timestamp}} and {{ .Format}} // Default: "flag-variation-{{ .Hostname}}-{{ .Timestamp}}.{{ .Format}}" Filename string // CsvTemplate is used if your output format is CSV. // This field will be ignored if you are using another format than CSV. // You can decide which fields you want in your CSV line with a go-template syntax, // please check internal/exporter/feature_event.go to see what are the fields available. // Default: // {{ .Kind}};{{ .ContextKind}};{{ .UserKey}};{{ .CreationDate}};{{ .Key}};{{ .Variation}};{{ .Value}};{{ .Default}}\n CsvTemplate string // contains filtered or unexported fields }
type GoogleCloudStorage ¶ added in v0.21.0
type GoogleCloudStorage struct { // Bucket is the name of your S3 Bucket. Bucket string // Options are Google Cloud Api options to connect to Google Storage SDK Options []option.ClientOption // Format is the output format you want in your exported file. // Available format are JSON and CSV. // Default: JSON Format string // Path allows you to specify in which directory you want to export your data. Path string // Filename is the name of your output file // You can use a templated config to define the name of your export files. // Available replacement are {{ .Hostname}}, {{ .Timestamp}} and {{ .Format}} // Default: "flag-variation-{{ .Hostname}}-{{ .Timestamp}}.{{ .Format}}" Filename string // CsvTemplate is used if your output format is CSV. // This field will be ignored if you are using another format than CSV. // You can decide which fields you want in your CSV line with a go-template syntax, // please check internal/exporter/feature_event.go to see what are the fields available. // Default: // {{ .Kind}};{{ .ContextKind}};{{ .UserKey}};{{ .CreationDate}};{{ .Key}};{{ .Variation}};{{ .Value}};{{ .Default}}\n CsvTemplate string }
func (*GoogleCloudStorage) Export ¶ added in v0.21.0
func (f *GoogleCloudStorage) Export(ctx context.Context, logger *log.Logger, featureEvents []FeatureEvent) error
Export is saving a collection of events in a file.
func (*GoogleCloudStorage) IsBulk ¶ added in v0.21.0
func (f *GoogleCloudStorage) IsBulk() bool
type Log ¶ added in v0.11.0
type Log struct { // Format is the template configuration of the output format of your log. // You can use all the key from the exporter.FeatureEvent + a key called FormattedDate that represent the date with // the RFC 3339 Format // Default: [{{ .FormattedDate}}] user="{{ .UserKey}}", flag="{{ .Key}}", value="{{ .Value}}" Format string // Deprecated: use LogFormat instead. // Format is the template configuration of the output format of your log. // You can use all the key from the exporter.FeatureEvent + a key called FormattedDate that represent the date with // the RFC 3339 Format // Default: [{{ .FormattedDate}}] user="{{ .UserKey}}", flag="{{ .Key}}", value="{{ .Value}}" LogFormat string // contains filtered or unexported fields }
type S3 ¶ added in v0.12.0
type S3 struct { // Bucket is the name of your S3 Bucket. Bucket string // AwsConfig is the AWS SDK configuration object we will use to // upload your exported data files. AwsConfig *aws.Config // Format is the output format you want in your exported file. // Available format are JSON and CSV. // Default: JSON Format string // S3Path allows you to specify in which directory you want to export your data. S3Path string // Filename is the name of your output file // You can use a templated config to define the name of your export files. // Available replacement are {{ .Hostname}}, {{ .Timestamp}} and {{ .Format}} // Default: "flag-variation-{{ .Hostname}}-{{ .Timestamp}}.{{ .Format}}" Filename string // CsvTemplate is used if your output format is CSV. // This field will be ignored if you are using another format than CSV. // You can decide which fields you want in your CSV line with a go-template syntax, // please check internal/exporter/feature_event.go to see what are the fields available. // Default: // {{ .Kind}};{{ .ContextKind}};{{ .UserKey}};{{ .CreationDate}};{{ .Key}};{{ .Variation}};{{ .Value}};{{ .Default}}\n CsvTemplate string // contains filtered or unexported fields }
type Webhook ¶ added in v0.13.0
type Webhook struct { // EndpointURL of your webhook EndpointURL string // Secret used to sign your request body. Secret string // Meta information that you want to send to your webhook (not mandatory) Meta map[string]string // contains filtered or unexported fields }
Webhook is the exporter of your data to a webhook.
It calls the EndpointURL with a POST request with the following format:
{ "meta": { "hostname": "server01", }, "events": [ { "kind": "feature", "contextKind": "anonymousUser", "userKey": "14613538188334553206", "creationDate": 1618909178, "key": "test-flag", "variation": "Default", "value": false, "default": false }, ] }
Click to show internal directories.
Click to hide internal directories.