Documentation ¶
Index ¶
Constants ¶
View Source
const DefaultLogLevel = "info"
View Source
const OtelTracerName = "go-feature-flag"
Variables ¶
View Source
var DefaultExporter = struct { Format string LogFormat string FileName string CsvFormat string FlushInterval time.Duration MaxEventInMemory int64 ParquetCompressionCodec string LogLevel string }{ Format: "JSON", LogFormat: "[{{ .FormattedDate}}] user=\"{{ .UserKey}}\", flag=\"{{ .Key}}\", value=\"{{ .Value}}\"", FileName: "flag-variation-{{ .Hostname}}-{{ .Timestamp}}.{{ .Format}}", CsvFormat: "{{ .Kind}};{{ .ContextKind}};{{ .UserKey}};{{ .CreationDate}};{{ .Key}};{{ .Variation}};" + "{{ .Value}};{{ .Default}};{{ .Source}}\n", FlushInterval: 60000 * time.Millisecond, MaxEventInMemory: 100000, ParquetCompressionCodec: parquet.CompressionCodec_SNAPPY.String(), LogLevel: DefaultLogLevel, }
Functions ¶
This section is empty.
Types ¶
type APIKeys ¶ added in v1.28.0
type APIKeys struct { Admin []string `mapstructure:"admin" koanf:"admin"` Evaluation []string `mapstructure:"evaluation" koanf:"evaluation"` }
APIKeys is a struct to store the API keys for the different endpoints
type Config ¶
type Config struct { // ListenPort (optional) is the port we are using to start the proxy ListenPort int `mapstructure:"listen" koanf:"listen"` // HideBanner (optional) if true, we don't display the go-feature-flag relay proxy banner HideBanner bool `mapstructure:"hideBanner" koanf:"hidebanner"` // Debug (optional) if true, go-feature-flag relay proxy will run on debug mode, with more logs and custom responses Debug bool `mapstructure:"debug" koanf:"debug"` // EnableSwagger (optional) to have access to the swagger EnableSwagger bool `mapstructure:"enableSwagger" koanf:"enableswagger"` // Host should be set if you are using swagger (default is localhost) Host string `mapstructure:"host" koanf:"host"` // LogLevel (optional) sets the verbosity for logging, // Possible values: debug, info, warn, error, dpanic, panic, fatal // If level debug go-feature-flag relay proxy will run on debug mode, with more logs and custom responses // Default: debug LogLevel string `mapstructure:"logLevel" koanf:"loglevel"` // PollingInterval (optional) Poll every X time // The minimum possible is 1 second // Default: 60 seconds PollingInterval int `mapstructure:"pollingInterval" koanf:"pollinginterval"` // EnablePollingJitter (optional) set to true if you want to avoid having true periodicity when // retrieving your flags. It is useful to avoid having spike on your flag configuration storage // in case your application is starting multiple instance at the same time. // We ensure a deviation that is maximum + or - 10% of your polling interval. // Default: false EnablePollingJitter bool `mapstructure:"enablePollingJitter" koanf:"enablepollingjitter"` // FileFormat (optional) is the format of the file to retrieve (available YAML, TOML and JSON) // Default: YAML FileFormat string `mapstructure:"fileFormat" koanf:"fileformat"` // StartWithRetrieverError (optional) If true, the relay proxy will start even if we did not get any flags from // the retriever. It will serve only default values until the retriever returns the flags. // The init method will not return any error if the flag file is unreachable. // Default: false StartWithRetrieverError bool `mapstructure:"startWithRetrieverError" koanf:"startwithretrievererror"` // Retriever is the configuration on how to retrieve the file Retriever *RetrieverConf `mapstructure:"retriever" koanf:"retriever"` // Retrievers is the exact same things than Retriever but allows to give more than 1 retriever at the time. // We are dealing with config files in order, if you have the same flag name in multiple files it will be override // based of the order of the retrievers in the slice. // // Note: If both Retriever and Retrievers are set, we will start by calling the Retriever and, // after we will use the order of Retrievers. Retrievers *[]RetrieverConf `mapstructure:"retrievers" koanf:"retrievers"` // Exporter is the configuration on how to export data Exporter *ExporterConf `mapstructure:"exporter" koanf:"exporter"` // Notifiers is the configuration on where to notify a flag change Notifiers []NotifierConf `mapstructure:"notifier" koanf:"notifier"` // RestAPITimeout is the timeout on the API. RestAPITimeout int `mapstructure:"restApiTimeout" koanf:"restapitimeout"` // Version is the version of the relay-proxy Version string `mapstructure:"version" koanf:"version"` // Deprecated: use AuthorizedKeys instead // APIKeys list of API keys that authorized to use endpoints APIKeys []string `mapstructure:"apiKeys" koanf:"apikeys"` // AuthorizedKeys list of API keys that authorized to use endpoints AuthorizedKeys APIKeys `mapstructure:"authorizedKeys" koanf:"authorizedkeys"` // StartAsAwsLambda (optional) if true, the relay proxy will start ready to be launched as AWS Lambda StartAsAwsLambda bool `mapstructure:"startAsAwsLambda" koanf:"startasawslambda"` // EvaluationContextEnrichment (optional) will be merged with the evaluation context sent during the evaluation. // It is useful to add common attributes to all the evaluations, such as a server version, environment, ... // // All those fields will be included in the custom attributes of the evaluation context, // if in the evaluation context you have a field with the same name, // it will be overridden by the evaluationContextEnrichment. // Default: nil EvaluationContextEnrichment map[string]interface{} `mapstructure:"evaluationContextEnrichment" koanf:"evaluationcontextenrichment"` //nolint: lll // OpenTelemetryOtlpEndpoint (optional) is the endpoint of the OpenTelemetry collector // Default: "" OpenTelemetryOtlpEndpoint string `mapstructure:"openTelemetryOtlpEndpoint" koanf:"opentelemetryotlpendpoint"` // MonitoringPort (optional) is the port we are using to expose the metrics and healthchecks // If not set we will use the same port as the proxy MonitoringPort int `mapstructure:"monitoringPort" koanf:"monitoringport"` // PersistentFlagConfigurationFile (optional) if set GO Feature Flag will store flags configuration in this file // to be able to serve the flags even if none of the retrievers is available during starting time. // // By default, the flag configuration is not persisted and stays on the retriever system. By setting a file here, // you ensure that GO Feature Flag will always start with a configuration but which can be out-dated. PersistentFlagConfigurationFile string `mapstructure:"persistentFlagConfigurationFile" koanf:"persistentflagconfigurationfile"` //nolint: lll // contains filtered or unexported fields }
func (*Config) APIKeyExists ¶ added in v1.7.0
APIKeyExists is checking if an API Key exist in the relay proxy configuration
func (*Config) APIKeysAdminExists ¶ added in v1.28.0
APIKeysAdminExists is checking if an admin API Key exist in the relay proxy configuration
func (*Config) IsDebugEnabled ¶ added in v1.30.0
func (*Config) ZapLogLevel ¶ added in v1.30.0
type ExporterConf ¶
type ExporterConf struct { Kind ExporterKind `mapstructure:"kind" koanf:"kind"` OutputDir string `mapstructure:"outputDir" koanf:"outputdir"` Format string `mapstructure:"format" koanf:"format"` Filename string `mapstructure:"filename" koanf:"filename"` CsvTemplate string `mapstructure:"csvTemplate" koanf:"csvtemplate"` Bucket string `mapstructure:"bucket" koanf:"bucket"` Path string `mapstructure:"path" koanf:"path"` EndpointURL string `mapstructure:"endpointUrl" koanf:"endpointurl"` Secret string `mapstructure:"secret" koanf:"secret"` Meta map[string]string `mapstructure:"meta" koanf:"meta"` LogFormat string `mapstructure:"logFormat" koanf:"logformat"` FlushInterval int64 `mapstructure:"flushInterval" koanf:"flushinterval"` MaxEventInMemory int64 `mapstructure:"maxEventInMemory" koanf:"maxeventinmemory"` ParquetCompressionCodec string `mapstructure:"parquetCompressionCodec" koanf:"parquetcompressioncodec"` Headers map[string][]string `mapstructure:"headers" koanf:"headers"` QueueURL string `mapstructure:"queueUrl" koanf:"queueurl"` Kafka kafkaexporter.Settings `mapstructure:"kafka" koanf:"kafka"` ProjectID string `mapstructure:"projectID" koanf:"projectid"` Topic string `mapstructure:"topic" koanf:"topic"` }
ExporterConf contains all the field to configure an exporter
func (*ExporterConf) IsValid ¶
func (c *ExporterConf) IsValid() error
type ExporterKind ¶
type ExporterKind string
const ( FileExporter ExporterKind = "file" WebhookExporter ExporterKind = "webhook" LogExporter ExporterKind = "log" S3Exporter ExporterKind = "s3" GoogleStorageExporter ExporterKind = "googleStorage" SQSExporter ExporterKind = "sqs" KafkaExporter ExporterKind = "kafka" PubSubExporter ExporterKind = "pubsub" )
func (ExporterKind) IsValid ¶
func (r ExporterKind) IsValid() error
IsValid is checking if the value is part of the enum
type NotifierConf ¶
type NotifierConf struct { Kind NotifierKind `mapstructure:"kind" koanf:"kind"` SlackWebhookURL string `mapstructure:"slackWebhookUrl" koanf:"slackWebhookUrl"` EndpointURL string `mapstructure:"endpointUrl" koanf:"endpointUrl"` Secret string `mapstructure:"secret" koanf:"secret"` Meta map[string]string `mapstructure:"meta" koanf:"meta"` Headers map[string][]string `mapstructure:"headers" koanf:"headers"` }
func (*NotifierConf) IsValid ¶
func (c *NotifierConf) IsValid() error
type NotifierKind ¶
type NotifierKind string
const ( SlackNotifier NotifierKind = "slack" WebhookNotifier NotifierKind = "webhook" )
func (NotifierKind) IsValid ¶
func (r NotifierKind) IsValid() error
IsValid is checking if the value is part of the enum
type RetrieverConf ¶
type RetrieverConf struct { Kind RetrieverKind `mapstructure:"kind" koanf:"kind"` RepositorySlug string `mapstructure:"repositorySlug" koanf:"repositoryslug"` Branch string `mapstructure:"branch" koanf:"branch"` Path string `mapstructure:"path" koanf:"path"` // Deprecated: Please use AuthToken instead GithubToken string `mapstructure:"githubToken" koanf:"githubtoken"` URL string `mapstructure:"url" koanf:"url"` Timeout int64 `mapstructure:"timeout" koanf:"timeout"` HTTPMethod string `mapstructure:"method" koanf:"method"` HTTPBody string `mapstructure:"body" koanf:"body"` HTTPHeaders map[string][]string `mapstructure:"headers" koanf:"headers"` Bucket string `mapstructure:"bucket" koanf:"bucket"` Object string `mapstructure:"object" koanf:"object"` Item string `mapstructure:"item" koanf:"item"` Namespace string `mapstructure:"namespace" koanf:"namespace"` ConfigMap string `mapstructure:"configmap" koanf:"configmap"` Key string `mapstructure:"key" koanf:"key"` BaseURL string `mapstructure:"baseUrl" koanf:"baseurl"` AuthToken string `mapstructure:"token" koanf:"token"` URI string `mapstructure:"uri" koanf:"uri"` Database string `mapstructure:"database" koanf:"database"` Collection string `mapstructure:"collection" koanf:"collection"` RedisOptions *redis.Options `mapstructure:"redisOptions" koanf:"redisOptions"` RedisPrefix string `mapstructure:"redisPrefix" koanf:"redisPrefix"` }
RetrieverConf contains all the field to configure a retriever
func (*RetrieverConf) IsValid ¶
func (c *RetrieverConf) IsValid() error
IsValid validate the configuration of the retriever nolint:gocognit
type RetrieverKind ¶
type RetrieverKind string
RetrieverKind is an enum containing all accepted Retriever kind
const ( HTTPRetriever RetrieverKind = "http" GitHubRetriever RetrieverKind = "github" GitlabRetriever RetrieverKind = "gitlab" S3Retriever RetrieverKind = "s3" FileRetriever RetrieverKind = "file" GoogleStorageRetriever RetrieverKind = "googleStorage" KubernetesRetriever RetrieverKind = "configmap" MongoDBRetriever RetrieverKind = "mongodb" RedisRetriever RetrieverKind = "redis" )
func (RetrieverKind) IsValid ¶
func (r RetrieverKind) IsValid() error
IsValid is checking if the value is part of the enum
Click to show internal directories.
Click to hide internal directories.