Skip to content

Commit

Permalink
Remove Stream from RedisSubscriberJob
Browse files Browse the repository at this point in the history
Remove fs2 as well
  • Loading branch information
lenguyenthanh committed Nov 25, 2023
1 parent 27a5fb9 commit aed9bd0
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 17 deletions.
14 changes: 1 addition & 13 deletions app/src/main/scala/RedisSubscriberJob.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package lila.fishnet

import cats.effect.IO
import cats.effect.std.Queue
import fs2.Stream
import io.chrisdavenport.rediculous.RedisPubSub
import org.typelevel.log4cats.Logger
import Lila.Request
Expand All @@ -16,21 +14,11 @@ object RedisSubscriberJob:
def apply(executor: Executor, pubsub: RedisPubSub[IO])(using Logger[IO]): RedisSubscriberJob =
new RedisSubscriberJob:
def run(): IO[Unit] =
requestStream.compile.drain

def requestStream: Stream[IO, Lila.Request] =
for
q <- Stream.eval(Queue.unbounded[IO, Lila.Request])
_ <- Stream.eval(subscribe(q.offer))
request <- Stream.fromQueueUnterminated(q)
yield request

def subscribe(cb: Request => IO[Unit]): IO[Unit] =
Logger[IO].info("Subscribing to fishnet-out") *>
pubsub.subscribe(
"fishnet-out",
msg =>
Logger[IO].info(s"Received message: $msg") *>
Logger[IO].debug(s"Received message: $msg") *>
Lila
.readMoveReq(msg.message)
.match
Expand Down
1 change: 0 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ lazy val app = project
circeCore,
cirisCore,
cirisHtt4s,
fs2,
http4sCirce,
http4sDsl,
http4sServer,
Expand Down
3 changes: 0 additions & 3 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ object Dependencies {
val lilaMaven = "lila-maven" at "https://raw.githubusercontent.com/lichess-org/lila-maven/master"

object V {
val fs2 = "3.9.3"
val circe = "0.14.6"
val http4s = "0.23.23"
val ciris = "3.4.0"
Expand All @@ -23,8 +22,6 @@ object Dependencies {
val catsCore = "org.typelevel" %% "cats-core" % "2.10.0"
val catsEffect = "org.typelevel" %% "cats-effect" % "3.5.0"

val fs2 = "co.fs2" %% "fs2-core" % V.fs2

val circeCore = circe("core")
val circeLiteral = circe("literal") % Test

Expand Down

0 comments on commit aed9bd0

Please sign in to comment.