module

AptLarder

Top-level module — holds global config and logging state.

Startup sequence (called from CLI::Server#run):

  1. init_app!(config_file) — load YAML, apply env overrides, validate, open log
  2. Server.new(config).start — bind, listen, run background loops

Signal handlers update state here: SIGUSR1 calls reopen_log_file!, SIGTERM calls server.stop.

Constants

COPY_BUFFER_SIZE = 64 * 1024

Shared buffer size for all IO copy operations. 64 KB reduces syscall overhead by 8× vs Crystal's default 8 KB.

GIT_REF = {{ (`git log -n 1 --format=\"%H\" | head -c 8`).chomp.stringify }}
Log = ::Log.for("apt-larder")
VERSION = {{ (`shards version /tmp/tmp.mLPiMM/src/src`).chomp.stringify }}

Class methods

close_log_file!

Closes the log file if logging to a file (no-op when writing to stdout). Called from CLI::Server#run's ensure block after Server#start returns.

Source
config

Returns the active Config, constructing one with defaults if none has been loaded yet.

Source
format_bytes(n : Int64) : String

Formats n bytes as a human-readable string (1.2 KB, 45.3 MB, …).

Source
immutable?(key : String) : Bool

Returns true for cache keys that APT guarantees are immutable once published: .deb packages and content-addressed paths (/pool/, /by-hash/).

Source
init_app!(config_file)

Bootstraps the application: load config → apply env vars → validate → open log. Raises ArgumentError if the config is invalid.

Source
parse_connect_target(resource : String) : Tuple(String, Int32)

Parses a CONNECT authority (host:port) into {host, port}.

Handles IPv6 literals: the brackets of [::1]:8443 are stripped and the port that follows the closing bracket is parsed, so an address containing colons is never split on the wrong one. A bracketed literal without a port ([::1]) and a bare host without a port both fall back to port 443.

Source
reopen_log_file!

Reopens the log file after log rotation (SIGUSR1).

Source
version

Returns "<version> (<git-ref>)".

Source

Nested types