Created
February 10, 2014 18:06
-
-
Save caniszczyk/8921074 to your computer and use it in GitHub Desktop.
Bridge Netty and Finagle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ServerBridge[In, Out]( | |
serveTransport: Transport[In, Out] => Unit, | |
) extends SimpleChannelHandler { | |
override def channelOpen( | |
ctx: ChannelHandlerContext, | |
e: ChannelStateEvent | |
){ | |
val channel = e.getChannel | |
val transport = new ChannelTransport[In, Out](channel) // #1 | |
serveTransport(transport) | |
super.channelOpen(ctx, e) | |
} | |
override def exceptionCaught( | |
ctx: ChannelHandlerContext, | |
e: ExceptionEvent | |
) { // log exception and close channel } | |
} | |
// #1 Is called once a new Channel was open and create a new ChannelTransport to bridge to Finagle | |
// see https://github.com/twitter/finagle/blob/master/finagle-core/src/main/scala/com/twitter/finagle/netty3/server.scala |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment