Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1 from walfie/streams
Browse files Browse the repository at this point in the history
Rewrite using akka-stream
  • Loading branch information
walfie authored Aug 13, 2016
2 parents 7661765 + 1a5fc8f commit bb5108a
Show file tree
Hide file tree
Showing 17 changed files with 323 additions and 500 deletions.
5 changes: 2 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ organization := "com.github.walfie"
name := "granblue-raid-finder"

libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % Versions.Akka,
"com.typesafe.akka" %% "akka-agent" % Versions.Akka,
"com.typesafe.akka" %% "akka-cluster-tools" % Versions.Akka,
"com.typesafe.akka" %% "akka-http-experimental" % Versions.Akka,
"com.typesafe.play" %% "play-json" % Versions.Play,
"com.typesafe.akka" %% "akka-stream" % Versions.Akka,
"org.twitter4j" % "twitter4j-core" % Versions.Twitter4j
)

Expand Down
48 changes: 0 additions & 48 deletions src/main/resources/static/app.js

This file was deleted.

10 changes: 0 additions & 10 deletions src/main/resources/static/index.html

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,46 +1,30 @@
package com.github.walfie.granblue.raidfinder
package com.github.walfie.granblue.raidfinder.domain

import akka.actor._
import akka.cluster.pubsub.DistributedPubSub
import akka.cluster.pubsub.DistributedPubSubMediator.{Subscribe, SubscribeAck}
import akka.http.scaladsl.Http
import akka.http.scaladsl.server.Directives._
import akka.stream.ActorMaterializer
import com.github.walfie.granblue.raidfinder.actor._
import scala.io.StdIn
import akka.NotUsed
import akka.stream.scaladsl._
import akka.stream.{ActorMaterializer, ClosedShape}
import com.github.walfie.granblue.raidfinder.flow._
import scala.concurrent.duration._
import twitter4j.TwitterFactory

// TODO: Make this not so bad
object Application {
import scala.concurrent.ExecutionContext.Implicits.global

def main(args: Array[String]): Unit = {
implicit val system = ActorSystem("raid-tracker")
implicit val materializer = ActorMaterializer()(system)

val mediator = DistributedPubSub(system).mediator
implicit val system = ActorSystem("granblue-raid-finder")
implicit val materializer = ActorMaterializer()
import scala.concurrent.ExecutionContext.Implicits.global

val raidPoller = system.actorOf(
RaidPoller.defaultProps(Some(mediator)), "poller"
)
val raidInfoCache = RaidInfoCache.default
val cacheEvictionScheduler =
RaidInfoCache.defaultCacheEvictionScheduler(raidInfoCache)

val routes = createRoutes(system, raidPoller, mediator)
val bindingFuture = Http().bindAndHandle(routes, "localhost", 8080)
val graph = RaidFinderGraph.default(Some(raidInfoCache))
graph.run()

// Temporary way to stop server without killing SBT
println("Server running. Press RETURN to stop.")
println("Application started. Press RETURN to stop.")
scala.io.StdIn.readLine()
println("Stopping server.")
println("Stopping application.")
system.terminate()
}

def createRoutes(
system: ActorSystem, raidPoller: ActorRef, pubSubMediator: ActorRef
) = pathEndOrSingleSlash {
encodeResponse(getFromResource("static/index.html"))
} ~ path("ws") {
handleWebSocketMessages(WebsocketFlow.newSubscriber(system, raidPoller, pubSubMediator))
} ~ pathPrefix("") {
encodeResponse(getFromResourceDirectory("static"))
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit bb5108a

Please sign in to comment.