meteorhacks / cluster

Clustering solution for Meteor with load balancing and service discovery
https://meteorhacks.com/cluster-a-different-kind-of-load-balancer-for-meteor.html
MIT License
632 stars 80 forks source link

Cluster does not work on Galaxy #111

Open guns2410 opened 8 years ago

guns2410 commented 8 years ago

I have observed that meteorhacks:cluster does not work on galaxy dev edition (and also with the production version). I have an application running 7 different micro-services powering a single application. I have been working on making the servers talk to each other over DDP using cluster and it was preety easy on AWS and Digital Ocean.

I wish apart from Loadbalancing, Cluster could be used on Galaxy for DDP connections.

DDPConnector = function (url, options = {}) {
    this.url = url;
    this.ddpOptions = options.ddpOptions || {};
    this.timeout = options.timeout || 5 * 1000;

    this.connection = DDP.connect(this.url, this.ddpOptions);
    this.connection.disconnect();
    this.startConnecting();
}

DDPConnector.prototype.getConnection = function () {
    return this.connection;
}

DDPConnector.prototype.getUrl = function () {
    return this.url;
}

DDPConnector.prototype.startConnecting = function () {
    var self = this;
    var connected = false;
    setConnectionIfNeeded();

    this.timeoutHandler = Meteor.setInterval(setConnectionIfNeeded, self.timeout);

    function setConnectionIfNeeded () {
        var status = self.connection.status();
        var isOffline = connected && status.status == "offline";
        if (!status.connected && !isOffline) {
            self.connection.reconnect({ url: self.url });
            connected = true;
        }
    }
}

DDPConnector.prototype.stop = function () {
    Meteor.clearTimeout(this.timeoutHandler);
}

This is what i have incorporated temporarily removing Cluster. I know this code would be buggy but i really hope that we have meteorhacks:cluster work on Galaxy..