Skip to content

refactor(di): migrate from lightweight_di_container to common_system service_container#447

Merged
kcenon merged 3 commits into
mainfrom
refactor/issue-367-migrate-to-service-container
Feb 23, 2026
Merged

refactor(di): migrate from lightweight_di_container to common_system service_container#447
kcenon merged 3 commits into
mainfrom
refactor/issue-367-migrate-to-service-container

Conversation

@kcenon

@kcenon kcenon commented Feb 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • Remove legacy lightweight_di_container and related internal DI headers (4 files, 587 LOC deleted)
  • Rewrite DI container tests to validate integration with common_system::di::service_container
  • Fix test build: link to LoggerSystem target instead of non-existent logger target
  • Update PROJECT_STRUCTURE.md to reflect the new DI architecture

Closes kcenon/common_system#367

Context

This is Phase 3 of the DI container consolidation effort (kcenon/common_system#363).
The lightweight_di_container was only used in test code and is now fully replaced
by the unified service_container from common_system.

Changes

Removed

  • src/impl/di/di_container_interface.h - Template DI interface
  • src/impl/di/lightweight_container.h - Simple type-based container
  • src/impl/di/lightweight_di_container.h - String-based template container
  • src/impl/di/thread_system_di_adapter.h - Thread system adapter

Added/Modified

  • tests/unit/di_test/di_container_test.cpp - 20 tests using service_container
  • tests/CMakeLists.txt - Add di_container_test to build (was never built before)
  • tests/unit/di_test/CMakeLists.txt - Link LoggerSystem instead of logger
  • docs/PROJECT_STRUCTURE.md - Update DI section

Test Plan

  • All 20 DI container integration tests pass
  • Tests cover: registration, resolution, singletons, transients, instances, factories, thread safety, freeze, clear, unregister
  • CI build passes on all platforms

Remove internal DI container files that are superseded by
common_system's service_container. These files were only used
in test code and are no longer needed.

Removed files:
- src/impl/di/di_container_interface.h
- src/impl/di/lightweight_container.h
- src/impl/di/lightweight_di_container.h
- src/impl/di/thread_system_di_adapter.h

Part of kcenon/common_system#367
Replace lightweight_di_container tests with service_container
integration tests. The new tests validate:
- Singleton and transient lifetime registration/resolution
- Instance registration
- Factory and simple factory patterns
- Duplicate registration prevention
- Unregister and clear operations
- Concurrent resolve thread safety (8 threads)
- Service descriptor introspection
- Container freeze behavior

Also fix test build configuration:
- Link to LoggerSystem instead of non-existent 'logger' target
- Add test definition to main tests/CMakeLists.txt

Part of kcenon/common_system#367
Replace internal DI implementation file listing with a note about
using common_system's service_container for dependency injection.

Part of kcenon/common_system#367
@github-actions

Copy link
Copy Markdown
Contributor

Performance Regression Check

Benchmark Base (ns) PR (ns) Delta
BM_AsyncDecorator 207.4 195.3 🚀 -5.8%
BM_BufferedAsyncDecorator 124.1 127.5 +2.7%
BM_BufferedDecorator 861.1 854.3 -0.8%
BM_ConsoleAsyncDecorator 342.2 275.2 🚀 -19.6%
BM_DirectConsoleWriter 5444.4 5619.2 +3.2%
BM_DirectFileWriter 739.2 742.7 +0.5%
BM_ManualNesting_Async 208.8 180.1 🚀 -13.7%
BM_ManualNesting_BufferedAsync 122.1 122.2 +0.0%
BM_ObjectPool_HighContention/real_time/threads:4 1034.2 1028.6 -0.5%
BM_ObjectPool_HighContention/real_time/threads:8 1203.5 1225.3 +1.8%
BM_ObjectPool_MultiThread/real_time/threads:1 18.8 18.6 -1.1%
BM_ObjectPool_MultiThread/real_time/threads:2 113.7 115.0 +1.1%
BM_ObjectPool_MultiThread/real_time/threads:4 103.1 105.4 +2.3%
BM_ObjectPool_MultiThread/real_time/threads:8 120.7 117.3 -2.8%
BM_ObjectPool_SingleThread 18.0 17.9 -0.4%
BM_ThreadLocalObjectPool_CacheEfficiency/16/real_time/threads:4 1.4 1.5 ⚠️ +12.0%
BM_ThreadLocalObjectPool_CacheEfficiency/32/real_time/threads:4 1.4 1.3 -0.4%
BM_ThreadLocalObjectPool_CacheEfficiency/4/real_time/threads:4 1.4 1.3 -0.7%
BM_ThreadLocalObjectPool_CacheEfficiency/64/real_time/threads:4 1.4 1.3 -0.7%
BM_ThreadLocalObjectPool_CacheEfficiency/8/real_time/threads:4 1.4 1.3 -0.6%
BM_ThreadLocalObjectPool_HighContention/real_time/threads:4 188.2 187.4 -0.4%
BM_ThreadLocalObjectPool_HighContention/real_time/threads:8 180.0 181.7 +0.9%
BM_ThreadLocalObjectPool_MultiThread/real_time/threads:1 3.7 3.7 -0.1%
BM_ThreadLocalObjectPool_MultiThread/real_time/threads:2 14.0 13.8 -0.9%
BM_ThreadLocalObjectPool_MultiThread/real_time/threads:4 18.7 18.6 -0.1%
BM_ThreadLocalObjectPool_MultiThread/real_time/threads:8 17.7 18.0 +1.7%
BM_ThreadLocalObjectPool_SingleThread 2.8 2.8 -0.1%
BM_Throughput_LargeMessages 161.3 200.2 ⚠️ +24.2%
BM_Throughput_SmallMessages 196.4 161.0 🚀 -18.0%

Threshold: >5% regression triggers warning
Result: ⚠️ 2 benchmark(s) show potential regression

@kcenon kcenon merged commit 66a00cc into main Feb 23, 2026
32 checks passed
@kcenon kcenon deleted the refactor/issue-367-migrate-to-service-container branch February 23, 2026 12:16
@kcenon

kcenon commented Mar 7, 2026

Copy link
Copy Markdown
Owner Author

Test Plan Verification ✅

Remaining unchecked test plan item verified post-merge:

  • CI build passes on all platforms — all 30 checks pass (ubuntu-24.04/gcc, ubuntu-24.04/clang, macos-14/clang, windows-2022/msvc)

kcenon added a commit that referenced this pull request Apr 13, 2026
…service_container (#447)

* refactor(di): remove legacy lightweight_di_container implementation

Remove internal DI container files that are superseded by
common_system's service_container. These files were only used
in test code and are no longer needed.

Removed files:
- src/impl/di/di_container_interface.h
- src/impl/di/lightweight_container.h
- src/impl/di/lightweight_di_container.h
- src/impl/di/thread_system_di_adapter.h

Part of kcenon/common_system#367

* test(di): rewrite DI tests to use common_system service_container

Replace lightweight_di_container tests with service_container
integration tests. The new tests validate:
- Singleton and transient lifetime registration/resolution
- Instance registration
- Factory and simple factory patterns
- Duplicate registration prevention
- Unregister and clear operations
- Concurrent resolve thread safety (8 threads)
- Service descriptor introspection
- Container freeze behavior

Also fix test build configuration:
- Link to LoggerSystem instead of non-existent 'logger' target
- Add test definition to main tests/CMakeLists.txt

Part of kcenon/common_system#367

* docs(di): update PROJECT_STRUCTURE.md after DI container removal

Replace internal DI implementation file listing with a note about
using common_system's service_container for dependency injection.

Part of kcenon/common_system#367
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.

refactor(di): Phase 3 — migrate logger_system to service_container

1 participant