Interface DataConn


public interface DataConn
The interface that abstracts a connection per session to an external data service, such as a database, file system, or messaging service.

Its primary purpose is to enable cohesive transaction operations across multiple external data services within a single transaction context. Implementations of this interface provide the concrete input/output operations for their respective data services.

Methods declared within this interface are designed to handle transactional logic. The AsyncGroup parameter in various methods allows for asynchronous processing when commit or rollback operations are time-consuming.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes the connection to the external data service, releasing any associated resources.
    void
    Commits the changes made within the current session to the external data service.
    default void
    Performs a force-back operation to revert the committed changes when this connection had been already committed but the other connection had failed.
    default void
    Performs any necessary post-commit operations.
    default void
    Performs any necessary pre-commit operations.
    void
    Rolls back the changes made within the current session, discarding all operations performed since the last commit or rollback.
    default boolean
    Indicates whether a force-back operation should be performed.
  • Method Details

    • commit

      void commit(AsyncGroup ag) throws com.github.sttk.errs.Exc
      Commits the changes made within the current session to the external data service. This method is responsible for finalizing all operations performed since the last commit or rollback.
      Parameters:
      ag - An AsyncGroup that can be used to perform asynchronous operations if the commit process is time-consuming.
      Throws:
      com.github.sttk.errs.Exc - if an error occurs during the commit operation.
    • preCommit

      default void preCommit(AsyncGroup ag) throws com.github.sttk.errs.Exc
      Performs any necessary pre-commit operations. This method is called before the commit(AsyncGroup) method.
      Parameters:
      ag - An AsyncGroup that can be used for asynchronous pre-commit tasks.
      Throws:
      com.github.sttk.errs.Exc - if an error occurs during the pre-commit operation.
    • postCommit

      default void postCommit(AsyncGroup ag)
      Performs any necessary post-commit operations. This method is called after the commit(AsyncGroup) method has successfully completed.
      Parameters:
      ag - An AsyncGroup that can be used for asynchronous post-commit tasks.
    • shouldForceBack

      default boolean shouldForceBack()
      Indicates whether a force-back operation should be performed. A force-back is a mechanism to revert the committed changes when this connection had been already committed but the other connection had failed.
      Returns:
      true if a force-back is required, false otherwise.
    • rollback

      void rollback(AsyncGroup ag)
      Rolls back the changes made within the current session, discarding all operations performed since the last commit or rollback.
      Parameters:
      ag - An AsyncGroup that can be used to perform asynchronous operations if the rollback process is time-consuming.
    • forceBack

      default void forceBack(AsyncGroup ag)
      Performs a force-back operation to revert the committed changes when this connection had been already committed but the other connection had failed.
      Parameters:
      ag - An AsyncGroup that can be used for asynchronous force-back tasks.
    • close

      void close()
      Closes the connection to the external data service, releasing any associated resources. This method should be called to ensure proper resource management.