config

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogLevelTrace = LogLevel(slog.LevelDebug - 4) // TRACE
	LogLevelDebug = LogLevel(slog.LevelDebug)     // DEBUG
	LogLevelInfo  = LogLevel(slog.LevelInfo)      // INFO
	LogLevelWarn  = LogLevel(slog.LevelWarn)      // WARN
	LogLevelError = LogLevel(slog.LevelError)     // ERROR
)

Variables

View Source
var Module = fx.Options(
	fx.Provide(fx.Annotate(NewConfig, fx.ParamTags("", `optional:"true"`))),
	fx.Provide(GetRootConfig),
)

Module exports dependency

View Source
var TraceAsSlogStr = slog.Level(LogLevelTrace).String()

TraceAsSlogStr is the string representation of the TRACE log level within the slog package: "DEBUG-4"

Functions

func LoadConfig

func LoadConfig[T any](root RootConfig, dst *T, secretsMgr SecretsManager)

Types

type CORS

type CORS struct {
	cors.Config
}

func (CORS) MarshalJSON

func (c CORS) MarshalJSON() ([]byte, error)

type Config

type Config struct {
	RootConfig

	Database DatabaseConfig

	Redis RedisConfig

	HttpServer HttpServerConfig

	JWT JWTConfig

	Slack SlackConfig
}

func NewConfig

func NewConfig(root RootConfig, secretsMgr SecretsManager) Config

type DataDogConfig

type DataDogConfig struct {
	Profiling bool
	Tracing   bool
	Agent     string
}

type DatabaseConfig

type DatabaseConfig struct {
	Host string
	Port int
	User string
	Pass string
}

type EnvConfig

type EnvConfig struct {
	Name string
	Type EnvType
	Host Host
}

type EnvType

type EnvType string
const EnvTypeLocal EnvType = "local"
const EnvTypeProd EnvType = "prod"
const EnvTypeSandbox EnvType = "sandbox"
const EnvTypeTest EnvType = "test"

type Host

type Host string

func (*Host) MarshalText

func (h *Host) MarshalText() ([]byte, error)

func (*Host) UnmarshalText

func (h *Host) UnmarshalText(text []byte) error

type HttpServerConfig

type HttpServerConfig struct {
	BindAddress       string
	Port              int
	ReqLoggerExcludes []string
	BasePath          string
	CORS              CORS
}

type JWTConfig

type JWTConfig struct {
	SigningKey string
}

type LogConfig

type LogConfig struct {
	Level  LogLevel
	Levels map[string]LogLevel
	Writer LogConfigWriter
}

type LogConfigWriter

type LogConfigWriter string
const (
	LogConfigWriterStdout LogConfigWriter = "stdout"
	LogConfigWriterStderr LogConfigWriter = "stderr"
	LogConfigWriterBuffer LogConfigWriter = "buffer"
)

func (LogConfigWriter) MarshalText

func (w LogConfigWriter) MarshalText() ([]byte, error)

MarshalText returns the string representation of a logger writer

func (*LogConfigWriter) UnmarshalText

func (w *LogConfigWriter) UnmarshalText(text []byte) error

UnmarshalText parses a logger writer from a string

type LogLevel

type LogLevel slog.Level

func (LogLevel) MarshalText

func (l LogLevel) MarshalText() ([]byte, error)

MarshalText returns the string representation of a log level

func (LogLevel) String

func (i LogLevel) String() string

func (*LogLevel) UnmarshalText

func (l *LogLevel) UnmarshalText(text []byte) error

UnmarshalText parses a log level from a string

type PanicSecretsManager

type PanicSecretsManager struct {
}

func (PanicSecretsManager) GetSecret

func (w PanicSecretsManager) GetSecret(_ context.Context, name string) (string, error)

func (PanicSecretsManager) GetSecretVerbatim

func (w PanicSecretsManager) GetSecretVerbatim(_ context.Context, id string) (string, error)

type RedisConfig

type RedisConfig struct {
	URL string
}

type RootConfig

type RootConfig struct {
	Name    string
	Secrets SecretsConfig
	Env     EnvConfig
	Log     LogConfig
	Datadog DataDogConfig
}

func GetRootConfig added in v0.5.0

func GetRootConfig() RootConfig

type SecretsConfig

type SecretsConfig struct {
	PrefixFmt string
	KeyFmt    string
}

type SecretsManager

type SecretsManager interface {
	GetSecret(ctx context.Context, key string) (string, error)
	GetSecretVerbatim(ctx context.Context, id string) (string, error)
}

SecretsManager is a minimal interface needed to process config secrets

type SlackConfig

type SlackConfig struct {
	Enabled            bool
	HTTPTimeoutSeconds int
	WebhookURLs        struct {
		Info  string
		Warn  string
		Error string
	}
}

type TLSConfig

type TLSConfig struct {
	CertFolder   string
	CACertBase64 string
	CAKeyBase64  string
}

Jump to

Keyboard shortcuts

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