config

package
v0.46.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DefaultInputPlugin  = "chainsync"
	DefaultOutputPlugin = "log"
)

Variables

This section is empty.

Functions

func SaveAtomic added in v0.40.0

func SaveAtomic(path string, data any) error

SaveAtomic encodes data as YAML and writes it durably to path via a unique temporary file + rename.

Reliability guarantees:

  • Encoder is explicitly Closed so all buffered bytes are flushed before f.Close.
  • syncFull (fsync on Linux/Windows, F_FULLFSYNC on macOS) runs before f.Close so data blocks are durable on physical storage prior to rename. Plain fsync on macOS does NOT provide this; see fsync_darwin.go.
  • The parent directory is fsynced after rename so the rename is durable across a crash. Skipped on Windows where directory fsync semantics differ; on filesystems that return ENOTSUP for directory fsync (tmpfs, certain FUSE/SMB configurations) this step is a no-op and the rename's durability is filesystem- dependent.
  • The temporary file name is generated by os.CreateTemp (O_EXCL + random suffix), so concurrent callers cannot truncate each other's in-flight tmp file.
  • Calls to SaveAtomic with the same destination path are serialized by a per-path sync.Mutex; concurrent calls do not race the rename and no write is silently lost. (Different paths do not contend; symlinks to the same inode are not coalesced.)

SaveAtomic does not accept a context and will block for as long as the underlying syscalls take (potentially forever on a stalled disk). Callers that need cancellation responsiveness must wrap SaveAtomic externally; an in-package SaveAtomicCtx wrapper was considered and rejected because the leaked goroutine could out-of-order-clobber a subsequent successful save.

Types

type ApiConfig

type ApiConfig struct {
	ListenAddress string          `yaml:"address" envconfig:"API_ADDRESS"`
	ListenPort    uint            `yaml:"port"    envconfig:"API_PORT"`
	Events        ApiEventsConfig `yaml:"events"  envconfig:"API_EVENTS"`
}

type ApiEventsConfig added in v0.38.0

type ApiEventsConfig struct {
	BufferSize uint `yaml:"buffer-size" envconfig:"API_EVENTS_BUFFER_SIZE"`
}

type ByronGenesisConfig added in v0.34.0

type ByronGenesisConfig struct {
	EndSlot            *uint64 `yaml:"end_slot"              envconfig:"BYRON_GENESIS_END_SLOT"`
	EpochLength        uint64  `yaml:"epoch_length"          envconfig:"BYRON_GENESIS_EPOCH_LENGTH"`
	ByronSlotsPerEpoch uint64  `yaml:"byron_slots_per_epoch" envconfig:"BYRON_GENESIS_BYRON_SLOTS_PER_EPOCH"`
}

ByronGenesisConfig holds Byron era genesis parameters

type Config

type Config struct {
	ByronGenesis      ByronGenesisConfig                   `yaml:"byron_genesis"       envconfig:"BYRON_GENESIS"`
	Plugin            map[string]map[string]map[string]any `yaml:"plugins"                                             ignored:"true"`
	ConfigFile        string                               `yaml:"-"                                                   ignored:"true"`
	Input             string                               `yaml:"input"               envconfig:"INPUT"`
	Output            string                               `yaml:"output"              envconfig:"OUTPUT"`
	KupoUrl           string                               `yaml:"kupo_url"            envconfig:"KUPO_URL"`
	Api               ApiConfig                            `yaml:"api"                 envconfig:"API"`
	Debug             DebugConfig                          `yaml:"debug"               envconfig:"DEBUG"`
	ShelleyGenesis    ShelleyGenesisConfig                 `yaml:"shelley_genesis"     envconfig:"SHELLEY_GENESIS"`
	ShelleyTransEpoch int32                                `yaml:"shelley_trans_epoch" envconfig:"SHELLEY_TRANS_EPOCH"`
	Version           bool                                 `yaml:"-"                                                   ignored:"true"`
}

func GetConfig

func GetConfig() *Config

GetConfig returns the global config instance

func New added in v0.46.0

func New() *Config

New returns independent application defaults.

func (*Config) BindFlags added in v0.35.0

func (c *Config) BindFlags(fs *pflag.FlagSet) error

BindFlags registers independent CLI storage initialized from standard defaults.

func (*Config) Load

func (c *Config) Load(configFile string) error

Load replaces c with freshly resolved defaults, YAML, and environment values. A failed load leaves c unchanged. Load is not concurrent with readers of c.

func (*Config) LoadWithFlags added in v0.42.0

func (c *Config) LoadWithFlags(configFile string, fs *pflag.FlagSet) error

LoadWithFlags applies defaults < YAML < environment < explicit CLI flags. Flag storage is independent of c, so the same FlagSet can be reused on reload.

func (*Config) ResolvePlugins added in v0.46.0

func (c *Config) ResolvePlugins(
	fs *pflag.FlagSet,
) (*plugin.Configuration, error)

ResolvePlugins snapshots plugin configuration. The top-level Kupo URL supplies a fallback only when an input's YAML does not explicitly provide kupo-url.

type DebugConfig

type DebugConfig struct {
	ListenAddress string `yaml:"address" envconfig:"DEBUG_ADDRESS"`
	ListenPort    uint   `yaml:"port"    envconfig:"DEBUG_PORT"`
}

type ShelleyGenesisConfig added in v0.34.0

type ShelleyGenesisConfig struct {
	EpochLength uint64 `yaml:"epoch_length" envconfig:"SHELLEY_GENESIS_EPOCH_LENGTH"`
}

ShelleyGenesisConfig holds Shelley era genesis parameters

Jump to

Keyboard shortcuts

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