config

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package config provides shared configuration types and Viper helpers used by both the AppView and Hold services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindLogShipper

func BindLogShipper(v *viper.Viper)

BindLogShipper registers BindEnv calls for shared (unprefixed) log shipper env vars.

func MarshalCommentedYAML

func MarshalCommentedYAML(title string, cfg any) ([]byte, error)

MarshalCommentedYAML serializes cfg into a YAML document with comments derived from `comment` struct tags. The title becomes the document head comment. Fields with `yaml:"-"` are excluded. Nested structs become YAML mapping nodes. time.Duration values render as their string representation (e.g. "15m0s").

func NewViper

func NewViper(prefix string, yamlPath string) *viper.Viper

NewViper creates a configured Viper instance with common settings. prefix is the env var prefix (e.g., "ATCR" or "HOLD"). yamlPath is the optional YAML config file path (empty = env-only).

func StringToTimeDurationHook

func StringToTimeDurationHook() mapstructure.DecodeHookFunc

StringToTimeDurationHook returns a mapstructure DecodeHookFunc that converts string values to time.Duration. This handles env vars like "15m" or "5s".

func UnmarshalOption

func UnmarshalOption() viper.DecoderConfigOption

UnmarshalOption returns the Viper decoder option that uses yaml struct tags and supports time.Duration string parsing.

Types

type LogShipperConfig

type LogShipperConfig struct {
	// Log shipping backend. Empty disables shipping.
	Backend string `yaml:"backend" comment:"Log shipping backend: \"victoria\", \"opensearch\", or \"loki\". Empty disables shipping."`

	// Remote log service endpoint.
	URL string `yaml:"url" comment:"Remote log service endpoint, e.g. \"http://victorialogs:9428\"."`

	// Number of log entries to buffer before flushing.
	BatchSize int `yaml:"batch_size" comment:"Number of log entries to buffer before flushing to the remote service."`

	// Maximum time between flushes, even if batch is not full.
	FlushInterval time.Duration `yaml:"flush_interval" comment:"Maximum time between flushes, even if batch is not full."`

	// Basic auth username for the log service (optional).
	Username string `yaml:"username" comment:"Basic auth username for the log service (optional)."`

	// Basic auth password for the log service (optional).
	Password string `yaml:"password" comment:"Basic auth password for the log service (optional)."`
}

LogShipperConfig defines remote log shipping settings. Shared by both AppView and Hold services.

Jump to

Keyboard shortcuts

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