config

package
v0.0.0-...-84339fa Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 6 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	// This corresponds to the name and version of the router deployed from the Turing app and
	// will be logged as RouterVersion in TuringResultLog.proto
	// Format: {router_name}-{router_version}.{project_name}
	Name          string       `required:"true"`
	Environment   string       `required:"true"`
	LogLevel      LogLevel     `split_words:"false" default:"INFO"`
	CustomMetrics bool         `split_words:"true" default:"false"`
	FiberDebugLog bool         `split_words:"true" default:"false"`
	ResultLogger  ResultLogger `split_words:"true" default:"NOP"`
	BigQuery      *BQConfig    `envconfig:"BQ"`
	Fluentd       *FluentdConfig
	Kafka         *KafkaConfig
	Jaeger        *JaegerConfig
	Sentry        sentry.Config
}

AppConfig is the structure used to the parse the environment configs that correspond to application behavior such as logging, instrumentation, etc.

type BQConfig

type BQConfig struct {
	Project   string `envconfig:"APP_GCP_PROJECT"`
	Dataset   string
	Table     string
	BatchLoad bool `split_words:"true" default:"false"`
}

BQConfig is used to parse the APP config env vars that hold the BQ connection information. These env vars are optional, i.e., only required to be set for ResultLogger type BigqueryLogger. If they are not set for BQLogger type, init will fail. If BatchLoad is true, the Fluentd config is also expected to be set.

type Config

type Config struct {
	Port int `envconfig:"PORT" required:"true"`

	EnrichmentConfig *EnrichmentConfig `envconfig:"ENRICHER"`
	RouterConfig     *RouterConfig     `envconfig:"ROUTER"`
	EnsemblerConfig  *EnsemblerConfig  `envconfig:"ENSEMBLER"`

	AppConfig *AppConfig `envconfig:"APP"`
}

Config is the structure used to parse the environment configs

func InitConfigEnv

func InitConfigEnv() (*Config, error)

InitConfigEnv initialises configuration from the environment.

func (*Config) ListenAddress

func (c *Config) ListenAddress() string

ListenAddress retrieves the Mission Control's configured port

func (*Config) RouterConfigFile

func (c *Config) RouterConfigFile() string

RouterConfigFile retrieves the router's config file path

type EnrichmentConfig

type EnrichmentConfig struct {
	Endpoint string
	Timeout  time.Duration `default:"15ms"`
}

EnrichmentConfig is the structure used to parse the Enricher's environment configs

type EnsemblerConfig

type EnsemblerConfig struct {
	Endpoint string
	Timeout  time.Duration `default:"10ms"`
}

EnsemblerConfig is the structure used to parse the Ensembler's environment configs

type FluentdConfig

type FluentdConfig struct {
	Host string
	Port int
	Tag  string
}

FluentdConfig is used to parse the APP config env var(s) that hold the Fluentd backend information

type JaegerConfig

type JaegerConfig struct {
	Enabled           bool
	CollectorEndpoint string `split_words:"true"`
	ReporterAgentHost string `envconfig:"REPORTER_HOST" split_words:"true"`
	ReporterAgentPort int    `envconfig:"REPORTER_PORT" split_words:"true"`
}

JaegerConfig captures the settings for tracing using Jaeger client Ref: https://pkg.go.dev/github.com/uber/jaeger-client-go/config

type KafkaConfig

type KafkaConfig struct {
	Brokers             string
	Topic               string
	SerializationFormat SerializationFormat `split_words:"true"`
	MaxMessageBytes     int                 `split_words:"true" default:"1048588"`
	CompressionType     string              `split_words:"true" default:"none"`
}

KafkaConfig captures the minimal configuration for writing result logs to Kafka topics

type LogLevel

type LogLevel string

LogLevel type is used to capture the supported logging levels

const (
	// DebugLevel is used for verbose logs at debug level
	DebugLevel LogLevel = "DEBUG"
	// InfoLevel is used for logs that are info level and higher
	InfoLevel LogLevel = "INFO"
	// WarnLevel is used for logs that are warning level and higher
	WarnLevel LogLevel = "WARN"
	// ErrorLevel is used for logs that are error level and higher
	ErrorLevel LogLevel = "ERROR"
)

func (*LogLevel) Decode

func (logLvl *LogLevel) Decode(value string) error

Decode parses the LogLevel config defined and validates if it is one of the supported values.

type Protocol

type Protocol string

Protocol is used for router config to indicate spinning up of respective router mission control

const (
	UPI  Protocol = "UPI_V1"
	HTTP Protocol = "HTTP_JSON"
)

type ResultLogger

type ResultLogger string

ResultLogger is the type used to capture the supported response logging destinations

const (
	// BigqueryLogger logs the responses to BigQuery
	BigqueryLogger ResultLogger = "BIGQUERY"
	// ConsoleLogger logs the responses to console
	ConsoleLogger ResultLogger = "CONSOLE"
	// KafkaLogger logs the response to a Kafka topic
	KafkaLogger ResultLogger = "KAFKA"
	// UPILogger logs the response to a Kafka topic with UPI proto
	UPILogger ResultLogger = "UPI"
	// NopLogger disables response logging
	NopLogger ResultLogger = "NOP"
)

func (*ResultLogger) Decode

func (resLogger *ResultLogger) Decode(value string) error

Decode parses the ResultLogger config defined and validates if it is one of the supported values.

type RouterConfig

type RouterConfig struct {
	ConfigFile string        `split_words:"true" required:"true"`
	Timeout    time.Duration `default:"20ms"`
	Protocol   Protocol      `default:"HTTP_JSON"`
}

RouterConfig is the structure used to parse the Router's environment configs

type SerializationFormat

type SerializationFormat string

SerializationFormat represents the message serialization format to be used by the ResultLogger

const (
	// JSONSerializationFormat formats the message as json, for logging
	JSONSerializationFormat SerializationFormat = "json"
	// ProtobufSerializationFormat formats the message using protobuf, for logging
	ProtobufSerializationFormat SerializationFormat = "protobuf"
)

func (*SerializationFormat) Decode

func (serialization *SerializationFormat) Decode(value string) error

Decode parses the SerializationFormat config and validates if it is one of the supported values.

Jump to

Keyboard shortcuts

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