Skip to content

Instantly share code, notes, and snippets.

@momania
momania / gist:700121
Created November 15, 2010 07:09
A to B to C
package actor.actor
import akka.actor.{Actor, FSM}
import java.util.concurrent.TimeUnit
sealed trait ExampleState
case object A extends ExampleState
case object B extends ExampleState
case object C extends ExampleState
@momania
momania / gist:674090
Created November 12, 2010 13:41
Akka AMQP RPC example
import akka.amqp.AMQP.{ToBinary, FromBinary}
import rpc.RPC.{RpcClientSerializer, RpcServerSerializer}
import rpc.RPC
import akka.actor.ActorRegistry
object RPCExample {
def main(args: Array[String]) {
// shared between client and server
val connection = AMQP.newConnection()
@momania
momania / gist:661478
Created November 3, 2010 18:28
Akka FSM Goto 10 FTW!
class GotoFsm extends Actor with FSM[Int, Null] {
notifying {
case Transition(_, 10) => println("Goto 10 ftw!")
}
when(0) {
case _ => goto(10) until 5000
}
@momania
momania / gist:653276
Created October 29, 2010 10:14
HeartMonitor using Akka FSM
import akka.actor.{Actor, FSM}
import java.util.concurrent.TimeUnit
sealed trait Health
case object Stale extends Health
case object Alive extends Health
case object Dead extends Health
case object HeartBeat