Created
February 10, 2014 18:04
Revisions
-
caniszczyk created this gist
Feb 10, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ case class Netty3Listener[In, Out]( pipelineFactory: ChannelPipelineFactory, channelFactory: ServerChannelFactory bootstrapOptions: Map[String, Object], ... // stats/timeouts/ssl config ) extends Listener[In, Out] { def newServerPipelineFactory( statsReceiver: StatsReceiver, newBridge: () => ChannelHandler ) = new ChannelPipelineFactory { // #1 def getPipeline() = { val pipeline = pipelineFactory.getPipeline() // ... add stats/timeouts/ssl pipeline.addLast("finagleBridge", newBridge()) // #2 pipeline } } def listen(addr: SocketAddress)( serveTransport: Transport[In, Out] => Unit ): ListeningServer = new ListeningServer with CloseAwaitably { val newBridge = () => new ServerBridge(serveTransport, ...) val bootstrap = new ServerBootstrap(channelFactory) bootstrap.setOptions(bootstrapOptions.asJava) bootstrap.setPipelineFactory( newServerPipelineFactory(scopedStatsReceiver, newBridge)) val ch = bootstrap.bind(addr) } } } // #1 Create a new ChannelPipelineFactory // #2 Add the Bridge into the ChannelPipeline