import { AbortResult, CommitResult, PrepareResult, TransactionContext } from './types'; /** * Interface adapter towards banking core. * * Based on the 2-phase commit protocol, adapter * implementation should provide methods for the * first phase: * - prepare * * and the second phase: * - abort * - commit * * Methods have to support idempotency. Meaning * if processor calls methods multiple times for * the same job (command), they have to check * if they are already processing or have started * processing the given job and not start processing * it again. * * Each phase can suspend processing of a current job * in order to give more time to bank system for core * transaction processing. When suspended job is * continued, the bank adapter method which caused * suspend will be invoked again in order to provide * result for the executing phase. */ export declare abstract class IBankAdapter { /** * Prepares transaction for execution. * Validates and allocates resources * needed for executing the transaction. * * @param context transaction context * @returns prepared, failed or suspended */ abstract prepare(context: TransactionContext): Promise; /** * Aborts transaction. Reverts any resources * allocated in the prepare phase. * * @param context transaction context * @returns aborted or suspended */ abstract abort(context: TransactionContext): Promise; /** * Commits transaction. Finalizes allocated * resources in the prepare phase. * * @param context transaction context * @return committed or suspended */ abstract commit(context: TransactionContext): Promise; }