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
3 changes: 3 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ Anand Suresh
Brett Bergmann
Jesse Friedman
Zach Bjornson <zbbjornson@gmail.com>

Greta.io
Dennis Mårtensson <dennis@greta.io>

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Ben Stahl <bhstahl@gmail.com>
Brett Bergmann <me@brettbergmann.com>
Burcu Dogan <jbd@google.com>
Cristian Almstrand <cristian.almstrand@gmail.com>
Dennis Mårtensson <dennis@greta.io>
Gor Martsen <gor.martsen@gmail.com>
Hector Rovira <hrovira@gmail.com>
Ido Shamun <idoesh1@gmail.com>
Expand Down
7 changes: 7 additions & 0 deletions packages/pubsub/src/topic.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@ Topic.prototype.getSubscriptionsStream = function(options) {
* @param {object=} options - Configuration object.
* @param {boolean} options.raw - Enable if you require setting attributes on
* your messages.
* @param {number} options.timeout - Set a maximum amount of time in
* milliseconds before giving up if no response is received.
* @param {function=} callback - The callback function.
*
* @example
Expand Down Expand Up @@ -435,6 +437,7 @@ Topic.prototype.getSubscriptionsStream = function(options) {
* var messageIds = data[0];
* var apiResponse = data[1];
* });
*
*/
Topic.prototype.publish = function(messages, options, callback) {
messages = arrify(messages);
Expand All @@ -456,6 +459,10 @@ Topic.prototype.publish = function(messages, options, callback) {
method: 'publish',
};

if (is.number(options.timeout)) {
protoOpts.timeout = options.timeout;

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

}

var reqOpts = {
topic: this.name,
messages: messages
Expand Down
13 changes: 13 additions & 0 deletions packages/pubsub/test/topic.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,19 @@ describe('Topic', function() {
topic.publish(message, assert.ifError);
});

it('should honor the timeout setting', function(done) {
var options = {
timeout: 10
};

topic.request = function(protoOpts) {
assert.strictEqual(protoOpts.timeout, options.timeout);
done();
};

topic.publish(message, options, assert.ifError);
});

it('should send correct api request for raw message', function(done) {
topic.request = function(protoOpts, reqOpts) {
assert.deepEqual(reqOpts.messages, [
Expand Down