Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pubsub: refactor subscription connection #2627

Merged
merged 7 commits into from
Oct 2, 2017
Merged

pubsub: refactor subscription connection #2627

merged 7 commits into from
Oct 2, 2017

Conversation

callmehiphop
Copy link
Contributor

Relates to #2621, #2619, #2598, #2572

Copy link
Contributor

@stephenplusplus stephenplusplus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small stuff and questions.

@@ -32,6 +32,9 @@ var uuid = require('uuid');
var PKG = require('../package.json');
var v1 = require('./v1');

var CHANNEL_READY = 'channel.ready';

This comment was marked as spam.

This comment was marked as spam.

connection.pause();
}

self.once(CHANNEL_ERROR, function(err) {

This comment was marked as spam.

This comment was marked as spam.

}

var elapsedTimeWithoutConnection = 0;
var deadline, timeout;

This comment was marked as spam.

This comment was marked as spam.

*/
ConnectionPool.prototype.waitForReady = function() {
var self = this;
var READY = 2;

This comment was marked as spam.

This comment was marked as spam.

/**
*
*/
ConnectionPool.prototype.watchForReady = function() {

This comment was marked as spam.

This comment was marked as spam.


this.on('newListener', function(eventName) {
if (eventName == CHANNEL_READY && !self.waiting) {
clearImmediate(self.waitHandle);

This comment was marked as spam.

This comment was marked as spam.

this.isOpen = false;
this.waiting = false;

this.removeAllListeners('newListener')

This comment was marked as spam.

This comment was marked as spam.

});

self.once(CHANNEL_READY, function() {
connection.isConnected = true;

This comment was marked as spam.

This comment was marked as spam.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 728575b on callmehiphop:dg--pubsub-stream-refactor into 42eef91 on GoogleCloudPlatform:master.

@callmehiphop
Copy link
Contributor Author

@stephenplusplus I think this is ready for another look through.

@@ -59,6 +59,7 @@
"google-auto-auth": "^0.7.1",
"google-gax": "^0.13.0",
"google-proto-files": "^0.12.0",
"grpc": "^1.6.0",

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

pool.createConnection();
pool.emit(channelErrorEvent);

assert.strictEqual(fakeConnection.canceled, true);

This comment was marked as spam.

This comment was marked as spam.

pool.getClient = function(callback) {
callback(fakeError);

assert.strictEqual(pool.isGettingChannelState, false);

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

getChannel: function() {
return {
getConnectivityState: function(shouldConnect) {
assert.strictEqual(shouldConnect, false);

This comment was marked as spam.

This comment was marked as spam.

elapsedTimeWithoutConnection = now - self.noConnectionsTime;
}

deadline = now + (300000 - elapsedTimeWithoutConnection);

This comment was marked as spam.

This comment was marked as spam.

@@ -520,6 +523,9 @@ Subscription.prototype.exists = function(callback) {
Subscription.prototype.flushQueues_ = function() {
var self = this;

clearTimeout(this.flushTimeoutHandle_);

This comment was marked as spam.

This comment was marked as spam.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 8f88c29 on callmehiphop:dg--pubsub-stream-refactor into 42eef91 on GoogleCloudPlatform:master.

@callmehiphop
Copy link
Contributor Author

@stephenplusplus this should be good to go btw!

@ApeNox
Copy link

ApeNox commented Oct 2, 2017

Could this be merged ? seems it fixes the issue with acked messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the Pub/Sub API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants