Skip to content

Commit

Permalink
rename previousEvent to currentWorkerName
Browse files Browse the repository at this point in the history
  • Loading branch information
podviaznikov committed Sep 29, 2016
1 parent 58e56e1 commit 1975053
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/rabbitmq.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ class RabbitMQ {
headers: {}
}
const ns = getNamespace('ponos')
jobMeta.headers.previousEvent = ns && ns.get('previousEvent')
jobMeta.headers.previousEvent = ns && ns.get('currentWorkerName')
// add tid to message if one does not exist
if (!content.tid) {
const tid = ns && ns.get('tid')
Expand Down
2 changes: 1 addition & 1 deletion src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class Worker {
return Promise.fromCallback((cb) => {
cls.run(() => {
cls.set('tid', this.tid)
cls.set('previousEvent', this.queue)
cls.set('currentWorkerName', this.queue)
Promise.try(() => {
this.log.info({
attempt: this.attempt++,
Expand Down
4 changes: 2 additions & 2 deletions test/functional/fixtures/worker-tid.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const testClsData = (step) => {
if (typeof getNamespace('ponos').get('tid') !== 'string') {
throw new Error('tid not found after Promise.' + step)
}
if (getNamespace('ponos').get('previousEvent') !== 'ponos-test:one') {
throw new Error('previousEvent not found after Promise.' + step)
if (getNamespace('ponos').get('currentWorkerName') !== 'ponos-test:one') {
throw new Error('currentWorkerName not found after Promise.' + step)
}
}

Expand Down
4 changes: 2 additions & 2 deletions test/unit/rabbitmq.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,13 +747,13 @@ describe('rabbitmq', () => {
})
})

it('should use previousEvent if in namespace', () => {
it('should use currentWorkerName if in namespace', () => {
const testEvent = 'app.started'
const ns = cls.createNamespace('ponos')

return Promise.fromCallback((cb) => {
ns.run(() => {
ns.set('previousEvent', testEvent)
ns.set('currentWorkerName', testEvent)
const payload = RabbitMQ.buildPayload({})
assert.isString(payload.jobMeta.headers.previousEvent, testEvent)
cb()
Expand Down

0 comments on commit 1975053

Please sign in to comment.