Skip to content
This repository was archived by the owner on Dec 3, 2019. It is now read-only.

Connection factory timeouts #90

Merged
merged 1 commit into from
May 10, 2014
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import scala.{None, Option, Int}
import io.netty.util.CharsetUtil
import io.netty.buffer.AbstractByteBufAllocator
import io.netty.buffer.PooledByteBufAllocator
import scala.concurrent.duration._

object Configuration {
val DefaultCharset = CharsetUtil.UTF_8
Expand Down Expand Up @@ -52,5 +53,7 @@ case class Configuration(username: String,
database: Option[String] = None,
charset: Charset = Configuration.DefaultCharset,
maximumMessageSize: Int = 16777216,
allocator: AbstractByteBufAllocator = PooledByteBufAllocator.DEFAULT
allocator: AbstractByteBufAllocator = PooledByteBufAllocator.DEFAULT,
connectTimeout: Duration = 5.seconds,
testTimeout: Duration = 5.seconds
)
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class MySQLConnectionFactory( configuration : Configuration ) extends ObjectFact
*/
def create: MySQLConnection = {
val connection = new MySQLConnection(configuration)
Await.result(connection.connect, 5.seconds )
Await.result(connection.connect, configuration.connectTimeout )

connection
}
Expand Down Expand Up @@ -121,7 +121,7 @@ class MySQLConnectionFactory( configuration : Configuration ) extends ObjectFact
*/
override def test(item: MySQLConnection): Try[MySQLConnection] = {
Try {
Await.result(item.sendQuery("SELECT 0"), 5.seconds)
Await.result(item.sendQuery("SELECT 0"), configuration.testTimeout)
item
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class PostgreSQLConnectionFactory(

def create: PostgreSQLConnection = {
val connection = new PostgreSQLConnection(configuration, group = group, executionContext = executionContext)
Await.result(connection.connect, 5.seconds)
Await.result(connection.connect, configuration.connectTimeout)

connection
}
Expand Down Expand Up @@ -87,7 +87,7 @@ class PostgreSQLConnectionFactory(

override def test(item: PostgreSQLConnection): Try[PostgreSQLConnection] = {
val result : Try[PostgreSQLConnection] = Try({
Await.result( item.sendQuery("SELECT 0"), 5.seconds )
Await.result( item.sendQuery("SELECT 0"), configuration.testTimeout )
item
})

Expand Down