Imported from GitHub samson-media/barn#2 — opened by @daniel-samson on 2026-01-21 12:35:05 UTC
Implement the TOML configuration parser and configuration model for Barn.
docs/config.md
Create records/classes in com.samsonmedia.barn.config/:
com.samsonmedia.barn.config/
// Config.java - top-level configuration public record Config( ServiceConfig service, JobsConfig jobs, CleanupConfig cleanup, StorageConfig storage ) { } // ServiceConfig.java public record ServiceConfig( LogLevel logLevel, // debug, info, warn, error int maxConcurrentJobs, // default: 4 int heartbeatIntervalSeconds, // default: 5 Path ipcSocket, // platform-specific default int staleHeartbeatThresholdSeconds // default: 30 ) { } // JobsConfig.java public record JobsConfig( int defaultTimeoutSeconds, // default: 3600 int maxRetries, // default: 3 int retryDelaySeconds, // default: 30 double retryBackoffMultiplier, // default: 2.0 List<Integer> retryOnExitCodes // default: empty (retry all) ) { } // CleanupConfig.java public record CleanupConfig( boolean enabled, // default: true int maxAgeHours, // default: 72 int cleanupIntervalMinutes, // default: 60 boolean keepFailedJobs, // default: true int keepFailedJobsHours // default: 168 ) { } // StorageConfig.java public record StorageConfig( Path baseDir, // default: platform temp/barn int maxDiskUsageGb, // default: 50 boolean preserveWorkDir // default: false ) { }
ConfigLoader.java:
ConfigLoader.java
--config
Pattern: BARN_<SECTION>_<KEY> (uppercase, underscores)
BARN_<SECTION>_<KEY>
// Example: BARN_SERVICE_LOG_LEVEL=debug overrides [service] log_level
public final class ConfigDefaults { public static Path getDefaultConfigPath() { return switch (OS.current()) { case LINUX -> Path.of("/etc/barn/barn.conf"); case MACOS -> Path.of("/etc/barn/barn.conf"); case WINDOWS -> Path.of(System.getenv("PROGRAMDATA"), "barn", "barn.conf"); }; } public static Path getDefaultIpcSocket() { return switch (OS.current()) { case LINUX, MACOS -> Path.of("/tmp/barn/barn.sock"); case WINDOWS -> Path.of("\\\\.\\pipe\\barn"); }; } }
ConfigTest.java
ConfigLoaderTest.java
ConfigDefaultsTest.java
mvn verify
For TOML parsing, consider:
toml4j
Validation should check:
@daniel-samson commented on 2026-01-21 12:59:23 UTC:
Completed implementation:
Deliverables:
Commit: 79f89be
79f89be
No dependencies set.
The note is not visible to the blocked user.
Imported from GitHub samson-media/barn#2 — opened by @daniel-samson on 2026-01-21 12:35:05 UTC
Overview
Implement the TOML configuration parser and configuration model for Barn.
Context
docs/config.md(defines all config options)Requirements
1. Configuration Model
Create records/classes in
com.samsonmedia.barn.config/:2. Configuration Loader
ConfigLoader.java:--configCLI override3. Environment Variable Override
Pattern:
BARN_<SECTION>_<KEY>(uppercase, underscores)4. Platform-Specific Defaults
5. Tests Required
ConfigTest.java: Test record creation with defaultsConfigLoaderTest.java: Test file loading, env override, validationConfigDefaultsTest.java: Test platform detectionAcceptance Criteria
mvn verifypassesImplementation Notes
For TOML parsing, consider:
toml4jdependencyValidation should check:
Definition of Done
@daniel-samson commented on 2026-01-21 12:59:23 UTC:
Completed implementation:
Deliverables:
Commit:
79f89be