Created
May 27, 2015 11:26
-
-
Save zergood/53977efd500985a34ea1 to your computer and use it in GitHub Desktop.
Akka http sample for benchmarking
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
trait Core { | |
implicit val system: ActorSystem = ActorSystem("Suggestion") | |
implicit val materializer: ActorFlowMaterializer = ActorFlowMaterializer() | |
implicit val ec: ExecutionContext = system.dispatcher | |
} | |
object AkkaHttpStarter extends App{ | |
val http = new VanilaHttp with Core{ | |
override def config: Config = ConfigFactory.load() | |
} | |
http.start() | |
} | |
trait AkkaHttp { | |
this: Core => | |
def config: Config | |
def start() = { | |
val route: Route = { | |
path("dictionaries" / Segment / "suggestions"){ dictionaryId => | |
get{ | |
parameters("ngr"){ ngr => | |
complete("response") | |
} | |
} | |
} | |
} | |
Http().bind( | |
interface = config.getString("frontend.interface"), | |
port = config.getInt("frontend.port") | |
).to(Sink.foreach { conn => | |
conn.flow.join(route).run() | |
}).run() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment