Skip to content

Commit

Permalink
lib: allow contact points to be a csv
Browse files Browse the repository at this point in the history
if passed via env var, it won't be an array, but likely a csv.
The driver will accept

- [<host>]
- <host>,<host>
- <host>

semver: patch
  • Loading branch information
esatterwhite committed Feb 26, 2018
1 parent 96e8645 commit d869bca
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,13 @@ ScyllaDown.prototype._open = function _open(opts = {}, cb) {
, replicas = 1
} = opts

debug('contact points: ', contactPoints)
const hosts = toArray(contactPoints)
debug('contact points: ', hosts)
debug('keyspace', keyspace)
debug('replicas', replicas)

this.client = new Client({
contactPoints: contactPoints
contactPoints: hosts
})

this.keyspace = keyspace
Expand Down Expand Up @@ -243,6 +244,12 @@ ScyllaDown.prototype._table = function _table(cb) {
this.client.execute(query, cb)
}

function toArray(item) {
if (!item) return []
if (Array.isArray(item)) return item
return typeof item === 'string' ? item.split(CSV_SEP) : [item]
}

/**
* Represents a single operations inside of a batch
* @typedef {Object} Operation
Expand Down

0 comments on commit d869bca

Please sign in to comment.