configuration

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2025 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

View Source
const (
	CurrentDir    = "."
	ConfigDir     = "./config"
	CmdDir        = "../../config/"
	ConfigName    = "config"
	FileExtension = "yaml"
)

Default values and dirs

View Source
const (
	TracingFlag = "tracing"
	MetricsFlag = "metrics"
)
View Source
const (
	EtcdAddress = "etcd.address"
	EtcdPrefix  = "etcd.prefix"

	// Database
	DatabaseType        = "database.type"
	DatabaseAddress     = "database.host"
	DatabasePort        = "database.port"
	DatabaseUsername    = "database.username"
	DatabasePassword    = "database.password"
	DatabaseName        = "database.database"
	DatabaseReplicaSet  = "database.replicaSet"
	DatabaseTLSEnabled  = "database.tls.enabled"
	DatabaseTLSKeyPath  = "database.tls.keyPath"
	DatabaseTLSCertPath = "database.tls.certPath"

	// HTTP server
	ServerAddress     = "http.address"
	ServerPathPrefix  = "http.pathPrefix"
	ServerTLSEnabled  = "http.tls.enabled"
	ServerTLSKeyPath  = "http.tls.keyPath"
	ServerTLSCertPath = "http.tls.certPath"

	// Metrics
	MetricsServerAddress = "observability.metrics.address"
	MetricsEnable        = "observability.metrics.enable"
	MetricsEndpoint      = "observability.metrics.endpoint"

	// Tracing
	TracingEnable      = "observability.tracing.enable"
	TracingAddress     = "observability.tracing.address"
	TracingAuth        = "observability.tracing.auth"
	TracingTLSEnabled  = "observability.tracing.tls.enabled"
	TracingTLSKeyPath  = "observability.tracing.tls.keyPath"
	TracingTLSCertPath = "observability.tracing.tls.certPath"
)

Variables

This section is empty.

Functions

func GetConfiguration

func GetConfiguration(viper *viper.Viper, configStruct interface{})

GetConfiguration loads the configuration from Viper and validates it.

func InitConfig

func InitConfig(configurationFilePath string, additionalDirs ...string)

InitConfig initializes the configuration for the service, either from file or from ETCD (if ETCD was set).

func SetDefaults

func SetDefaults(serviceName string)

SetDefaults sets the default values for the app configuration.

func SetupEnv

func SetupEnv(serviceName string)

SetupEnv sets up the environment variables for the service.

Types

type Database

type Database struct {
	Type       string  `json:"type" yaml:"type" mapstructure:"type" required:""`
	URI        string  `json:"uri,omitempty" yaml:"uri" mapstructure:"uri"`
	Host       string  `json:"host,omitempty" yaml:"host" mapstructure:"host"`
	Username   string  `json:"username,omitempty" yaml:"username" mapstructure:"username"`
	Password   string  `json:"password,omitempty" yaml:"password" mapstructure:"password"`
	Port       int     `json:"port,omitempty" yaml:"port" mapstructure:"port"`
	Database   string  `json:"database,omitempty" yaml:"database" mapstructure:"database"`
	ReplicaSet string  `json:"replicaSet,omitempty" yaml:"replicaSet" mapstructure:"replicaSet"`
	TLS        tls.TLS `json:"tls" yaml:"tls" mapstructure:"tls"`
}

Primary Database configuration

type InfluxDB

type InfluxDB struct {
	URL          string  `yaml:"url" json:"url" mapstructure:"url"`
	Organization string  `yaml:"organization" json:"organization" mapstructure:"organization"`
	Bucket       string  `yaml:"bucket" json:"bucket" mapstructure:"bucket"`
	AccessToken  string  `yaml:"accessToken" json:"accessToken" mapstructure:"accessToken"`
	TLS          tls.TLS `mapstructure:"tls" yaml:"tls" json:"tls"`
}

InfluxDB database configuration with TLS

type Redis

type Redis struct {
	Address  string  `yaml:"address" json:"address" mapstructure:"address"`
	Password string  `yaml:"password" json:"password" mapstructure:"password"`
	TLS      tls.TLS `mapstructure:"tls" yaml:"tls" json:"tls"`
}

Redis database configuration with TLS

Jump to

Keyboard shortcuts

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