Documentation
¶
Index ¶
Constants ¶
const ( DefaultInputPlugin = "chainsync" DefaultOutputPlugin = "log" )
Variables ¶
This section is empty.
Functions ¶
func SaveAtomic ¶ added in v0.40.0
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[any]any `yaml:"plugins" envconfig:"PLUGINS"`
Logging LoggingConfig `yaml:"logging" envconfig:"LOGGING"`
ConfigFile string `yaml:"-"`
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:"-"`
}
func (*Config) Load ¶
Load reads configuration from the environment and, if configFile is non-empty, from the YAML file at that path, then applies populate* defaults. Effective precedence: YAML > env > pre-set/default field values on *c.
Load does NOT preserve CLI flag values. pflag binds flags by reference into c, so yaml.Unmarshal overwrites the bound variable in place — the CLI value is lost. Callers that bind CLI flags via BindFlags must use LoadWithFlags instead to get the documented CLI > YAML > env precedence.
Load is not safe to call more than once on the same *Config: neither envconfig nor yaml clears fields that are absent from their source, so a key removed from the YAML between reloads will retain whatever value the previous Load left behind. Callers that need to reload must construct a fresh *Config (and re-bind flags) on each call.
func (*Config) LoadWithFlags ¶ added in v0.42.0
LoadWithFlags is Load plus CLI-flag preservation. Effective precedence: CLI > YAML > env > pre-set/default. Pass the same *pflag.FlagSet that was previously passed to BindFlags on this *Config so pflag's bound pointers map back into c.
Mechanism: snapshot the value of every flag with Changed=true BEFORE env/yaml overwrite the bound variables; re-apply each snapshotted value via fs.Set AFTER yaml. Flags the user did not explicitly set (Changed=false) are skipped, so defaults do not clobber env/yaml values.
Pass fs=nil for the same behavior as Load() (no CLI override).
type DebugConfig ¶
type LoggingConfig ¶
type LoggingConfig struct {
Level string `yaml:"level" envconfig:"LOGGING_LEVEL"`
}
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