Created
July 23, 2015 14:04
-
-
Save dpsoft/2fe4b0efe32eaeb3711b to your computer and use it in GitHub Desktop.
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 characters
package kamon.netty.playground.http.helloworld | |
import io.netty.bootstrap.ServerBootstrap | |
import io.netty.channel.ChannelOption | |
import io.netty.channel.nio.NioEventLoopGroup | |
import io.netty.channel.socket.nio.NioServerSocketChannel | |
import io.netty.util.internal.logging.{InternalLoggerFactory, Slf4JLoggerFactory} | |
import kamon.Kamon | |
import kamon.netty.annotation.MetricName | |
import kamon.netty.playground.HttpHelloWorldServerInitializer | |
object HttpHelloWorldServer extends App { | |
Kamon.start() | |
val port = args.headOption.map(_.toInt).getOrElse(8080) | |
InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory()) | |
val bossGroup, workerGroup = new NioEventLoopGroup(20) | |
try { | |
val b = new ServerBootstrap() | |
b.option(ChannelOption.SO_BACKLOG, Int.box(1024)) | |
.group(@MetricName("bla") bossGroup, @MetricName("bla") workerGroup) /////aca se rompe | |
.channel(classOf[NioServerSocketChannel]) | |
.childHandler(new HttpHelloWorldServerInitializer()) | |
val ch = b.bind(port).sync().channel() | |
ch.closeFuture().sync() | |
} finally { | |
bossGroup.shutdownGracefully() | |
workerGroup.shutdownGracefully() | |
Kamon.shutdown() | |
} | |
} |
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 characters
package kamon.netty.annotation; | |
import java.lang.annotation.ElementType; | |
import java.lang.annotation.Retention; | |
import java.lang.annotation.RetentionPolicy; | |
import java.lang.annotation.Target; | |
@Target(ElementType.PARAMETER) | |
@Retention(RetentionPolicy.RUNTIME) | |
public @interface MetricName { | |
String value(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment