Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bridge Netty and Finagle
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
You can’t perform that action at this time.