Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Removing spamming actor

  • Loading branch information...
commit 53ddeeaaa7896348b9b0d41c94a05bf4275c5756 1 parent af39838
@kelvl kelvl authored
Showing with 0 additions and 52 deletions.
  1. +0 −52 src/main/scala/com/twilio/shadow/UIService.scala
View
52 src/main/scala/com/twilio/shadow/UIService.scala
@@ -95,64 +95,12 @@ trait UIService extends HttpService {
val metricsRegistry: MetricsRegistry
- val spammer: ActorRef = actorRefFactory.actorOf(Props(new Actor {
-
- import spray.httpx.RequestBuilding._
- import scala.util.Random
-
- var shouldSpam = false
-
- def choice[T](choices: Array[T]) = {
- choices(Random.nextInt(choices.size))
- }
-
- val statuses = Array(StatusCodes.OK, StatusCodes.InternalServerError)
- val entities = Array(HttpEntity("helloworld"), HttpEntity("wtf world!"))
-
- def mockResponse = {
- (HttpResponse(choice(statuses), choice(entities), Nil, HttpProtocols.`HTTP/1.0`), Random.nextLong())
- }
-
- def example = new ShadowEntry(Get("/test"), (mockResponse, mockResponse))
-
- def receive = {
- case "Spam" => {
- if(shouldSpam) {
- context.system.eventStream.publish(example)
- Thread.sleep(10)
- self ! "Spam"
- }
- }
-
- case "Start" => {
- shouldSpam = true
- self ! "Spam"
- }
- case "Stop" => {
- println("Stopped received")
- shouldSpam = false
- }
- }
- }))
-
val myRoute =
path("stream") {
get { ctx =>
actorRefFactory.actorOf(Props(new ResponseStreamActor(ctx)))
}
} ~
- path("spam") {
- get { ctx =>
- spammer ! "Start"
- ctx.complete(StatusCodes.OK)
- }
- } ~
- path("stop") {
- get { ctx =>
- spammer ! "Stop"
- ctx.complete(StatusCodes.OK)
- }
- } ~
path("stats") {
get {
complete {
Please sign in to comment.
Something went wrong with that request. Please try again.