CombinedTransaction
Implements:
This class represents a combined transaction across object stores.
Constructor Summary
Public Constructor | ||
public |
constructor(transactions: ...Transaction) |
Member Summary
Public Members | ||
public get |
|
|
public get |
|
|
public get |
Returns the object store this transaction belongs to. |
|
public get |
transactions: Array<Transaction> |
Protected Members | ||
protected set |
_dependency(dependency: CombinedTransaction) Sets a new CombinedTransaction as dependency. |
Method Summary
Public Methods | ||
public |
abort(): Promise Is used to abort an open transaction. |
|
public |
async commit(): Promise<boolean> Is used to commit the state of an open transaction. |
|
public |
isConsistent(transactions: Array<Transaction>): boolean Verifies the two most important consistency rules for combined transactions: 1. |
|
public |
async onFlushable(tx: Transaction, callback: function(), preprocessing: function(): Promise): Promise<boolean> To be called when a transaction is flushable to the persistent state. |
|
public |
Creates an in-memory snapshot of the current state. |
|
public |
toString(): string |
|
public |
transaction(enableWatchdog: boolean): Transaction Creates a new transaction, ensuring read isolation on the most recently successfully committed state. |
Protected Methods | ||
protected |
async _checkConstraints(): Promise<boolean> Is used to check constraints before committing. |
|
protected |
async _commitBackend(): Promise Is used to commit the transaction. |
|
protected |
async _commitInternal(tx: Transaction): Promise Unsupported operation for snapshots. |
|
protected |
_isCommittable(): boolean Is used to probe whether a transaction can be committed. |
|
protected |
_setParent(parent: *) Allows to change the backend of a Transaction when the state has been flushed. |
Public Constructors
public constructor(transactions: ...Transaction) source
Params:
Name | Type | Attribute | Description |
transactions | ...Transaction | The transactions to build the combined transaction from. |
Public Members
public get dependency: CombinedTransaction source
public get transactions: Array<Transaction> source
Protected Members
protected set _dependency(dependency: CombinedTransaction) source
Sets a new CombinedTransaction as dependency.
Public Methods
public abort(): Promise source
Is used to abort an open transaction. A user only needs to call this method on Transactions without arguments. The optional tx argument is only used internally, in order to abort a transaction on the underlying store.
Return:
Promise | The promise resolves after successful abortion of the transaction. |
public async commit(): Promise<boolean> source
Is used to commit the state of an open transaction. A user only needs to call this method on Transactions without arguments. The optional tx argument is only used internally, in order to commit a transaction to the underlying store. If the commit was successful, the method returns true, and false otherwise.
Return:
Promise<boolean> | A promise of the success outcome. |
public isConsistent(transactions: Array<Transaction>): boolean source
Verifies the two most important consistency rules for combined transactions:
- only transactions from different object stores
- only open transactions
- only transactions from the same JungleDB instance
- only non-nested transactions
Params:
Name | Type | Attribute | Description |
transactions | Array<Transaction> |
Return:
boolean | Whether the given set of transactions is suitable for a combined transaction. |
public async onFlushable(tx: Transaction, callback: function(), preprocessing: function(): Promise): Promise<boolean> source
To be called when a transaction is flushable to the persistent state. Triggers combined flush as soon as all transactions are ready.
Params:
Name | Type | Attribute | Description |
tx | Transaction | Transaction to be reported flushable. |
|
callback | function() |
|
A callback to be called after the transaction is flushed. |
preprocessing | function(): Promise |
|
A callback to be called right before the transaction is flushed. |
Return:
Promise<boolean> | Whether the flushing has been triggered. |
public snapshot(): Snapshot source
Creates an in-memory snapshot of the current state. This snapshot only maintains the differences between the state at the time of the snapshot and the current state. To stop maintaining the snapshot, it has to be aborted.
public transaction(enableWatchdog: boolean): Transaction source
Creates a new transaction, ensuring read isolation on the most recently successfully committed state.
Params:
Name | Type | Attribute | Description |
enableWatchdog | boolean |
|
Protected Methods
protected async _checkConstraints(): Promise<boolean> source
Is used to check constraints before committing. If a constraint is not satisfied, the commitable is aborted and an exception is thrown.
Return:
Promise<boolean> |
Throw:
* |
protected async _commitBackend(): Promise source
Is used to commit the transaction.
Return:
Promise | A promise that resolves upon successful application of the transaction. |
protected async _commitInternal(tx: Transaction): Promise source
Unsupported operation for snapshots.
Params:
Name | Type | Attribute | Description |
tx | Transaction | The transaction to be applied. |
Return:
Promise | A promise that resolves upon successful application of the transaction. |
protected _isCommittable(): boolean source
Is used to probe whether a transaction can be committed. This, for example, includes a check whether another transaction has already been committed.
Return:
boolean | Whether a commit will be successful. |
protected _setParent(parent: *) source
Allows to change the backend of a Transaction when the state has been flushed.
Params:
Name | Type | Attribute | Description |
parent | * |