Skip to content

update!: overhauled to align with the sabi-rust - #56

Merged
sttk merged 1 commit into
mainfrom
update/overhaul_to_align_with_sabi-rust
Jul 26, 2026
Merged

update!: overhauled to align with the sabi-rust#56
sttk merged 1 commit into
mainfrom
update/overhaul_to_align_with_sabi-rust

Conversation

@sttk

@sttk sttk commented Jul 26, 2026

Copy link
Copy Markdown
Owner

This pull request represents a major overhaul of the sabi-java framework to align its design and API with the sabi-rust implementation. The changes are comprehensive, touching the core framework interfaces, internal implementation, and error handling mechanisms.

Key Changes Overview

1. Enhanced Transaction Failure Reporting

The PR introduces a sophisticated transaction failure diagnostic system:

  • New classes: TxnFailureReport, TxnFailureCause, TxnFailureRollback, TxnFailureCauseState, TxnFailureRollbackState, TxnFailureRecovery
  • These provide detailed diagnostics about transaction failures across multiple data connections
  • Connections receive failure reports via the new DataConn#onTxnFailure() method to enable informed recovery decisions

2. Error Entry Refactoring (New ErrEntry Class)

  • Replaces Map-based error collection with a structured list-based approach
  • Captures indexed error entries with connection name and associated Err instances
  • Provides better semantics for batch operation error reporting during setup, pre-commit, commit, and post-commit phases

3. Data Connection Lifecycle Improvements

DataConn interface changes:

  • New isCommitted() method replaces shouldForceBack() for clearer semantics
  • rollback() and postCommit() now throw Err (previously ignored errors in postCommit)
  • New onTxnFailure() method for connections to handle transaction failure notifications
  • Added three error record types: FailToPreCommitDataConn, FailToCommitDataConn, FailToPostCommitDataConn

4. Internal Refactoring

Removed components:

  • DataSrcList → Replaced with DataSrcManager (ArrayList-based, more efficient)
  • DataConnList → Replaced with DataConnManager (ArrayList-based with manager responsibilities)

New internal components:

  • DataSrcManager: Manages data source registration and lifecycle with setup ordering support
  • DataConnManager: Handles data connection management, transaction phases, and failure reporting
  • TxnFailureReportBuilder: Constructs transaction failure reports during failure processing

5. DataHub API Enhancements

  • New constructor DataHub(List<String> names) and varargs variant for binding specific global data sources
  • New Sabi.setup(String... names) and Sabi.setup(List<String> names) for ordered global setup
  • Improved exception handling with better ClassCastException handling in run() and txn() methods

6. AsyncGroupImpl Optimization

  • Replaced linked-list error tracking with ArrayList<ErrEntry>
  • Now includes error index tracking for batch operations
  • Cleaner error management semantics

7. Documentation Improvements

All public interfaces received comprehensive Javadoc updates:

  • More precise and concise descriptions
  • Better parameter documentation
  • Clarified purpose and behavior of each component
  • Updated package-info documentation to emphasize the framework's modular design

8. Test Updates

  • AsyncGroupImplTest: Updated to work with new error entry list API
  • DataAccTest: Significant refactoring to test new transaction failure reporting mechanisms

Technical Philosophy Alignment

This overhaul brings the Java implementation closer to the Rust implementation by:

  • Adopting a state-aware transaction failure model for better diagnostics
  • Using indexed error entries instead of string-keyed maps for more explicit error tracking
  • Implementing connection state queries (isCommitted()) for more precise lifecycle management
  • Supporting ordered data source setup for deterministic initialization sequences

Impact

This is a breaking change (hence the commit message "update!") that:

  • Requires implementations to update DataConn with new methods
  • Changes error reporting semantics from Map-based to list-based
  • Provides significantly better diagnostics for transaction failures
  • Aligns the API with functional programming principles (state transitions, explicit failure reporting)

The changes maintain the core philosophy of sabi: separating business logic from data access through clean interfaces, while improving the framework's robustness and observability.

@sttk
sttk merged commit b2497e6 into main Jul 26, 2026
15 checks passed
@sttk
sttk deleted the update/overhaul_to_align_with_sabi-rust branch July 26, 2026 09:20
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.

1 participant