dtoubelis / sails-cassandra

Cassanda database adapter for Sails.js
MIT License
26 stars 11 forks source link

ContactPoints configuration parameter does not accept multiple IP addresses #34

Closed vazarely closed 8 years ago

vazarely commented 8 years ago

Hi,

I'm using sails-cassandra to connect sailsjs server to cassandra cluster. I'm also using MongoDB to store some parts of the data. In cloud, this configuration runs in Heroku. in config/connections.js, I have used the one-IP-address configuration for one contactPoints value succesfully: In local: cassandraLocal: { module : 'sails-cassandra', user : 'mylocaluser', password : 'mypasswd', contactPoints : [ '127.0.0.1' ], keyspace : 'mydb' }

...and in Heroku: cassandraCloud: { module : 'sails-cassandra', user : 'myclouduser', password : 'mypasswd', contactPoints : [ process.env.CONTACT_POINTS ], keyspace : 'mydb' } ...in which process.env.CONTACT_POINTS has only one IP address e.g. 10.11.12.13

Now, when I try to list all the Cassandra cluster's node IP addresses in process.env.CONTACT_POINTS (e.g. 10.11.12.13, 10.11.12.14, 10.11.12.15), I get an error that DB server cannot be reached and Heroku sails server crashes.

I have tried different combinations of listing multiple IP addresses without luck. e.g. 10.11.12.13, 10.11.12.14, 10.11.12.15 "10.11.12.13", "10.11.12.14", "10.11.12.15" '10.11.12.13', '10.11.12.14', '10.11.12.15'

Do you know what might be the problem and how to fix it?

dtoubelis commented 8 years ago

I don't think you can specify multiple addresses in one environment variable, however, you could do something like this:

CONTACT_POINTS="10.11.12.13 10.11.12.14 10.11.12.15"

and then in the config file:

...
contactPoints: process.env.CONTACT_POINTS.split(/\s+/)
...
vazarely commented 8 years ago

Looks like this approach works both in local and in Heroku. At least the server starts OK. Thank you so much!

Final thing I have is to figure out if sailsjs Heroku process can really use those IP addresses i.e. if the first IP is not responsing it uses the second one, and so on. => Do you know how to check to which Cassandra IP address sailsjs/waterline process is connected?

A side topic: Do you have any plans to update sails-cassandra's cassandra-driver dependency from 2.0.0 to new 3.x? What benefits do you see in potential update?

dtoubelis commented 8 years ago

I pass contactPoints directly to the driver and it is up to the driver to handle reconnects. There may be some extra info in the documentation for the driver but from sails/waterline standpoint this process is obscure.

I know that cassandra driver dependency is relatively old, but since the new version is a major release I suspect that it may require code update as well as changes to the documentation. I will do it eventually when I have a bit of time ;-)

vazarely commented 8 years ago

OK, thanks.