config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package config loads and validates the hookkeep YAML configuration.

Secrets never live in the file itself: the config only names the environment variables that hold them (dsn_env, secret_env, ui_token_env).

Index

Constants

View Source
const (
	DefaultListen      = ":8080"
	DefaultMaxBody     = 1 << 20 // 1 MiB
	DefaultMaxAttempts = 10
	DefaultBackoffBase = 5 * time.Second
	DefaultBackoffMax  = 15 * time.Minute
	DefaultRetention   = 30 * 24 * time.Hour
	DefaultTimeout     = 10 * time.Second
)

Defaults applied by Load when a field is left unset.

Variables

This section is empty.

Functions

func ParseRelative

func ParseRelative(s string) (time.Duration, error)

ParseRelative parses a human duration like "30s", "15m" or "2d" — the same syntax config durations use. CLI and API relative-time params share it.

Types

type Backoff

type Backoff struct {
	Base   Duration `yaml:"base"`
	Max    Duration `yaml:"max"`
	Jitter *bool    `yaml:"jitter"`
}

func (Backoff) JitterEnabled

func (b Backoff) JitterEnabled() bool

JitterEnabled reports whether backoff jitter is on (default true).

type Config

type Config struct {
	Version   int      `yaml:"version"`
	Database  Database `yaml:"database"`
	Server    Server   `yaml:"server"`
	Sources   []Source `yaml:"sources"`
	Targets   []Target `yaml:"targets"`
	Retry     Retry    `yaml:"retry"`
	Retention Duration `yaml:"retention"`
}

func Load

func Load(path string) (*Config, error)

Load reads, parses and validates the config file at path. Unknown YAML fields are an error so typos never silently disable behavior.

func (*Config) DSN

func (c *Config) DSN() (string, error)

DSN resolves the database connection string from the configured env var.

func (*Config) SourceByName

func (c *Config) SourceByName(name string) *Source

SourceByName returns the source config, or nil if not declared.

func (*Config) TargetByName

func (c *Config) TargetByName(name string) *Target

TargetByName returns the target config, or nil if not declared.

type Database

type Database struct {
	DSNEnv string `yaml:"dsn_env"`
}

type Duration

type Duration time.Duration

Duration is a time.Duration that unmarshals from YAML strings like "30s", "15m" or "30d" (days are not part of time.ParseDuration but are the natural unit for retention).

func (Duration) Std

func (d Duration) Std() time.Duration

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(value *yaml.Node) error

type Retry

type Retry struct {
	MaxAttempts int     `yaml:"max_attempts"`
	Backoff     Backoff `yaml:"backoff"`
}

type Server

type Server struct {
	Listen     string `yaml:"listen"`
	UITokenEnv string `yaml:"ui_token_env"`
	MaxBody    Size   `yaml:"max_body"`
}

type Size

type Size int64

Size is a byte count that unmarshals from YAML strings like "1MiB", "512KiB" or a plain number of bytes.

func (*Size) UnmarshalYAML

func (s *Size) UnmarshalYAML(value *yaml.Node) error

type Source

type Source struct {
	Name    string   `yaml:"name"`
	Verify  *Verify  `yaml:"verify"`
	Targets []string `yaml:"targets"`
}

type Target

type Target struct {
	Name    string            `yaml:"name"`
	URL     string            `yaml:"url"`
	Timeout Duration          `yaml:"timeout"`
	Headers map[string]string `yaml:"headers"`
}

type Verify

type Verify struct {
	Preset        string `yaml:"preset"`
	SecretEnv     string `yaml:"secret_env"`
	Header        string `yaml:"header"`
	Encoding      string `yaml:"encoding"`
	Prefix        string `yaml:"prefix"`
	MerchantIDEnv string `yaml:"merchant_id_env"`
}

Verify configures signature verification for a source. Preset selects the scheme; header/encoding/prefix are only used by the generic-hmac preset, merchant_id_env only by iyzico (subscription events sign the merchant id, which is not present in the payload).

Jump to

Keyboard shortcuts

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