This repository has been archived by the owner on May 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from walfie/streams
Rewrite using akka-stream
- Loading branch information
Showing
17 changed files
with
323 additions
and
500 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
50 changes: 17 additions & 33 deletions
50
src/main/scala/com/github/walfie/granblue/raidfinder/Application.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")) | ||
} | ||
} | ||
|
24 changes: 0 additions & 24 deletions
24
src/main/scala/com/github/walfie/granblue/raidfinder/RaidParser.scala
This file was deleted.
Oops, something went wrong.
50 changes: 0 additions & 50 deletions
50
src/main/scala/com/github/walfie/granblue/raidfinder/TweetSearcher.scala
This file was deleted.
Oops, something went wrong.
136 changes: 0 additions & 136 deletions
136
src/main/scala/com/github/walfie/granblue/raidfinder/actor/RaidPoller.scala
This file was deleted.
Oops, something went wrong.
46 changes: 0 additions & 46 deletions
46
src/main/scala/com/github/walfie/granblue/raidfinder/actor/WebsocketFlow.scala
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.