class

AptLarder::Config

Inherits YAML::Serializable / Reference / Object

Top-level configuration loaded from a YAML file (default: apt-larder.yml).

All fields have sensible defaults so a minimal config only needs to override what differs from the defaults. Unknown keys are silently ignored.

Example

cache_dir: /var/cache/apt-larder
index_ttl: 5
max_redirects: 5
connect_timeout: 10
read_timeout: 30
log_file: /var/log/apt-larder.log
quiet: false
evict_after_days: 30
server_host: "0.0.0.0"
server_port: 3142
admin:
  enabled: false

See AdminConfig for the nested admin: section.

Constructors

new(*, __context_for_yaml_serializable ctx : YAML::ParseContext, __node_for_yaml_serializable node : YAML::Nodes::Node)
Source

Instance methods

admin

Configuration for the optional admin server (REST API + web UI).

See AdminConfig for available fields.

Source
admin=(admin : AdminConfig)

Configuration for the optional admin server (REST API + web UI).

See AdminConfig for available fields.

Source
apply_env!(env : Hash(String, String) = ENV.to_h) : Nil

Overrides config values from env.

Convention: APT_LARDER_<FIELD> for top-level fields, APT_LARDER_ADMIN_<FIELD> for nested admin fields. Boolean fields accept "true", "1", "yes" (case-insensitive) as truthy.

Defaults to the process environment. Pass a plain Hash in tests to avoid mutating ENV (which is not thread-safe on UNIX — see crystal#16449).

Call after from_yaml and before validate!.

Source
cache_dir

Directory where cached packages and index files are stored on disk.

Source
cache_dir=(cache_dir : String)

Directory where cached packages and index files are stored on disk.

Source
connect_timeout

Upstream TCP connect timeout in seconds.

Source
connect_timeout=(connect_timeout : Int32)

Upstream TCP connect timeout in seconds.

Source
evict_after_days

Delete cached files not accessed for this many days.

The eviction loop runs once per hour in the background. Set to 0 (default) to disable automatic eviction entirely.

Source
evict_after_days=(evict_after_days : Int32)

Delete cached files not accessed for this many days.

The eviction loop runs once per hour in the background. Set to 0 (default) to disable automatic eviction entirely.

Source
index_ttl

Minutes before a cached index file (Release, Packages, …) is considered stale and revalidated against the upstream with a conditional GET (If-Modified-Since).

Immutable files (.deb, paths containing /pool/ or /by-hash/) are never subject to this TTL — they are cached forever.

Source
index_ttl=(index_ttl : Int32)

Minutes before a cached index file (Release, Packages, …) is considered stale and revalidated against the upstream with a conditional GET (If-Modified-Since).

Immutable files (.deb, paths containing /pool/ or /by-hash/) are never subject to this TTL — they are cached forever.

Source
log_file

Destination for access logs.

Use "stdout" to write to standard output, or an absolute path to write to a file. Send SIGUSR1 to reopen the file after log rotation.

Source
log_file=(log_file : String)

Destination for access logs.

Use "stdout" to write to standard output, or an absolute path to write to a file. Send SIGUSR1 to reopen the file after log rotation.

Source
log_level

Minimum log severity. Accepted values (case-insensitive): trace, debug, info, warn, error, fatal, off.

Defaults to info. Use debug to log upstream fetches and redirects.

Source
log_level=(log_level : String)

Minimum log severity. Accepted values (case-insensitive): trace, debug, info, warn, error, fatal, off.

Defaults to info. Use debug to log upstream fetches and redirects.

Source
max_cache_size_gb

Maximum cache size in gigabytes. When exceeded, the oldest files are deleted (LRU) until the cache fits within the limit. Set to 0 to disable size-based eviction entirely.

Accepts both integer (0) and float (0.5) in YAML.

Source
max_cache_size_gb=(max_cache_size_gb : Float64)

Maximum cache size in gigabytes. When exceeded, the oldest files are deleted (LRU) until the cache fits within the limit. Set to 0 to disable size-based eviction entirely.

Accepts both integer (0) and float (0.5) in YAML.

Source
max_redirects

Maximum number of HTTP redirects to follow for a single upstream request.

Mirrors commonly redirect http:// to https://; this limit prevents infinite redirect loops.

Source
max_redirects=(max_redirects : Int32)

Maximum number of HTTP redirects to follow for a single upstream request.

Mirrors commonly redirect http:// to https://; this limit prevents infinite redirect loops.

Source
quiet=(quiet : Bool)

When true, only MISS and ERR lines are logged.

HIT and REVAL lines are suppressed, which significantly reduces log volume on a warm cache where the vast majority of requests are hits.

Source
quiet?

When true, only MISS and ERR lines are logged.

HIT and REVAL lines are suppressed, which significantly reduces log volume on a warm cache where the vast majority of requests are hits.

Source
read_timeout

Upstream read timeout in seconds.

Applies to each individual read on the upstream connection, not to the total download duration. Increase for slow mirrors or very large files.

Source
read_timeout=(read_timeout : Int32)

Upstream read timeout in seconds.

Applies to each individual read on the upstream connection, not to the total download duration. Increase for slow mirrors or very large files.

Source
remaps

Host remapping table.

Maps upstream hostnames to replacement targets. The cache key always uses the original hostname so the cache remains valid if the mirror changes.

Each value can be a bare hostname (my-mirror.lan), a host:port pair, or a full URL (http://my-mirror.lan:8080). The path is preserved.

remaps:
  deb.debian.org: my-mirror.internal
  security.debian.org: my-mirror.internal
Source
remaps=(remaps : Hash(String, String))

Host remapping table.

Maps upstream hostnames to replacement targets. The cache key always uses the original hostname so the cache remains valid if the mirror changes.

Each value can be a bare hostname (my-mirror.lan), a host:port pair, or a full URL (http://my-mirror.lan:8080). The path is preserved.

remaps:
  deb.debian.org: my-mirror.internal
  security.debian.org: my-mirror.internal
Source
server_host

IP address the proxy server binds to.

Source
server_host=(server_host : String)

IP address the proxy server binds to.

Source
server_port

TCP port the proxy server listens on.

Source
server_port=(server_port : Int32)

TCP port the proxy server listens on.

Source
validate!

Raises ArgumentError with a descriptive message if any field contains an invalid value. Call once after loading the config file.

Source

Nested types