8000 PostgreSQLConnectionFactory - allow to configure the execution context · odd/postgresql-async@a75e939 · GitHub
[go: up one dir, main page]

Skip to content

Commit a75e939

Browse files
committed
PostgreSQLConnectionFactory - allow to configure the execution context
1 parent 80e054f commit a75e939

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

postgresql-async/src/main/scala/com/github/mauricio/async/db/postgresql/pool/PostgreSQLConnectionFactory.scala

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ import scala.concurrent.Await
2525
import scala.concurrent.duration._
2626
import scala.language.postfixOps
2727
import scala.util.{Success, Failure, Try}
28+
import scala.concurrent.ExecutionContext
29+
import com.github.mauricio.async.db.util.ExecutorServiceUtils
30+
import com.github.mauricio.async.db.util.NettyUtils
31+
import io.netty.channel.EventLoopGroup
2832

2933
object PostgreSQLConnectionFactory {
3034
val log = Log.get[PostgreSQLConnectionFactory]
@@ -37,12 +41,15 @@ object PostgreSQLConnectionFactory {
3741
* @param configuration
3842
*/
3943

40-
class PostgreSQLConnectionFactory( val configuration : Configuration ) extends ObjectFactory[PostgreSQLConnection] {
44+
class PostgreSQLConnectionFactory(
45+
val configuration : Configuration,
46+
group : EventLoopGroup = NettyUtils.DefaultEventLoopGroup,
47+
executionContext : ExecutionContext = ExecutorServiceUtils.CachedExecutionContext ) extends ObjectFactory[PostgreSQLConnection] {
4148

4249
import PostgreSQLConnectionFactory.log
4350

4451
def create: PostgreSQLConnection = {
45-
val connection = new PostgreSQLConnection(configuration)
52+
val connection = new PostgreSQLConnection(configuration, group = group, executionContext = executionContext)
4653
Await.result(connection.connect, 5.seconds)
4754

4855
connection

0 commit comments

Comments
 (0)
0