Interface DataConn
DataHub.
Implementations encapsulate connection state and operations for external resources such as relational databases, NoSQL stores, or web services. During a transaction, connections progress through pre-commit, commit, and post-commit phases, and support rollback, failure reporting, and abnormal termination handling when errors occur.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidabend()Terminates this connection abnormally when an unrecoverableRuntimeExceptionorErroroccurs.voidclose()Closes and disposes of this data connection, releasing any held resources.voidcommit(AsyncGroup ag) Commits changes made through this connection.booleanChecks whether this connection has been committed.default voidonTxnFailure(AsyncGroup ag, List<TxnFailureReport> reports) Notifies this connection of a transaction failure with detailed failure reports.default voidpostCommit(AsyncGroup ag) Performs post-commit operations after all connections in a transaction have successfully committed.default voidpreCommit(AsyncGroup ag) Prepares this connection for commit prior to the main commit phase.voidrollback(AsyncGroup ag) Rolls back changes made through this connection.
-
Method Details
-
preCommit
Prepares this connection for commit prior to the main commit phase.The default implementation does nothing. Implementations can override this method to perform pre-commit checks or flush pending writes.
- Parameters:
ag- the asynchronous group for registering background tasks- Throws:
com.github.sttk.errs.Err- if pre-commit preparation or validation fails
-
commit
Commits changes made through this connection.Asynchronous background tasks may be registered with the provided
AsyncGroupduring commit processing.- Parameters:
ag- the asynchronous group for registering background tasks- Throws:
com.github.sttk.errs.Err- if committing the transaction changes fails
-
postCommit
Performs post-commit operations after all connections in a transaction have successfully committed.The default implementation does nothing. Implementations can override this method to perform cleanup or trigger post-commit notifications.
- Parameters:
ag- the asynchronous group for registering background tasks- Throws:
com.github.sttk.errs.Err- if post-commit processing fails
-
isCommitted
boolean isCommitted()Checks whether this connection has been committed.- Returns:
trueif this connection has been committed;falseotherwise
-
rollback
Rolls back changes made through this connection.This method is invoked when a transaction fails before commit completes and must restore the connection or underlying resource to its pre-transaction state.
- Parameters:
ag- the asynchronous group for registering background tasks- Throws:
com.github.sttk.errs.Err- if rolling back connection changes fails
-
onTxnFailure
Notifies this connection of a transaction failure with detailed failure reports.The default implementation does nothing. Implementations can inspect failure reports to log diagnostics or take recovery actions.
- Parameters:
ag- the asynchronous group for registering background tasksreports- the list of transaction failure reports
-
close
void close()Closes and disposes of this data connection, releasing any held resources. -
abend
default void abend()Terminates this connection abnormally when an unrecoverableRuntimeExceptionorErroroccurs.The default implementation delegates to
close().
-