aboutsummaryrefslogtreecommitdiff
path: root/kamon-playground
diff options
context:
space:
mode:
authorDiego Parra <diegolparra@gmail.com>2013-11-26 15:54:10 -0300
committerDiego Parra <diegolparra@gmail.com>2013-11-26 15:54:10 -0300
commit5e0b032bfef9509e64af2960452aed44b6e6cb22 (patch)
tree464573c5093b966eaddc65b52244bb1b50c03857 /kamon-playground
parentdad8547a63d65a5b929346310d53ba2ab45d615c (diff)
downloadKamon-5e0b032bfef9509e64af2960452aed44b6e6cb22.tar.gz
Kamon-5e0b032bfef9509e64af2960452aed44b6e6cb22.tar.bz2
Kamon-5e0b032bfef9509e64af2960452aed44b6e6cb22.zip
added scalariform
Diffstat (limited to 'kamon-playground')
-rw-r--r--kamon-playground/src/main/scala/test/SimpleRequestProcessor.scala71
1 files changed, 34 insertions, 37 deletions
diff --git a/kamon-playground/src/main/scala/test/SimpleRequestProcessor.scala b/kamon-playground/src/main/scala/test/SimpleRequestProcessor.scala
index 7cdfae73..1c1dba4f 100644
--- a/kamon-playground/src/main/scala/test/SimpleRequestProcessor.scala
+++ b/kamon-playground/src/main/scala/test/SimpleRequestProcessor.scala
@@ -19,7 +19,7 @@ import akka.actor._
import spray.routing.SimpleRoutingApp
import akka.util.Timeout
import spray.httpx.RequestBuilding
-import scala.concurrent.{Await, Future}
+import scala.concurrent.{ Await, Future }
import kamon.spray.UowDirectives
import kamon.trace.Trace
import kamon.Kamon
@@ -34,7 +34,7 @@ object SimpleRequestProcessor extends App with SimpleRoutingApp with RequestBuil
import system.dispatcher
val act = system.actorOf(Props(new Actor {
- def receive: Actor.Receive = { case any => sender ! any }
+ def receive: Actor.Receive = { case any ⇒ sender ! any }
}), "com")
implicit val timeout = Timeout(30 seconds)
@@ -44,42 +44,42 @@ object SimpleRequestProcessor extends App with SimpleRoutingApp with RequestBuil
val random = new Random()
startServer(interface = "localhost", port = 9090) {
get {
- path("test"){
+ path("test") {
uow {
complete {
- val futures = pipeline(Get("http://10.254.209.14:8000/")).map(r => "Ok") :: pipeline(Get("http://10.254.209.14:8000/")).map(r => "Ok") :: Nil
+ val futures = pipeline(Get("http://10.254.209.14:8000/")).map(r ⇒ "Ok") :: pipeline(Get("http://10.254.209.14:8000/")).map(r ⇒ "Ok") :: Nil
- Future.sequence(futures).map(l => "Ok")
+ Future.sequence(futures).map(l ⇒ "Ok")
}
}
} ~
- path("reply" / Segment) { reqID =>
- uow {
+ path("reply" / Segment) { reqID ⇒
+ uow {
+ complete {
+ if (Trace.context().isEmpty)
+ println("ROUTE NO CONTEXT")
+
+ (replier ? reqID).mapTo[String]
+ }
+ }
+ } ~
+ path("ok") {
complete {
- if (Trace.context().isEmpty)
- println("ROUTE NO CONTEXT")
-
- (replier ? reqID).mapTo[String]
+ //Thread.sleep(random.nextInt(1) + random.nextInt(5) + random.nextInt(2))
+ "ok"
+ }
+ } ~
+ path("future") {
+ dynamic {
+ complete(Future { "OK" })
+ }
+ } ~
+ path("error") {
+ complete {
+ throw new NullPointerException
+ "okk"
}
}
- } ~
- path("ok") {
- complete{
- //Thread.sleep(random.nextInt(1) + random.nextInt(5) + random.nextInt(2))
- "ok"
- }
- } ~
- path("future") {
- dynamic {
- complete(Future { "OK" })
- }
- } ~
- path("error") {
- complete {
- throw new NullPointerException
- "okk"
- }
- }
}
}
@@ -98,21 +98,18 @@ object Verifier extends App {
val pipeline = sendReceive
- val futures = Future.sequence(for(i <- 1 to 500) yield {
- pipeline(Get("http://127.0.0.1:9090/reply/"+i)).map(r => r.entity.asString == i.toString)
+ val futures = Future.sequence(for (i ← 1 to 500) yield {
+ pipeline(Get("http://127.0.0.1:9090/reply/" + i)).map(r ⇒ r.entity.asString == i.toString)
})
- println("Everything is: "+ Await.result(futures, 10 seconds).forall(a => a == true))
+ println("Everything is: " + Await.result(futures, 10 seconds).forall(a ⇒ a == true))
}
-
-
-
}
class Replier extends Actor with ActorLogging {
def receive = {
- case anything =>
- if(Trace.context.isEmpty)
+ case anything ⇒
+ if (Trace.context.isEmpty)
log.warning("PROCESSING A MESSAGE WITHOUT CONTEXT")
log.info("Processing at the Replier")