Skip to content

Commit

Permalink
Merge pull request #27 from recurly/headers
Browse files Browse the repository at this point in the history
Added headers to packet
  • Loading branch information
cbarton authored Feb 28, 2022
2 parents 45e33f2 + 91ea0a2 commit 78cf73d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ starsky.once('connect', function () {
console.log('body: %j', msg.body);
console.log('timestamp: %s', msg.timestamp);
console.log('topic: %s', msg.topic);
console.log('headers %s', msg.headers);
done();
});
});
Expand All @@ -143,13 +144,15 @@ To start processing message, invoke `consumer.process`. This will invoke the fun
- `body`: The actual message published.
- `timestamp`: The time when the message was published.
- `topic`: The topic the message was published with.
- `headers`: The headers associated with the message.

```js
consumer.process(function (msg, done) {
console.log('id: %s', msg.id);
console.log('body: %j', msg.body);
console.log('timestamp: %s', msg.timestamp);
console.log('topic: %s', msg.topic);
console.log('headers %s', msg.headers);
done();
});
```
Expand Down
3 changes: 2 additions & 1 deletion lib/consumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ Consumer.prototype.onMessage = function (callback) {
id: info.messageId,
body: body,
timestamp: info.timestamp,
topic: msg.routingKey
topic: msg.routingKey,
headers: headers
};

// keep track of packets in-process, see quit()
Expand Down
1 change: 1 addition & 0 deletions test/consumer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('Consumer', function () {
msg.should.have.property('timestamp');
msg.should.have.property('topic', 'foo.bar');
msg.body.should.have.property('hello', 'world');
msg.should.have.property('headers');
next();
done();
});
Expand Down

0 comments on commit 78cf73d

Please sign in to comment.