Skip to content

feat: Phase 4 — Saga transactions, virtual threads, and test coverage - #4

Merged
aupv9 merged 1 commit into
mainfrom
feature/phase4-saga-virtual-threads-testing
Apr 7, 2026
Merged

aupv9 merged 1 commit into
mainfrom
feature/phase4-saga-virtual-threads-testing

Conversation

@aupv9

@aupv9 aupv9 commented Apr 7, 2026

Copy link
Copy Markdown
Owner

New module sharding-saga:

  • ShardSagaStep — execute + compensate interface
  • ShardSagaDefinition — immutable ordered step list with fluent builder
  • ShardSagaOrchestrator — forward execution with automatic reverse compensation
  • ShardSagaLog — immutable per-step audit record
  • ShardSagaException — carries sagaId + full audit log on failure
  • ShardingSagaAutoConfiguration — enabled via sharding.saga.enabled=true
  • ShardSagaOrchestratorTest — 7 scenarios covering happy-path, partial failure, first-step failure, reverse compensation order, and audit log assertions

sharding-core addition:

  • VirtualThreadShardExecutor — factory for ExecutorService backed by JDK 21 virtual threads (reflection-based, stays source-compatible with JDK 17); falls back to cached daemon thread pool on JDK 17–20

Test coverage gaps filled:

  • ShardKeyExtractorTest (sharding-aop) — all 3 extraction modes + error paths
  • MeteredShardRouterTest (sharding-metrics) — counter, timer, delegation
  • ReadWriteRoutingDataSourceTest (sharding-readwrite) — primary/replica routing, round-robin selection, no-replica fallback
  • ShardMigrationServiceTest (sharding-migration) — state machine transitions, key-range matching, invalid input, query methods

Infrastructure:

  • parent pom.xml: added sharding-saga module
  • sharding-spring-boot-starter: added sharding-saga optional dep + auto-config import
  • CHANGELOG.md + README.md: documented v4.0

https://claude.ai/code/session_01FTX9NsM4K1pu3c8yekzQ8m

Description

Brief description of the changes in this PR.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring

Related Issue

Fixes #(issue number)

Changes Made

  • Added/modified core sharding logic
  • Updated JDBC template functionality
  • Enhanced JPA repository support
  • Modified auto-configuration
  • Updated documentation
  • Added/updated tests

Testing

  • Unit tests pass
  • Integration tests pass
  • Added new tests for new functionality
  • Manual testing completed

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Screenshots (if applicable)

Add screenshots to help explain your changes.

Additional Notes

Any additional information that reviewers should know.

New module `sharding-saga`:
- ShardSagaStep<T> — execute + compensate interface
- ShardSagaDefinition<T> — immutable ordered step list with fluent builder
- ShardSagaOrchestrator — forward execution with automatic reverse compensation
- ShardSagaLog — immutable per-step audit record
- ShardSagaException — carries sagaId + full audit log on failure
- ShardingSagaAutoConfiguration — enabled via sharding.saga.enabled=true
- ShardSagaOrchestratorTest — 7 scenarios covering happy-path, partial failure,
  first-step failure, reverse compensation order, and audit log assertions

sharding-core addition:
- VirtualThreadShardExecutor — factory for ExecutorService backed by JDK 21
  virtual threads (reflection-based, stays source-compatible with JDK 17);
  falls back to cached daemon thread pool on JDK 17–20

Test coverage gaps filled:
- ShardKeyExtractorTest (sharding-aop) — all 3 extraction modes + error paths
- MeteredShardRouterTest (sharding-metrics) — counter, timer, delegation
- ReadWriteRoutingDataSourceTest (sharding-readwrite) — primary/replica routing,
  round-robin selection, no-replica fallback
- ShardMigrationServiceTest (sharding-migration) — state machine transitions,
  key-range matching, invalid input, query methods

Infrastructure:
- parent pom.xml: added sharding-saga module
- sharding-spring-boot-starter: added sharding-saga optional dep + auto-config import
- CHANGELOG.md + README.md: documented v4.0

https://claude.ai/code/session_01FTX9NsM4K1pu3c8yekzQ8m
@aupv9
aupv9 merged commit 7691a6f into main Apr 7, 2026
0 of 2 checks passed
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.

2 participants