Skip to content

Commit

Permalink
allow transaction to disable watchdog locally
Browse files Browse the repository at this point in the history
  • Loading branch information
paberr committed Nov 7, 2017
1 parent 9333d0e commit 780cb3c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/main/generic/CombinedTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,10 @@ class CombinedTransaction {
/**
* Creates a new transaction, ensuring read isolation
* on the most recently successfully committed state.
* @param {boolean} [enableWatchdog]
* @returns {Transaction} The transaction object.
*/
transaction() {
transaction(enableWatchdog) {
throw 'Unsupported operation';
}

Expand Down
5 changes: 3 additions & 2 deletions src/main/generic/DefaultWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,14 @@ class DefaultWrapper {
}

/**
* @param {boolean} enableWatchdog
* @returns {Transaction}
*/
transaction() {
transaction(enableWatchdog = true) {
if (!this._store.transaction) {
return undefined;
}
const tx = this._store.transaction();
const tx = this._store.transaction(enableWatchdog);
return new this.constructor(tx);
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/generic/ObjectStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,12 @@ class ObjectStore {
/**
* Creates a new transaction, ensuring read isolation
* on the most recently successfully committed state.
* @param {boolean} [enableWatchdog]
* @returns {Transaction} The transaction object.
*/
transaction() {
transaction(enableWatchdog = true) {
if (!this.__backend.connected) throw 'JungleDB is not connected';
const tx = new Transaction(this, this._currentState, this);
const tx = new Transaction(this, this._currentState, this, enableWatchdog);
this._transactions.set(tx.id, tx);
this._txBaseStates.set(tx.id, this._currentStateId);
this._openTransactions.get(this._currentStateId).add(tx.id);
Expand Down
5 changes: 3 additions & 2 deletions src/main/generic/Transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -737,13 +737,14 @@ class Transaction {
* This makes the current transaction read-only until all sub-transactions have been closed (committed/aborted).
* The same semantic for commits applies: Only the first transaction that commits will be applied. Subsequent transactions will be conflicted.
* This behaviour has one exception: If all nested transactions are closed, the outer transaction returns to a normal state and new nested transactions can again be created and committed.
* @param {boolean} [enableWatchdog]
* @returns {Transaction} The transaction object.
*/
transaction() {
transaction(enableWatchdog = true) {
if (this._state !== Transaction.STATE.OPEN && this._state !== Transaction.STATE.NESTED) {
throw 'Transaction already closed';
}
const tx = new Transaction(this._objectStore, this, this, this._enableWatchdog);
const tx = new Transaction(this._objectStore, this, this, enableWatchdog);
this._nested.add(tx);
this._state = Transaction.STATE.NESTED;
return tx;
Expand Down
3 changes: 2 additions & 1 deletion src/main/generic/interfaces/IObjectStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ class IObjectStore {
* Creates a new transaction, ensuring read isolation
* on the most recently successfully committed state.
* @abstract
* @param {boolean} [enableWatchdog] Boolean allows to disable watchdog timer.
* @returns {Transaction} The transaction object.
*/
transaction() {} // eslint-disable-line no-unused-vars
transaction(enableWatchdog = true) {} // eslint-disable-line no-unused-vars
}

0 comments on commit 780cb3c

Please sign in to comment.