Skip to content

Instantly share code, notes, and snippets.

View RayRoestenburg's full-sized avatar

Raymond Roestenburg RayRoestenburg

View GitHub Profile

Keybase proof

I hereby claim:

  • I am rayroestenburg on github.
  • I am rayroestenburg (https://keybase.io/rayroestenburg) on keybase.
  • I have a public key ASC-H2rpzN2skIGjRqBtqhx88CkGs0B4bxfYr1V9hcWNmAo

To claim this, I am signing this object:

package akka.persistence
import scala.language.postfixOps
import com.typesafe.config._
import scala.concurrent.duration._
import akka.actor._
import akka.persistence._
@RayRoestenburg
RayRoestenburg / confirmed_messages_not_replayed.scala
Last active August 29, 2015 13:57
Confirmed messages are not replayed if the same channel is used.
package akka.persistence
import com.typesafe.config._
import scala.concurrent.duration._
import akka.actor._
import akka.persistence._
import akka.testkit._
@RayRoestenburg
RayRoestenburg / confirmed_messages_replayed.scala
Created March 16, 2014 11:35
Are confirmed messages replayed?
package akka.persistence
import com.typesafe.config._
import scala.concurrent.duration._
import akka.actor._
import akka.persistence._
import akka.testkit._
@RayRoestenburg
RayRoestenburg / Failing_Test.scala
Last active August 29, 2015 13:57
Failing persistence test when one probe is used.
package akka.persistence
import com.typesafe.config._
import scala.concurrent.duration._
import akka.actor._
import akka.persistence._
import akka.testkit._
@RayRoestenburg
RayRoestenburg / firstSucceededOf.scala
Last active May 20, 2021 21:45
firstSucceededOf, returns a future containing the first successful result or contains the last failure if all futures have failed. What's wrong with it?
import scala.concurrent._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.util._
import java.util.concurrent.atomic.AtomicInteger
def firstSucceededOf[T](futures: TraversableOnce[Future[T]])(implicit executor: ExecutionContext): Future[T] = {
val p = Promise[T]()
val size = futures.size
val failureCount = new AtomicInteger(0)
@RayRoestenburg
RayRoestenburg / gist:3519303
Created August 29, 2012 21:39
Venomous!!!
/**
* Venomous spiders kill slow Actors...
*/
trait Venom extends WebNode[Poisoned, KillSlowActors] {
var time = 0L
var timeBefore: Long = 0
def now = System.currentTimeMillis()
override def sendSpiders(ref: ActorRef, data: Poisoned, msg: (KillSlowActors, Spider), collected: Set[ActorRef]) {
@RayRoestenburg
RayRoestenburg / gist:3519147
Created August 29, 2012 21:22
test outoput
Testing started at 11:21 PM ...
The spider:
Some text to play with
Some text to play with
Some text to play with
DiagnosticData((1,20000),1346275304836441000,WebNodeRef(Actor[akka://spider/user/printer],List(Actor[akka://spider/user/t-3], Actor[akka://spider/user/t-2], Actor[akka://spider/user/t-1]),List()))
DiagnosticData((1,86000),1346275304840491000,WebNodeRef(Actor[akka://spider/user/t-1],List(Actor[akka://spider/user/transformer-with-router]),List(Actor[akka://spider/user/printer])))
DiagnosticData((1,74000),1346275304840510000,WebNodeRef(Actor[akka://spider/user/t-2],List(Actor[akka://spider/user/transformer-with-router]),List(Actor[akka://spider/user/printer])))
DiagnosticData((1,74000),1346275304840513000,WebNodeRef(Actor[akka://spider/user/t-3],List(Actor[akka://spider/user/transformer-with-router]),List(Actor[akka://spider/user/printer])))
DiagnosticData((1,46882000),1346275304840637000,WebNodeRef(Actor[akka://spider/user/transformer-with-router],List(Actor[akka://spider/user/first-transformer]),Lis
@RayRoestenburg
RayRoestenburg / gist:3519015
Created August 29, 2012 21:10
test actors
case class SomeMessage(id:Long, text:String) extends HasId
class Transformer(next: ActorRef) extends Actor with Node{
def receive = {
case m:SomeMessage =>
send (next, m.copy(text = (m.text.head.toUpper +: m.text.tail).toString))
}
}
class Printer extends Actor {
class SpiderTest extends TestKit(ActorSystem("spider")) with WordSpec with MustMatchers with BeforeAndAfterAll {
implicit val timeout = Timeout(10 seconds)
"The spider " must {
"collect data about specific events " in {
val printer = system.actorOf(Props(new Printer with TimingDiagnostics with WireTap {
def listener = testActor
}), "printer")
def createDiagnostic = new Transformer(printer) with TimingDiagnostics