-
Notifications
You must be signed in to change notification settings - Fork 12
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 #69 from davenverse/fixHangingQueueResponses
Fix Hanging Queue Responses
- Loading branch information
Showing
7 changed files
with
90 additions
and
15 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 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
3 changes: 3 additions & 0 deletions
3
core/js-jvm/src/test/scala/io/chrisdavenport/rediculous/RediculousCrossSuite.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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package io.chrisdavenport.rediculous | ||
|
||
trait RediculousCrossSuite extends munit.CatsEffectSuite |
7 changes: 7 additions & 0 deletions
7
core/native/src/test/scala/io/chrisdavenport/rediculous/RediculousCrosssuite.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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.chrisdavenport.rediculous | ||
|
||
import epollcat.unsafe.EpollRuntime | ||
|
||
trait RediculousCrossSuite extends munit.CatsEffectSuite { | ||
override def munitIORuntime = EpollRuntime.global | ||
} |
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
48 changes: 48 additions & 0 deletions
48
core/shared/src/test/scala/io/chrisdavenport/rediculous/RedisConnectionSpec.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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package io.chrisdavenport.rediculous | ||
|
||
import cats.effect._ | ||
import fs2.{Chunk, Pipe} | ||
import com.comcast.ip4s.{Host, Port,IpAddress, SocketAddress} | ||
import fs2.io.net.{Socket, SocketOption, SocketGroup} | ||
|
||
class RedisConnectionSpec extends RediculousCrossSuite { | ||
|
||
test("Queued Connection Does Not Hang on EOF"){ | ||
val fakeSocket = new fs2.io.net.Socket[IO]{ | ||
def read(maxBytes: Int): IO[Option[Chunk[Byte]]] = IO(None) | ||
|
||
def readN(numBytes: Int): IO[Chunk[Byte]] = ??? | ||
|
||
def reads: fs2.Stream[IO,Byte] = ??? | ||
|
||
def endOfInput: IO[Unit] = ??? | ||
|
||
def endOfOutput: IO[Unit] = ??? | ||
|
||
def isOpen: IO[Boolean] = ??? | ||
|
||
def remoteAddress: IO[SocketAddress[IpAddress]] = ??? | ||
|
||
def localAddress: IO[SocketAddress[IpAddress]] = ??? | ||
|
||
def write(bytes: Chunk[Byte]): IO[Unit] = IO.unit | ||
|
||
def writes: Pipe[IO,Byte,Nothing] = _.chunks.evalMap(write).drain | ||
|
||
} | ||
|
||
val sg = new SocketGroup[IO] { | ||
def client(to: SocketAddress[Host], options: List[SocketOption]): Resource[IO,Socket[IO]] = Resource.pure(fakeSocket) | ||
|
||
def server(address: Option[Host], port: Option[Port], options: List[SocketOption]): fs2.Stream[IO,Socket[IO]] = ??? | ||
|
||
def serverResource(address: Option[Host], port: Option[Port], options: List[SocketOption]): Resource[IO,(SocketAddress[IpAddress], fs2.Stream[IO,Socket[IO]])] = ??? | ||
|
||
} | ||
|
||
RedisConnection.queued[IO].withSocketGroup(sg).build | ||
.use(c => | ||
RedisCommands.ping[RedisIO].run(c) | ||
).intercept[RedisError.QueuedExceptionError] // We catch the redis error from the empty returned chunk, previously to #69 this would hang. | ||
} | ||
} |
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