Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Options to use when creating pool, defaults match those used by node-pool.
- `min_connections` - Default: `0` - Min number of connections to keep open at any given time
- `idle_timeout` - Default: `30000` - Time (ms) to wait until closing idle connections
- `ttl` - Default: `undefined` - Time (+/-50%) (ms) past which to destroy the connection. For more explanation, see below
- `ssl` - Default: `false` - Whether to use SSL/TLS

### ttl

Expand Down
9 changes: 8 additions & 1 deletion lib/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@ CLOSE_MESSAGE = "Thrift-pool: Connection closed"
# @param thrift_options, passed to thrift connection,
create_cb = (thrift, pool_options, thrift_options, cb) ->
cb = _.once cb
connection = thrift.createConnection pool_options.host, pool_options.port, thrift_options

pool_options.ssl ?= false
if pool_options.ssl
connection = thrift.createSSLConnection pool_options.host, pool_options.port, thrift_options
else
connection = thrift.createConnection pool_options.host, pool_options.port, thrift_options

connection.__ended = false
if pool_options.ttl?
connection.__reap_time = Date.now() + _.random (pool_options.ttl / 2), (pool_options.ttl * 1.5)

connection.on "connect", ->
debug "in connect callback"
connection.connection.setKeepAlive(true)
Expand Down