Skip to content

feat: implement config hot-reload and fix corrupted backend files#308

Open
malik203 wants to merge 1 commit into
benelabs:mainfrom
malik203:feat/config-hot-reload
Open

feat: implement config hot-reload and fix corrupted backend files#308
malik203 wants to merge 1 commit into
benelabs:mainfrom
malik203:feat/config-hot-reload

Conversation

@malik203
Copy link
Copy Markdown

feat: implement config hot-reload and fix corrupted backend files

Summary

Implements runtime configuration hot-reload for the backend and repairs all files that had
multiple versions concatenated together.

Changes

Config hot-reload (backend/src/config/)

  • AppConfig in config/mod.rs — hot-reloadable struct with ServerConfig, DatabaseConfig,
    RedisConfig, log_level, max_connections, request_timeout_secs, maintenance_mode
  • ConfigManager — wraps AppConfig in ArcSwap for lock-free reads; supports full reload from
    config.json and partial JSON-patch updates via update_from_patch
  • ConfigWatcher — subscribes to config:reload Redis pub/sub channel, fetches updated config
    from config:current key, and atomically swaps the in-memory value; notifies all ConfigHandle
    holders via a tokio::sync::watch channel
  • ConfigHandle — cheap-to-clone reader with get() and wait_for_change() support
  • ReloadError — unified error type covering Redis, I/O, deserialisation, and validation
    failures
  • handle_reload / handle_get_config — Axum handlers for POST /api/config/reload and GET
    /api/config

File corruption fixes

  • Cargo.toml — removed duplicate [dependencies] / [dev-dependencies] blocks and conflicting
    dep versions
  • src/lib.rs, src/error.rs, src/jobs.rs, src/telemetry.rs — removed concatenated duplicate
    implementations
  • src/services/mod.rs, src/api/mod.rs, src/api/handlers/mod.rs, src/api/middleware/mod.rs —
    deduplicated module declarations
  • src/api/handlers/profiling.rs, src/api/handlers/dashboard.rs — single clean implementation
    each

Testing

Unit tests in config/reload.rs cover:

  • ConfigManager: load, reload (missing file error path), patch (top-level and nested fields,
    field preservation)
  • ConfigWatcher: reload updates config, unchanged config skips notification, changed config
    notifies handles, multiple handles see same update, wait_for_change resolves after reload
  • reload_from_redis: connection error leaves config unchanged
  • ReloadError: display formatting for all variants
  • AppConfig: default values, serialisation roundtrip
  • closes [Backend] 10.8 Build Configuration Hot-Reload #184

- Add ConfigManager (ArcSwap-based, patch-capable) in config/reload.rs
- Add ConfigWatcher (Redis pub/sub driven reload) with ConfigHandle
- Add ReloadError, handle_reload and handle_get_config Axum handlers
- Move AppConfig to config/mod.rs with ServerConfig, DatabaseConfig, RedisConfig
- Fix corrupted concatenated duplicates in Cargo.toml, lib.rs, error.rs,
  jobs.rs, telemetry.rs, services/mod.rs, api/mod.rs, handlers/mod.rs,
  middleware/mod.rs, profiling.rs, dashboard.rs
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 27, 2026

@malik203 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Backend] 10.8 Build Configuration Hot-Reload

1 participant