Skip to content

Commit

Permalink
feat: upgrade deps
Browse files Browse the repository at this point in the history
  • Loading branch information
AVVS committed Nov 17, 2021
1 parent 6dd2009 commit 1b6376f
Show file tree
Hide file tree
Showing 4 changed files with 2,210 additions and 2,623 deletions.
10 changes: 5 additions & 5 deletions __tests__/integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ describe('integration tests', () => {
}
}

function isLockAcquisitionError(e: Error): e is LockAcquisitionError {
return e.name === 'LockAcquisitionError'
function isLockAcquisitionError(e: unknown): e is LockAcquisitionError {
return e instanceof Error && e.name === 'LockAcquisitionError'
}

beforeEach(async () => {
Expand Down Expand Up @@ -266,7 +266,7 @@ describe('integration tests', () => {
try {
const result = await queueManager.dlock.fanout(id, 1500, job, arg1)
onComplete(result)
} catch (e) {
} catch (e: any) {
if (e.message === 'queue-no-response') {
timeoutError(e)
} else {
Expand Down Expand Up @@ -303,7 +303,7 @@ describe('integration tests', () => {
try {
const result = await queueManager.dlock.fanout(id, 1500, job)
onComplete(result)
} catch (e) {
} catch (e: any) {
if (e.message === 'queue-no-response') {
timeoutError(e)
} else {
Expand Down Expand Up @@ -331,7 +331,7 @@ describe('integration tests', () => {
try {
const results = await queueManager.dlock.fanout('error', job)
onComplete(null, results)
} catch (e) {
} catch (e: any) {
if (e.name === args.name && e.message === args.message) {
onComplete(e)
} else {
Expand Down
21 changes: 10 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,32 +41,31 @@
"@microfleet/callback-queue": "^4.0.2",
"@microfleet/ioredis-lock": "^5.0.4",
"bluebird": "^3.7.1",
"denque": "^1.5.0",
"denque": "^2.0.1",
"lodash": "^4.17.21",
"pino": "^6.11.3",
"pino": "^7.2.0",
"read-pkg-up": "7",
"serialize-error": "^8.1.0"
},
"devDependencies": {
"@makeomatic/deploy": "^10.4.0",
"@types/bluebird": "^3.5.33",
"@types/ioredis": "^4.22.3",
"@types/jest": "^26.0.22",
"@types/jest": "^27.0.2",
"@types/lodash": "^4.14.168",
"@types/node": "^14.14.41",
"@types/pino": "^6.3.7",
"@types/node": "^16.11.7",
"@types/sinon": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"cross-env": "^7.0.3",
"eslint": "^7.24.0",
"eslint": "^8.2.0",
"eslint-config-makeomatic": "^5.0.4",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-promise": "^5.1.0",
"ioredis": "^4.26.0",
"jest": "^26.6.3",
"sinon": "^10.0.0",
"ts-jest": "^26.5.5",
"jest": "^27.3.1",
"sinon": "^12.0.1",
"ts-jest": "^27.0.7",
"typescript": "^4.2.4"
},
"engine": {
Expand Down
15 changes: 7 additions & 8 deletions src/distributed-callback-queue.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Bluebird = require('bluebird')
import redislock = require('@microfleet/ioredis-lock')
import Redis = require('ioredis')
import pino = require('pino')
import { pino } from 'pino'
import assert = require('assert')
import readPkg = require('read-pkg-up')

Expand All @@ -15,15 +15,14 @@ import compose = require('lodash/fp/compose')
import * as callbackQueue from './callback-queue'
import { Semaphore } from './semaphore'
import { MultiLock, MultiLockError } from './multi-lock'
import P = require('pino')
import { Thunk } from '@microfleet/callback-queue'

const { LockAcquisitionError } = redislock
const isBoolean = filter<string>(Boolean)
const toFlattenedTruthyArray = compose(isBoolean, flatten)
const couldNotAcquireLockError = new LockAcquisitionError('job is already running')
const TimeoutError = new Bluebird.TimeoutError('queue-no-response')
const notLockAcquisitionError = (e: Error) => e.name !== 'LockAcquisitionError'
const notLockAcquisitionError = (e: unknown): e is Error => e instanceof Error && e.name !== 'LockAcquisitionError'
const isTimeoutError = (e: unknown): e is typeof TimeoutError => e === TimeoutError
const pkg = readPkg.sync()?.packageJson

Expand All @@ -32,7 +31,7 @@ export interface Config {
pubsub: Redis.Redis | Redis.Cluster
pubsubChannel: string
lock: Partial<redislock.Config>
log: P.Logger | boolean
log: pino.Logger | boolean
lockPrefix: string
debug: boolean
name: string
Expand Down Expand Up @@ -66,7 +65,7 @@ function hasProp<K extends PropertyKey>(data: object, prop: K): data is Record<K
* @param lockPrefix - used for creating locks in redis
*/
export class DistributedCallbackQueue {
public readonly logger: P.Logger
public readonly logger: pino.Logger
private readonly lockPrefix: string
private readonly client: Config['client']
private readonly pubsub: Config['pubsub']
Expand Down Expand Up @@ -108,7 +107,7 @@ export class DistributedCallbackQueue {
this.logger.info('Initialized...')
}

static isCompatibleLogger(logger: unknown): logger is P.Logger {
static isCompatibleLogger(logger: unknown): logger is pino.Logger {
if (typeof logger !== 'object' || logger == null) {
return false
}
Expand All @@ -122,7 +121,7 @@ export class DistributedCallbackQueue {
return true
}

static initLogger(options: Partial<Pick<Config, 'log' | 'debug' | 'name'>>): P.Logger {
static initLogger(options: Partial<Pick<Config, 'log' | 'debug' | 'name'>>): pino.Logger {
const { log: logger, debug, name } = options
const loggerEnabled = typeof logger === 'undefined' ? !!debug : logger

Expand Down Expand Up @@ -198,7 +197,7 @@ export class DistributedCallbackQueue {
try {
await lock.acquire(lockRedisKey)
return this.createWorker(lockRedisKey, lock)
} catch (e) {
} catch (e: unknown) {
if (notLockAcquisitionError(e)) {
// this is an abnormal error, need to post it and cancel requests
// so that they dont hang
Expand Down
Loading

0 comments on commit 1b6376f

Please sign in to comment.