Update waitForCompletion and pouch / backup type
This commit is contained in:
parent
9973f2e161
commit
f7af8621d5
|
@ -29,6 +29,7 @@ class InMemoryQueue {
|
|||
_messages: any[]
|
||||
_emitter: EventEmitter
|
||||
_runCount: number
|
||||
_addCount: number
|
||||
/**
|
||||
* The constructor the queue, exactly the same as that of Bulls.
|
||||
* @param {string} name The name of the queue which is being configured.
|
||||
|
@ -41,6 +42,7 @@ class InMemoryQueue {
|
|||
this._messages = []
|
||||
this._emitter = new events.EventEmitter()
|
||||
this._runCount = 0
|
||||
this._addCount = 0
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,6 +83,7 @@ class InMemoryQueue {
|
|||
throw "Queue only supports carrying JSON."
|
||||
}
|
||||
this._messages.push(newJob(this._name, msg))
|
||||
this._addCount++
|
||||
this._emitter.emit("message")
|
||||
}
|
||||
|
||||
|
@ -128,12 +131,9 @@ class InMemoryQueue {
|
|||
}
|
||||
|
||||
async waitForCompletion() {
|
||||
const currentCount = this._runCount
|
||||
let increased = false
|
||||
do {
|
||||
await timeout(50)
|
||||
increased = this._runCount > currentCount
|
||||
} while (!increased)
|
||||
} while (this._addCount < this._runCount)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ export interface AppBackupMetadata {
|
|||
}
|
||||
|
||||
export interface AppBackup extends Document, AppBackupMetadata {
|
||||
_id: string
|
||||
filename?: string
|
||||
}
|
||||
|
||||
|
|
|
@ -24,3 +24,9 @@ interface BulkDocResponse {
|
|||
id: string
|
||||
rev: string
|
||||
}
|
||||
|
||||
export interface PutResponse {
|
||||
ok: boolean
|
||||
id: string
|
||||
rev: string
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue