diff options
Diffstat (limited to 'kamon-core/src/main/scala/spraytest')
-rw-r--r-- | kamon-core/src/main/scala/spraytest/ClientTest.scala | 55 | ||||
-rw-r--r-- | kamon-core/src/main/scala/spraytest/FutureTesting.scala | 81 |
2 files changed, 0 insertions, 136 deletions
diff --git a/kamon-core/src/main/scala/spraytest/ClientTest.scala b/kamon-core/src/main/scala/spraytest/ClientTest.scala deleted file mode 100644 index 07532d0a..00000000 --- a/kamon-core/src/main/scala/spraytest/ClientTest.scala +++ /dev/null @@ -1,55 +0,0 @@ -package spraytest - -import akka.actor.ActorSystem -import spray.client.pipelining._ -import spray.httpx.SprayJsonSupport -import spray.json._ -import scala.concurrent.Future -import spray.can.Http -import akka.io.IO - -/** - * BEGIN JSON Infrastructure - */ -case class Container(data: List[PointOfInterest]) -case class Geolocation(latitude: Float, longitude: Float) -case class PointOfInterest(ma: Option[String], a: Option[String], c: String, s: Option[String], geolocation: Geolocation) - -object GeoJsonProtocol extends DefaultJsonProtocol { - implicit val geolocationFormat = jsonFormat2(Geolocation) - implicit val pointOfInterestFormat = jsonFormat5(PointOfInterest) - implicit val containerFormat = jsonFormat1(Container) -} -/** END-OF JSON Infrastructure */ - - - - - - -class ClientTest extends App { - implicit val actorSystem = ActorSystem("spray-client-test") - import actorSystem.dispatcher - - - import GeoJsonProtocol._ - import SprayJsonSupport._ - - - val actor = IO(Http) - - val pipeline = sendReceive ~> unmarshal[Container] - - val response = pipeline { - Get("http://geo.despegar.com/geo-services-web/service/Autocomplete/DESAR/1/0/0/10/0/0/Obelisco") - } onSuccess { - case a => { - println(a) - } - } -} - - - - - diff --git a/kamon-core/src/main/scala/spraytest/FutureTesting.scala b/kamon-core/src/main/scala/spraytest/FutureTesting.scala deleted file mode 100644 index b864d6d6..00000000 --- a/kamon-core/src/main/scala/spraytest/FutureTesting.scala +++ /dev/null @@ -1,81 +0,0 @@ -package spraytest -/* -import akka.actor.ActorSystem -import scala.concurrent.{ExecutionContext, Future} -import scala.util.{Try, Success} -import kamon.actor.TransactionContext - -object FutureTesting extends App { - - val actorSystem = ActorSystem("future-testing") - implicit val ec = actorSystem.dispatcher - implicit val tctx = TransactionContext(11, Nil) - - threadPrintln("In the initial Thread") - - - val f = TraceableFuture { - threadPrintln(s"Processing the Future, and the current context is: ${TransactionContext.current.get()}") - } - - f.onComplete({ - case Success(a) => threadPrintln(s"Processing the first callback, and the current context is: ${TransactionContext.current.get()}") - }) - - f.onComplete({ - case Success(a) => threadPrintln(s"Processing the second callback, and the current context is: ${TransactionContext.current.get()}") - }) - - - - - - - - - def threadPrintln(message: String) = println(s"Thread[${Thread.currentThread.getName}] says: [${message}]") - -} - - - - -trait TransactionContextWrapper { - def wrap[In, Out](f: => In => Out, tranContext: TransactionContext) = { - TransactionContext.current.set(tranContext.fork) - println(s"SetContext to: ${tranContext}") - val result = f - - TransactionContext.current.remove() - result - } - -} - -class TraceableFuture[T](val future: Future[T]) extends TransactionContextWrapper { - def onComplete[U](func: Try[T] => U)(implicit transactionContext: TransactionContext, executor: ExecutionContext): Unit = { - future.onComplete(wrap(func, transactionContext)) - } -} - -object TraceableFuture { - - implicit def toRegularFuture[T](tf: TraceableFuture[T]) = tf.future - - def apply[T](body: => T)(implicit transactionContext: TransactionContext, executor: ExecutionContext) = { - val wrappedBody = contextSwitchWrapper(body, TransactionContext(transactionContext.dispatcherName, Nil)) - - new TraceableFuture(Future { wrappedBody }) - } - - - - - def contextSwitchWrapper[T](body: => T, transactionContext: TransactionContext) = { - TransactionContext.current.set(transactionContext) - val result = body - TransactionContext.current.remove() - result - } -}*/ - |