Skip to content

Add persistent storage feature#51

Merged
cybcon merged 25 commits intomainfrom
feature/persistent_storage
Feb 8, 2026
Merged

Add persistent storage feature#51
cybcon merged 25 commits intomainfrom
feature/persistent_storage

Conversation

@cybcon
Copy link
Owner

@cybcon cybcon commented Feb 8, 2026

Summary

This branch implements persistent storage for Modbus registers and related documentation, tests, and configuration updates. It adds a new persistence library, integrates persistence into the server shutdown flow (graceful save), updates examples and configuration to support persistence, and includes supporting documentation and community files.

Highlights

  • Persistence: Adds a new persistence library and integrates it into the server to persist register state across restarts.
  • Tests: Adds unit tests for the persistence library to validate behavior.
  • Configuration: Adds persistence settings to the server configuration and example files.
  • Docs & Community: Adds SECURITY, CODE_OF_CONDUCT, CONTRIBUTING, and arc42 architecture docs/diagrams.
  • Maintenance: Minor logging, version bumps, and .gitignore improvements.

Key Changes (features & fixes)

  • Persistence implementation: New library and integration

    • Added src/app/lib/register_persistence/__init__.py implementing register persistence and storage optimizations.
    • Integrated persistence into server shutdown to perform a graceful save (src/app/modbus_server.py).
    • Added persistence configuration to src/app/modbus_server.json and examples.
  • Tests

    • Added tests/test_register_persistence.py to exercise the new persistence library.
    • Adjusted existing tests where necessary (tests/test_server.py, tests/__init__.py).
  • Documentation & Project Files

    • Added security and community docs: SECURITY.md, CODE_OF_CONDUCT.md, CONTRIBUTING.md.
    • Architectural documentation and diagrams: arc42/architecture.md and diagram files under arc42/diagrams/.
    • README updates describing the persistence feature and other clarifications.
  • Examples & Configuration

    • Updated examples/test.json, examples/abb_coretec_example.json, and examples/udp.json (removed deprecated fields, enabled debug in test examples, and added persistence-related configuration where applicable).
  • Build / CI / Packaging

    • Updated .github/workflows/test.yaml and Dockerfile variants for version changes and compatibility.
  • Other fixes

    • Logger configuration and wording fixes in various docs.
    • Updated .gitignore to ignore virtual envs and envrc.
    • Removed src/app/__init__.py (file deletion).

Files of interest

  • src/app/lib/register_persistence/__init__.py — new persistence library
  • src/app/modbus_server.py — integrated persistence and graceful-save adjustments
  • src/app/modbus_server.json — new/updated persistence configuration
  • tests/test_register_persistence.py — new tests
  • examples/test.json — example updated to reflect debug/persistence config
  • SECURITY.md, CODE_OF_CONDUCT.md, CONTRIBUTING.md — new repository-level docs
  • arc42/architecture.md and arc42/diagrams/ — architecture documentation and diagrams

Testing & Validation

  • Run the test suite locally:
cd src/
pip install -r requirements.txt
pytest
  • Run a focused test for persistence:
pytest tests/test_register_persistence.py -q

Migration / Configuration Notes

  • Persistence is controlled via modbus_server.json. If upgrading from a branch without persistence, check persistence settings in src/app/modbus_server.json and the example files.
  • The server now attempts to save register state during graceful shutdown — ensure your deployment allows the process time to shutdown cleanly.

Backward compatibility & Caveats

  • Default behaviour remains unchanged if persistence is not enabled in the configuration. When enabled, the server will create/modify on-disk persistence files as configured.
  • The branch introduces minor API/behaviour changes only around persistence lifecycle and storage optimization; existing Modbus protocol handling is not modified except for the persistence lifecycle integration.

@cybcon cybcon added the minor New Features label Feb 8, 2026
@cybcon cybcon merged commit 62eed28 into main Feb 8, 2026
26 checks passed
@cybcon cybcon deleted the feature/persistent_storage branch February 8, 2026 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor New Features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant