Skip to content

Reload-Safe Configs

DaisyConfig has the same runtime safety rule across every handle layer:

  • current always exposes the last good typed value
  • a successful reload replaces it
  • a failed reload keeps the previous good value live

DaisyConfigHandle<T> is the simple unmanaged path:

when (val result = profileConfig.reload()) {
is DaisyReloadResult.Success -> logger.info("Reloaded.")
is DaisyReloadResult.Failure -> logger.warning(result.errors.joinToString { "${it.path}: ${it.message}" })
}

That protects a single file without adding versioning or migration semantics.

DaisyManagedConfigHandle<T> keeps the same last-good guarantee, but adds:

  • config_version
  • default-file creation
  • missing-key merge
  • ordered migrations
  • migration reports
when (val result = settingsHandle.migrate()) {
is DaisyManagedReloadResult.Success -> {
logger.info("Version ${result.report.versionBefore ?: 1} -> ${result.report.versionAfter}")
}
is DaisyManagedReloadResult.Failure -> {
logger.warning(result.errors.joinToString { "${it.path}: ${it.message}" })
}
}

DaisyModuleHandle<S> applies the same safety rule to:

  • typed settings
  • optional lang
  • one module text source

That means settings.yml and lang.yml move together as one runtime unit.

when (val result = spawnModule.migrate()) {
is DaisyManagedBundleReloadResult.Success -> logger.info("Spawn module migrated.")
is DaisyManagedBundleReloadResult.Failure -> logger.warning(result.errors.joinToString { "${it.path}: ${it.message}" })
}

If a live file becomes invalid during reload:

  • decode fails
  • errors are returned
  • the previous good typed value stays active

That rule is the same for:

  • DaisyConfigHandle<T>
  • DaisyManagedConfigHandle<T>
  • DaisyModuleHandle<S>

Because a typo in YAML should not switch runtime state to a half-decoded config.