Skip to content

Commit

Permalink
feat(config) implement a C* timeout property
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaultcha committed Feb 3, 2016
1 parent b94439d commit d9fbe01
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
4 changes: 4 additions & 0 deletions kong.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
## Name of the keyspace used by Kong. Will be created if it does not exist.
# keyspace: kong

#####
## Connection and reading timeout (in ms).
# timeout: 5000

######
## Keyspace options. Set those before running Kong or any migration.
## Those settings will be used to create a keyspace with the desired options
Expand Down
6 changes: 4 additions & 2 deletions kong/dao/cassandra/factory.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,10 @@ function CassandraFactory:get_session_options()
query_options = {
prepare = true
},
username = self.properties.username,
password = self.properties.password,
socket_options = {
connect_timeout = self.properties.timeout,
read_timeout = self.properties.timeout
},
ssl_options = {
enabled = self.properties.ssl.enabled,
verify = self.properties.ssl.verify,
Expand Down
1 change: 1 addition & 0 deletions kong/tools/config_defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ return {
content = {
["contact_points"] = {type = "array", default = {"127.0.0.1:9042"}},
["keyspace"] = {type = "string", default = "kong"},
["timeout"] = {type = "number", default = 5000},
["replication_strategy"] = {type = "string", default = "SimpleStrategy", enum = {"SimpleStrategy", "NetworkTopologyStrategy"}},
["replication_factor"] = {type = "number", default = 1},
["data_centers"] = {type = "table", default = {}},
Expand Down
24 changes: 22 additions & 2 deletions spec/unit/dao/cassandra/factory_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local Factory = require "kong.dao.cassandra.factory"
local utils = require "kong.tools.utils"
local cassandra = require "cassandra"
local spec_helpers = require "spec.spec_helpers"
local env = spec_helpers.get_env()
local default_dao_properties = env.configuration.cassandra
Expand All @@ -24,6 +25,10 @@ describe("Cassadra factory", function()
query_options = {
prepare = true
},
socket_options = {
connect_timeout = 5000,
read_timeout = 5000
},
ssl_options = {
enabled = false,
verify = false
Expand All @@ -46,6 +51,10 @@ describe("Cassadra factory", function()
query_options = {
prepare = true
},
socket_options = {
connect_timeout = 5000,
read_timeout = 5000
},
ssl_options = {
enabled = false,
verify = false
Expand All @@ -68,12 +77,15 @@ describe("Cassadra factory", function()
query_options = {
prepare = true
},
socket_options = {
connect_timeout = 5000,
read_timeout = 5000
},
ssl_options = {
enabled = false,
verify = false
},
username = "cassie",
password = "cassiepwd"
auth = cassandra.auth.PlainTextProvider("cassie", "cassiepwd")
}, options)
end)
it("should accept SSL properties", function()
Expand All @@ -93,6 +105,10 @@ describe("Cassadra factory", function()
query_options = {
prepare = true
},
socket_options = {
connect_timeout = 5000,
read_timeout = 5000
},
ssl_options = {
enabled = false,
verify = true
Expand All @@ -113,6 +129,10 @@ describe("Cassadra factory", function()
query_options = {
prepare = true
},
socket_options = {
connect_timeout = 5000,
read_timeout = 5000
},
ssl_options = {
enabled = true,
verify = true
Expand Down

0 comments on commit d9fbe01

Please sign in to comment.