Skip to content

Instantly share code, notes, and snippets.

View jboner's full-sized avatar

Jonas Bonér jboner

View GitHub Profile
@timyates
timyates / fridayfun.groovy
Last active October 10, 2015 16:58
A Ping-Pong HotSwapped Untyped Akka Actor in Groovy
@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'
@patriknw
patriknw / CircuitBreakerSpotlight.scala
Created October 3, 2012 11:19
Circuit Breaker Spotlight
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))
@patriknw
patriknw / ConsistentHashingRouterSpotlight.scala
Created October 3, 2012 12:16
Spotlight for ConsistentHashingRouter
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]
@patriknw
patriknw / ClusterRouter.conf
Created October 8, 2012 12:15
Spotlight for Cluster Aware Routers
akka.actor.deployment {
/statsService/workerRouter {
router = round-robin
nr-of-instances = 100
cluster {
enabled = on
routees-path = "/user/statsWorker"
}
}
}
@patriknw
patriknw / ClusterListener.scala
Created October 8, 2012 12:48
Spotlight for Cluster Membership
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
@patriknw
patriknw / ClusterWatch.scala
Created October 8, 2012 13:12
Spotlight for Cluster Death Watch
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 =>
@patriknw
patriknw / PeekMailbox.scala
Created November 21, 2012 14:20
PeekMailbox example
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
@rkuhn
rkuhn / count-repl-session.txt
Created December 9, 2012 20:13
too simple benchmark
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)
@ymasory
ymasory / scala-irc
Last active August 30, 2017 21:16
List of all Scala-related IRC channels.
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
@ymasory
ymasory / bay-scala-jobs
Last active February 18, 2020 20:48
Companies hiring Scala developers in the Bay Area.
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