Skip to content

Commit 4485bc8

Browse files
committed
Use built-in ChannelInitializer to build pipeline when Channel is registered
1 parent d33c76d commit 4485bc8

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

src/aleph/netty.clj

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
ChannelHandler FileRegion
2222
ChannelInboundHandler
2323
ChannelOutboundHandler
24-
ChannelHandlerContext]
24+
ChannelHandlerContext
25+
ChannelInitializer]
2526
[io.netty.channel.epoll Epoll EpollEventLoopGroup
2627
EpollServerSocketChannel
2728
EpollSocketChannel]
@@ -627,18 +628,9 @@
627628
(.write ctx msg promise)))))
628629

629630
(defn pipeline-initializer [pipeline-builder]
630-
(channel-inbound-handler
631-
632-
:channel-registered
633-
([this ctx]
634-
(let [pipeline (.pipeline ctx)]
635-
(try
636-
(.remove pipeline this)
637-
(pipeline-builder pipeline)
638-
(.fireChannelRegistered ctx)
639-
(catch Throwable e
640-
(log/warn e "Failed to initialize channel")
641-
(.close ctx)))))))
631+
(proxy [ChannelInitializer] []
632+
(initChannel [^Channel ch]
633+
(pipeline-builder ^ChannelPipeline (.pipeline ch)))))
642634

643635
(defn instrument!
644636
[stream]

0 commit comments

Comments
 (0)