Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bitfinex/bfx-report",
"version": "5.3.0",
"version": "5.4.0",
"description": "Reporting tool",
"main": "worker.js",
"engines": {
Expand Down
9 changes: 8 additions & 1 deletion workers/loc.api/errors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@ class PDFBufferUnderFrameworkCreationError extends BaseError {
}
}

class InterrupterNameSettingError extends BaseError {
constructor (message = 'ERR_INTERRUPTER_NAME_INCOMPATIBLE_FOR_USE') {
super(message)
}
}

module.exports = {
BaseError,
BadRequestError,
Expand All @@ -225,5 +231,6 @@ module.exports = {
ImplementationError,
WeightedAveragesTimeframeError,
PDFBufferUnderElectronCreationError,
PDFBufferUnderFrameworkCreationError
PDFBufferUnderFrameworkCreationError,
InterrupterNameSettingError
}
17 changes: 17 additions & 0 deletions workers/loc.api/interrupter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
const EventEmitter = require('events')

const INTERRUPTER_NAMES = require('./interrupter.names')
const {
InterrupterNameSettingError
} = require('../errors')

const { decorateInjectable } = require('../di/utils')

Expand All @@ -18,10 +21,24 @@ class Interrupter extends EventEmitter {
this._interruptPromise = Promise.resolve()

this.name = INTERRUPTER_NAMES.COMMON_INTERRUPTER

this.interrupterNames = Object.values(INTERRUPTER_NAMES)
}

#validateIntName () {
const hasRegisteredName = this.interrupterNames
.some((name) => (name === this.name))

if (hasRegisteredName) {
return
}

throw new InterrupterNameSettingError()
}

setName (name) {
this.name = name ?? INTERRUPTER_NAMES.COMMON_INTERRUPTER
this.#validateIntName()

return this
}
Expand Down
3 changes: 2 additions & 1 deletion workers/loc.api/interrupter/interrupter.names.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ module.exports = {
COMMON_INTERRUPTER: 'COMMON_INTERRUPTER',

SYNC_INTERRUPTER: 'SYNC_INTERRUPTER',
TRX_TAX_REPORT_INTERRUPTER: 'TRX_TAX_REPORT_INTERRUPTER'
TRX_TAX_REPORT_INTERRUPTER: 'TRX_TAX_REPORT_INTERRUPTER',
FULL_SNAPSHOT_REPORT_INTERRUPTER: 'FULL_SNAPSHOT_REPORT_INTERRUPTER'
}
Loading