config

package
v0.0.0-...-681a524 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigFlag = &cli.StringFlag{
	Name:      configCLIName,
	Usage:     "The path to the configuration file.",
	Value:     "config.yaml",
	Sources:   cli.EnvVars("CONFIG"),
	TakesFile: true,
	OnlyOnce:  true,
	Local:     true,
}

ConfigFlag for CLI to load the configuration file

Functions

func Validate

func Validate(cfg *Config) error

Types

type Config

type Config struct {
	LogLevel LogLevel `yaml:"logLevel,omitempty" json:"logLevel,omitempty"`

	Events EventsConfig `yaml:"events" json:"events"`

	Storage PostgreSQLConfig `yaml:"storage" json:"storage"`
}

func Load

func Load(cmd *cli.Command) (*Config, error)

Load a configuration file from the CLI flags.

func New

func New() *Config

func (*Config) JSONSchema

func (cfg *Config) JSONSchema() *jsonschema.Schema

func (*Config) Schema

func (cfg *Config) Schema() ([]byte, error)

type EventsConfig

type EventsConfig struct {
	// The NATS URL to connect to for consuming/producing messages.
	URL string `yaml:"url" json:"url"`

	// A unique identifier for the instance.
	InstanceID *FromEnv `yaml:"instanceID" json:"instanceID"`
}

type FromEnv

type FromEnv struct {
	Content string `yaml:"-" json:"-" jsonschema:"-"`
}

func (FromEnv) JSONSchema

func (fe FromEnv) JSONSchema() *jsonschema.Schema

func (*FromEnv) UnmarshalYAML

func (fe *FromEnv) UnmarshalYAML(node *yaml.Node) error

type LogLevel

type LogLevel string

func (LogLevel) ToZapcoreLevel

func (ll LogLevel) ToZapcoreLevel() zapcore.Level

func (*LogLevel) UnmarshalYAML

func (ll *LogLevel) UnmarshalYAML(node *yaml.Node) error

type PostgreSQLConfig

type PostgreSQLConfig struct {
	// The PostgreSQL DSN to persist data. Example: postgres://user:secret@localhost:5432/mulval
	DSN string `yaml:"dsn" json:"dsn"`

	// An optional schema to store data into. Example: mulval
	Schema string `yaml:"schema,omitempty" json:"schema,omitempty"`

	// If turned on, run the PostgreSQL migrations before starting.
	Migrate bool `yaml:"migrate,omitempty" json:"migrate,omitempty"`

	// The minimum connections to the PostgreSQL pool.
	// Default to 4.
	MinConns int32 `yaml:"minConns,omitempty" json:"minConns,omitempty" jsonschema:"default=4"`

	// The maximum connections to the PostgreSQL pool.
	// If none set, defaults to minConns.
	MaxConns int32 `yaml:"maxConns,omitempty" json:"maxConns,omitempty"`
}

Jump to

Keyboard shortcuts

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