Skip to content

Instantly share code, notes, and snippets.

View scullxbones's full-sized avatar

Brian Scully scullxbones

View GitHub Profile
@scullxbones
scullxbones / ViewState.scala
Last active August 29, 2015 14:00
Stake in the ground
trait ViewState { self: View =>
type State
private val state: State
def handle: Receive = {
case SnapshotOffer(metadata, offeredSnapshot) => state = offeredSnapshot
case p@Persistent(payload, sequenceNr) =>
// Handle persistent
case PersistenceFailure(payload, sequenceNr, cause) =>
@scullxbones
scullxbones / Notes.md
Last active August 29, 2015 13:57
## A driver script for metrics-scala
@scullxbones
scullxbones / IntegrationTest.scala
Last active August 29, 2015 13:57
Attempt to duplicate Issue#3, no success. Possibly classpath issues?
package akka.contrib.persistence.mongodb
// REF Issue #1
import akka.actor._
import akka.persistence.{ Persistent, PersistenceFailure, Processor }
import ComputeActor._
import akka.testkit.TestKit
import com.typesafe.config.ConfigFactory
import org.junit.runner.RunWith
@scullxbones
scullxbones / Metrics-ScalaLibraryCode.scala
Created October 2, 2013 01:57
Another take on fine-grained metrics
object SuppliesMetricInformation {
import akka.actor.Actor.Receive
trait MetricInformation[A] {
val clazz: Class[_]
val name: String
val builder: InstrumentedBuilder
def counter: Counter = builder.metrics.counter(MetricBuilder.metricName(clazz, Seq(name)))
@scullxbones
scullxbones / Sample Per-Message Metrics
Last active December 21, 2015 16:08
Finer grained metrics - instead of a single counter for receive, separate out a counter-per-type for the idiomatic usage of actors ... question is how to fold this into the current metrics implementations for actors.
sealed trait Message
case class Get(id: Long) extends Message
case class Put(id: Long, value: String) extends Message
case class Database(store:Map[Long,String] = Map()) {
def get(id: Long) = store.get(id)
def put(id: Long, value: String) = new Database( store + (id -> value) )
}
trait Instrumented extends InstrumentedBuilder {
@scullxbones
scullxbones / DurableSystemTest.scala
Created May 7, 2012 01:38
OOM upon Redis client attempt to reconnect
package akka.actor.mailbox
import akka.event.Logging
import akka.util.Duration
import com.typesafe.config.ConfigFactory
import akka.actor._
import akka.actor.SupervisorStrategy.Restart
/**
@scullxbones
scullxbones / DurableSystemTest.scala
Created May 6, 2012 14:50
System test for durable mailboxes + circuit breaker
package akka.actor.mailbox
import akka.event.Logging
import akka.util.Duration
import com.typesafe.config.ConfigFactory
import akka.actor.{ActorRef, Props, ActorSystem, Actor}
/**
* akka.actor.mailbox