Skip to content

Commit

Permalink
Fix #58: Do not share netty framing handler among channels
Browse files Browse the repository at this point in the history
  • Loading branch information
povder committed Nov 22, 2016
1 parent eefafc9 commit 9aa9f93
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -768,4 +768,16 @@ object ManyInsertTest extends App {

}

}

object MultiConnTst extends App {

implicit val ec = ExecutionContext.global
implicit val timeout = FiniteDuration.apply(10, "seconds")

val fact = NettyPgConnectionFactory("localhost", 5432, "povder", "povder", "povder")

val f = (1 to 10).map(_ => fact.connection()).reduce((f1, f2) => f1.flatMap(_ => f2))
Await.ready(f, Duration.Inf)
println("conns open")
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class NettyPgConnectionFactory protected(remoteAddr: SocketAddress,
private implicit val actorSystem = ActorSystem("RdbcPgSystem") //TODO unique system name?, TODO configurable system
private implicit val streamMaterializer = ActorMaterializer()

def connection(): Future[PgConnection] = { //TODO important - it looks like you can't have multiple connections at the same time :D
def connection(): Future[PgConnection] = {

var conn: NettyPgConnection = null
//TODO bossGroup, workerGroup - familarize yourself
Expand Down Expand Up @@ -167,7 +167,7 @@ class NettyPgConnectionFactory protected(remoteAddr: SocketAddress,
}
}

private val framingHandler: LengthFieldBasedFrameDecoder = {
private def framingHandler: LengthFieldBasedFrameDecoder = {
val lengthFieldLength = 4
new LengthFieldBasedFrameDecoder(
Int.MaxValue, /* max frame length */
Expand Down

0 comments on commit 9aa9f93

Please sign in to comment.