config

package
v1.9.11 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2025 License: Unlicense Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEnv

func GetEnv() (requested bool)

func HelpRequested

func HelpRequested() (help bool)

HelpRequested returns true if any of the common types of help invocation are found as the first command line parameter/flag.

func PrintEnv

func PrintEnv(cfg *C, printer io.Writer)

func PrintHelp

func PrintHelp(cfg *C, printer io.Writer)

PrintHelp outputs a help text listing the configuration options and default values to a provided io.Writer (usually os.Stderr or os.Stdout).

Types

type C

type C struct {
	AppName        string   `env:"REALY_APP_NAME" default:"realy"`
	Config         string   `` /* 176-byte string literal not displayed */
	State          string   `env:"REALY_STATE_DATA_DIR" usage:"storage location for state data affected by dynamic interactive interfaces"`
	DataDir        string   `env:"REALY_DATA_DIR" usage:"storage location for the ratel event store"`
	Listen         string   `env:"REALY_LISTEN" default:"0.0.0.0" usage:"network listen address"`
	Port           int      `env:"REALY_PORT" default:"3334" usage:"port to listen on"`
	AdminNpubs     string   `` /* 143-byte string literal not displayed */
	LogLevel       string   `env:"REALY_LOG_LEVEL" default:"info" usage:"debug level: fatal error warn info debug trace"`
	DbLogLevel     string   `env:"REALY_DB_LOG_LEVEL" default:"info" usage:"debug level: fatal error warn info debug trace"`
	AuthRequired   bool     `env:"REALY_AUTH_REQUIRED" default:"false" usage:"requires auth for all access"`
	PublicReadable bool     `` /* 128-byte string literal not displayed */
	Owners         []string `` /* 271-byte string literal not displayed */
	DBSizeLimit    int      `` /* 155-byte string literal not displayed */
	DBLowWater     int      `env:"REALY_DB_LOW_WATER" default:"60" usage:"the percentage of DBSizeLimit a GC run will reduce the used storage down to"`
	DBHighWater    int      `env:"REALY_DB_HIGH_WATER" default:"80" usage:"the trigger point at which a GC run should start if exceeded"`
	GCFrequency    int      `env:"REALY_GC_FREQUENCY" default:"3600" usage:"the frequency of checks of the current utilisation in minutes"`
	Pprof          bool     `env:"REALY_PPROF" default:"false" usage:"enable pprof on 127.0.0.1:6060"`
	MemLimit       int      `env:"REALY_MEMLIMIT" default:"250000000" usage:"set memory limit, default is 250Mb"`
	UseCompact     bool     `env:"REALY_USE_COMPACT" default:"false" usage:"use the compact database encoding for the ratel event store"`
	Compression    string   `env:"REALY_COMPRESSION" default:"none" usage:"compress the database, [none|snappy|zstd]"`
}

func New

func New() (cfg *C, err error)

type KV

type KV struct{ Key, Value string }

type KVSlice

type KVSlice []KV

func EnvKV

func EnvKV(cfg any) (m KVSlice)

EnvKV turns a struct with `env` keys (used with go-simpler/env) into a standard formatted environment variable key/value pair list, one per line. Note you must dereference a pointer type to use this. This allows the composition of the config in this file with an extended form with a customized variant of realy to produce correct environment variables both read and write.

func (KVSlice) Composit

func (kv KVSlice) Composit(kv2 KVSlice) (out KVSlice)

Composit merges two KVSlice together, replacing the values of earlier keys with same named KV items later in the slice (enabling compositing two together as a .env, as well as them being composed as structs.

func (KVSlice) Len

func (kv KVSlice) Len() int

func (KVSlice) Less

func (kv KVSlice) Less(i, j int) bool

func (KVSlice) Swap

func (kv KVSlice) Swap(i, j int)

Jump to

Keyboard shortcuts

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