Interface DataConn


public interface DataConn
Represents a data connection participating in transaction lifecycles managed by a 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 Type
    Method
    Description
    default void
    Terminates this connection abnormally when an unrecoverable RuntimeException or Error occurs.
    void
    Closes and disposes of this data connection, releasing any held resources.
    void
    Commits changes made through this connection.
    boolean
    Checks whether this connection has been committed.
    default void
    Notifies this connection of a transaction failure with detailed failure reports.
    default void
    Performs post-commit operations after all connections in a transaction have successfully committed.
    default void
    Prepares this connection for commit prior to the main commit phase.
    void
    Rolls back changes made through this connection.
  • Method Details

    • preCommit

      default void preCommit(AsyncGroup ag) throws com.github.sttk.errs.Err
      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

      void commit(AsyncGroup ag) throws com.github.sttk.errs.Err
      Commits changes made through this connection.

      Asynchronous background tasks may be registered with the provided AsyncGroup during commit processing.

      Parameters:
      ag - the asynchronous group for registering background tasks
      Throws:
      com.github.sttk.errs.Err - if committing the transaction changes fails
    • postCommit

      default void postCommit(AsyncGroup ag) throws com.github.sttk.errs.Err
      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:
      true if this connection has been committed; false otherwise
    • rollback

      void rollback(AsyncGroup ag) throws com.github.sttk.errs.Err
      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

      default void onTxnFailure(AsyncGroup ag, List<TxnFailureReport> reports)
      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 tasks
      reports - 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 unrecoverable RuntimeException or Error occurs.

      The default implementation delegates to close().