config

package
v0.0.0-...-72205f7 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AppName app name
	AppName = "url-shortener"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {

	// ServiceName logging service name
	ServiceName string `toml:"service_name" validate:"required"`
	// Environment development, staging, production
	Environment string `toml:"environment" validate:"required"`
	// HTTPAddr internal server http address
	HTTPAddr string `toml:"http_addr" validate:"required"`
	// LogLevel ...
	LogLevel string `toml:"log_level" validate:"required"`
	// EnableApplicationProfiler ...
	EnableApplicationProfiler bool `toml:"enable_application_profiler"`
	// Coordination ...
	Coordination Coordination `toml:"coordination" validate:"required,dive"`
	// MySqlDB application DB config
	AppDB MySqlDB `toml:"app_db" validate:"required,dive"`
	// contains filtered or unexported fields
}

Config is app config

func Load

func Load(commitHash string, tag string) (*Config, error)

Load reads the config file path from environment variable and calls LoadFromPath

func LoadFromPath

func LoadFromPath(configFilePath, commitHash, tag string) (*Config, error)

LoadFromPath loads configurations commitHash is a git commit hash of this app build tag is a git tag of this app build

func (*Config) CommitHash

func (c *Config) CommitHash() string

CommitHash returns git commit hash of this app build

func (*Config) GetUserAgent

func (c *Config) GetUserAgent() string

GetUserAgent creates user-agent string for remote calls

func (*Config) Tag

func (c *Config) Tag() string

Tag returns git tag of this app build

type Coordination

type Coordination struct {
	// NodeID represents the unique identifier for the application, which must maintain its uniqueness within the cluster.
	NodeID string `toml:"node_id" validation:"required"`
	// RangeSize range size to be reserved in each request
	RangeSize int `toml:"range_size" validation:"required"`
	// DataStore MySql datastore that is being used for coordination purposes
	DataStore MySqlDB `toml:"datastore" validate:"required,dive"`
}

type DBCredential

type DBCredential struct {
	// Host ...
	Host string `toml:"host" validate:"required"`
	// DBName ...
	DBName string `toml:"db_name" validate:"required"`
	// Username ...
	Username string `toml:"username" validate:"required"`
	// Password ...
	Password string `toml:"password" validate:"required"`
}

DBCredential database credential

type MySqlDB

type MySqlDB struct {
	// Credentials ...
	Credential DBCredential `toml:"credential" validate:"required"`

	// Toml config constraint https://github.com/toml-lang/toml/issues/514
	// ReadTimeoutSec ...
	ReadTimeoutSec int `toml:"read_timeout_sec" validate:"required"`
	// WriteTimeoutSec ...
	WriteTimeoutSec int `toml:"write_timeout_sec" validate:"required"`
	// MaxOpenConn ...
	MaxOpenConn int `toml:"max_open_conn" validate:"required"`
	// ConnLifetimeSec ...
	ConnLifetimeSec int `toml:"connection_lifetime_sec" validate:"required"`
}

MySqlDB contains mysql db configs

Jump to

Keyboard shortcuts

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