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
@Grab( 'com.typesafe.akka:akka-actor_2.10:2.3.2' ) | |
@Grab( 'com.typesafe:config:1.2.0' ) | |
import akka.actor.UntypedActor | |
import akka.japi.Procedure | |
import akka.actor.ActorSystem | |
import akka.actor.Props | |
import com.typesafe.config.ConfigFactory | |
class PingPongActor extends UntypedActor { | |
static final String PING = 'PING' |
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 akka.pattern.CircuitBreaker | |
val breaker = | |
CircuitBreaker(system.scheduler, | |
maxFailures = 5, | |
callTimeout = 10.seconds, | |
resetTimeout = 1.minute) | |
def dangerous: Future[String] = | |
breaker.withCircuitBreaker(Future(dangerousCall)) |
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 akka.routing.ConsistentHashingRouter | |
import akka.routing.ConsistentHashingRouter.ConsistentHashMapping | |
import akka.actor.Actor | |
import akka.pattern.ask | |
case class Entry(key: String, value: String) | |
class Cache extends Actor { | |
var cache = Map.empty[String, String] | |
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
akka.actor.deployment { | |
/statsService/workerRouter { | |
router = round-robin | |
nr-of-instances = 100 | |
cluster { | |
enabled = on | |
routees-path = "/user/statsWorker" | |
} | |
} | |
} |
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 akka.cluster.Cluster | |
import akka.cluster.ClusterEvent._ | |
val clusterListener = system.actorOf(Props(new Actor with ActorLogging { | |
def receive = { | |
case state: CurrentClusterState ⇒ | |
log.info("Current members: {}", state.members) | |
case MemberUp(member) ⇒ | |
log.info("Member is up: {}", member) | |
// send a message to the "world" actor running at the member node |
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
case object BackendRegistration | |
case class Job(text: String) | |
class Frontend extends Actor { | |
var backends = IndexedSeq.empty[ActorRef] | |
var jobCounter = 0 | |
def receive = { | |
case job: Job if backends.isEmpty => |
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
package example | |
import java.util.concurrent.ConcurrentHashMap | |
import java.util.concurrent.ConcurrentLinkedQueue | |
import com.typesafe.config.Config | |
import com.typesafe.config.ConfigFactory | |
import akka.actor.Actor | |
import akka.actor.ActorContext | |
import akka.actor.ActorRef | |
import akka.actor.ActorSystem |
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
Welcome to Scala version 2.10.0-RC5 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_07). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> system=ActorSystem("repl",ConfigFactory.parseString("pinned{type=PinnedDispatcher;executor=thread-pool-executor}").withFallback(config)) | |
[DEBUG] [12/09/2012 21:23:23.535] [run-main] [EventStream(akka://repl)] logger log1-Logging$DefaultLogger started | |
[DEBUG] [12/09/2012 21:23:23.535] [run-main] [EventStream(akka://repl)] Default Loggers started | |
system: akka.actor.ActorSystem = akka://repl | |
scala> case class Add(x: Int) |
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
Please help compile a list of all Scala-related IRC rooms. | |
All of these channels are on Freenode. | |
#akka | concurrency & distribution framework | |
#argonaut | json library | |
#fp-in-scala | the book Functional Programming in Scala | |
#geotrellis | geoprocessing library | |
#indyscala | regional scala group | |
#json4s | json library |
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
Companies hiring Scala developers in the Bay Area. | |
Created in response to a thread on scala-base. | |
My favorites: | |
- CloudPhysics | |
- Wordnik | |
Unbiased list: | |
- 10Gen | |
- Audax Health |