Skip to content

File Exporter

The file exporter will collect the data and create a new file in a specific folder everytime we send the data.
This file should be in the local instance.

Check this complete example to see how to export the data in a file.

Configuration example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
ffclient.Config{ 
    // ...
   DataExporter: ffclient.DataExporter{
        // ...
        Exporter: &fileexporter.Exporter{
            OutputDir: "/output-data/",
            Format: "csv",
            FileName: "flag-variation-{{ .Hostname}}-{{ .Timestamp}}.{{ .Format}}",
            CsvTemplate: "{{ .Kind}};{{ .ContextKind}};{{ .UserKey}};{{ .CreationDate}};{{ .Key}};{{ .Variation}};{{ .Value}};{{ .Default}}\n"
        },
    },
    // ...
}

Configuration fields

Field Description
OutputDir OutputDir is the location of the directory where to store the exported files.
It should finish with a /.
Format (Optional) Format is the output format you want in your exported file.
Available format: JSON, CSV.
Default: JSON
Filename (Optional) Filename is the name of your output file.
You can use a templated config to define the name of your exported files.
Available replacement are {{ .Hostname}}, {{ .Timestamp}} and {{ .Format}}
Default: flag-variation-{{ .Hostname}}-{{ .Timestamp}}.{{ .Format}}
CsvTemplate (Optional) 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

Check the godoc for full details.