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
def stream = WebSocket.using[JsValue] { req => | |
val out = Concurrent.patchPanel[JsValue] { patcher => | |
// callback called when the enumerator "out" is applied to an iteratee, here the | |
// Websocket output Iteratee | |
patcher.patchIn(streamEnumerator1) | |
// ... | |
patcher.patchIn(streamEnumerator2) | |
} | |
val in = Iteratee.foreach[JsValue] { json => |
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
def stream = WebSocket.using[JsValue] { req => | |
val promiseIn = promise[Iteratee[JsValue, Unit]] | |
val out = Concurrent.patchPanel[JsValue] { patcher => | |
val in = Iteratee.foreach[JsValue] { json => | |
val topic = // read json and get the topic that the user want to subscribe to | |
val streamForThisTopic = // get the corresponding stream (enumerator) | |
patcher.patchIn(streamForThisTopic) | |
} mapDone { _ => println("Disconnected") } | |
promiseIn.success(in) |
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
/** | |
* Created by atamborrino on 11/03/2014. | |
*/ | |
import play.api.libs.iteratee.Enumeratee._ | |
import play.api.libs.iteratee._ | |
import scala.concurrent._ | |
import scala.concurrent.duration._ | |
def mapWithCounter[From, To](f: (From, Int) => To): Enumeratee[From, To] = new CheckDone[From, To] { |
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
import play.api.libs.iteratee._ | |
import play.api.libs.iteratee.Enumerator._ | |
import concurrent.ExecutionContext.Implicits.global | |
import scala.concurrent._ | |
import scala.concurrent.duration._ | |
implicit val t = 100 seconds | |
trait TreatCont2[E, S] { | |
def apply[A](loop: (Iteratee[E, A], S) => Future[Iteratee[E, A]], s: S, it: Iteratee[E, A]): Future[Iteratee[E, A]] |
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
import play.api.libs.iteratee._ | |
import play.api.libs.iteratee.Enumerator._ | |
import concurrent.ExecutionContext.Implicits.global | |
import scala.concurrent._ | |
import scala.concurrent.duration._ | |
implicit val t = 100 seconds | |
def startStream(): Future[Iteratee[Event, Unit]] = { | |
Thread.sleep(1000) |
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
\begin{figure}[h] | |
\begin{center} | |
\makebox[\textwidth]{\includegraphics[width=1.0\textwidth]{img/archi_actor_dataintegration.png}} | |
\caption{Puller actor system} | |
\label{fig:archi_actor_dataintegration} | |
\end{center} | |
\end{figure} |
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
#!/bin/bash | |
REMOTE=play@SERVER_IP | |
REMOTE_APP=/home/play/PROJECT_NAME/ | |
sbt stage || exit 1; | |
rsync -va target/ $REMOTE:$REMOTE_APP/target; | |
ssh $REMOTE "cd $REMOTE_APP; ./stop.sh"; | |
ssh $REMOTE "cd $REMOTE_APP; ./start.sh"; |
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
implicit val app = new play.core.StaticApplication(new java.io.File(".")) |
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
def uploadStream(bucket: String, key: String, enum: Enumerator[Array[Byte]]) | |
(implicit ec: ExecutionContext): Future[CompleteMultipartUploadResult] = { | |
import scala.collection.JavaConversions._ | |
val initRequest = new InitiateMultipartUploadRequest(bucket, key) | |
val initResponse = s3.initiateMultipartUpload(initRequest) | |
val uploadId = initResponse.getUploadId | |
val rechunker: Enumeratee[Array[Byte], Array[Byte]] = Enumeratee.grouped { | |
Traversable.takeUpTo[Array[Byte]](5 * 1024 * 1024) &>> Iteratee.consume() |
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
sealed trait IOToolResponse[+A] { | |
def flatMap[B](f: A => IOToolResponse[B]): IOToolResponse[B] = this match { | |
case Authenticated(a) => f(a) | |
case na: NotAuthenticated => na | |
} | |
def map[B](f: A => B): IOToolResponse[B] = this.flatMap(a => IOToolResponse.unit(f(a))) | |
} | |
object IOToolResponse { | |
def unit[A](a: A): IOToolResponse[A] = Authenticated(a) |
OlderNewer