Skip to content

Instantly share code, notes, and snippets.

@rkuhn
rkuhn / dsl-demo.scala
Created September 26, 2012 18:47
actor dsl demo
import akka.actor.ActorDSL._
val ref = actor("fred")(new Act {
become {
case "hello" => sender ! "world!"
}
})
implicit val recv = inbox()
ref ! "hello" // uses the `recv` as sender ref
@rkuhn
rkuhn / TestKitSampleTest.scala
Created July 4, 2012 15:48
JavaTestKit Sample
/**
* Copyright (C) 2012 Typesafe Inc. <http://www.typesafe.com>
*/
package docs.testkit;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
@rkuhn
rkuhn / gist:2726426
Created May 18, 2012 17:03 — forked from phaller/gist:2644769
Akka 2.0.1 dependencies for sbt
set resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
set libraryDependencies ++= Seq("com.typesafe.akka" % "akka-actor" % "2.0.1", "com.typesafe.akka" % "akka-remote" % "2.0.1", "com.typesafe.akka" % "akka-testkit" % "2.0.1" % "test", "org.specs2" %% "specs2" % "1.9" % "test", "junit" % "junit" % "4.5" % "test")
@rkuhn
rkuhn / Build.scala
Created April 13, 2012 14:47
Build.scala for merging reference.conf
import sbt._
import Keys._
import classpath.ClasspathUtilities.isArchive
import java.io.FileOutputStream
import sbtassembly.Plugin._
import AssemblyKeys._
object B extends Build {
lazy val merge = TaskKey[File]("merge-reference",
"merge all reference.conf")
@rkuhn
rkuhn / typedactordemo.scala
Created March 10, 2012 19:12
TypedActor Demonstration
package typedactordemo
import akka.actor._
import akka.dispatch.Future
import akka.pattern.ask
import akka.util.Timeout
import akka.util.duration._
case class Request(payload: String)
case class Response(payload: String)
@rkuhn
rkuhn / pipeTo.scala
Created February 16, 2012 11:17
Futures and Resizers
import akka.dispatch.Future
import akka.pattern.pipe
import akka.actor.Actor
case class Work(s: String)
case class Result(s: String)
object MyActor {
// put here to avoid closing over actor’s state
def doWork(work: String): String = {