Created
November 30, 2015 23:14
-
-
Save AlexFrazer/6e64ae86d2b279f12160 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
socket.on('close', Meteor.bindEnvironment(hasError => { | |
let retries = this.collection.findOne({ name: this.name }).connection.retryCount; | |
if (retries < this.config.maxRetries) { | |
Meteor.setTimeout(() => { | |
this.collection.update({ name: this.name }, { | |
$set: { | |
'connection.status': 'connecting', | |
'connection.retryTime': new Date | |
}, | |
$inc: { 'connection.retryCount': 1 } | |
}); | |
super.connect(...args); | |
}, this.config.retryInterval); | |
} else { | |
this.removeAllListeners(); | |
this.collection.update({ name: this.name }, { | |
$set: { | |
'connection.status': 'failed', | |
'connection.reason': 'Max retries exceeded' | |
} | |
}); | |
this.end(); | |
} | |
})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment