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

[feature/config] remove port option for better usability #457

Merged
merged 1 commit into from Aug 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 3 additions & 5 deletions Makefile
Expand Up @@ -54,19 +54,17 @@ test:
@busted -v spec/unit

test-integration:
@busted spec/integration
@busted -v spec/integration

test-plugins:
@busted spec/plugins
@busted -v spec/plugins

test-all:
@busted spec/
@busted -v spec/

coverage:
@rm -f luacov.*
@busted --coverage spec/
@luacov -c spec/.luacov
@tail -n 1 luacov.report.out | awk '{ print $$3 }'

test-all:
@busted -v spec/
4 changes: 2 additions & 2 deletions kong.yml
Expand Up @@ -35,8 +35,8 @@ database: cassandra
databases_available:
cassandra:
properties:
hosts: "localhost"
port: 9042
hosts:
- "localhost:9042"
timeout: 1000
keyspace: kong
keepalive: 60000 # in milliseconds
Expand Down
2 changes: 1 addition & 1 deletion kong/dao/cassandra/base_dao.lua
Expand Up @@ -67,7 +67,7 @@ function BaseDao:_open_session(keyspace)

local options = self._factory:get_session_options()

ok, err = session:connect(self._properties.hosts, self._properties.port, options)
ok, err = session:connect(self._properties.hosts, nil, options)
if not ok then
return nil, DaoError(err, error_types.DATABASE)
end
Expand Down
4 changes: 2 additions & 2 deletions kong/dao/cassandra/factory.lua
Expand Up @@ -108,7 +108,7 @@ function CassandraFactory:prepare()

local options = self:get_session_options()

local ok, co_err = session:connect(self._properties.hosts, self._properties.port, options)
local ok, co_err = session:connect(self._properties.hosts, nil, options)
session:close()

if not ok then
Expand Down Expand Up @@ -137,7 +137,7 @@ function CassandraFactory:execute_queries(queries, no_keyspace)

local options = self:get_session_options()

ok, err = session:connect(self._properties.hosts, self._properties.port, options)
ok, err = session:connect(self._properties.hosts, nil, options)
if not ok then
return DaoError(err, constants.DATABASE_ERROR_TYPES.DATABASE)
end
Expand Down
4 changes: 2 additions & 2 deletions spec/integration/dao/cassandra/base_dao_spec.lua
Expand Up @@ -48,7 +48,7 @@ describe("Cassandra", function()
session = cassandra:new()
session:set_timeout(configuration.cassandra.timeout)

local _, err = session:connect(configuration.cassandra.hosts, configuration.cassandra.port)
local _, err = session:connect(configuration.cassandra.hosts)
assert.falsy(err)

local _, err = session:set_keyspace("kong_tests")
Expand Down Expand Up @@ -709,4 +709,4 @@ describe("Cassandra", function()

end) -- describe plugins configurations
end) -- describe Base DAO
end) -- describe Cassandra
end) -- describe Cassandra
3 changes: 1 addition & 2 deletions spec/integration/dao/cassandra/factory_spec.lua
Expand Up @@ -8,8 +8,7 @@ configuration.cassandra = configuration.databases_available[configuration.databa
describe(":prepare()", function()

it("should return an error if cannot connect to Cassandra", function()
local new_factory = CassandraFactory({ hosts = "127.0.0.1",
port = 45678,
local new_factory = CassandraFactory({ hosts = "127.0.0.1:45678",
timeout = 1000,
keyspace = configuration.cassandra.keyspace
})
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/statics_spec.lua
Expand Up @@ -75,8 +75,8 @@ database: cassandra
databases_available:
cassandra:
properties:
hosts: "localhost"
port: 9042
hosts:
- "localhost:9042"
timeout: 1000
keyspace: kong
keepalive: 60000 # in milliseconds
Expand Down