fs2-http icon indicating copy to clipboard operation
fs2-http copied to clipboard

Use `maxUnanswered` parameter in ws pings

Open wedens opened this issue 8 years ago • 4 comments

It was unused.

Also deleted unused flag parameter.

wedens avatar Jul 04 '17 14:07 wedens

@wedens thanks for this. Any chance you can drop in test verifying the behaviour? Thanks

pchlupacek avatar Jul 05 '17 06:07 pchlupacek

I'll try to do that. Should I just add tests for controlStream to WebSocketSpec ?

wedens avatar Jul 05 '17 15:07 wedens

yes, that would be awesome @wedens.

pchlupacek avatar Jul 06 '17 14:07 pchlupacek

Sorry, I don't know how to implement such test :/

My best attempt so far was something ridiculous like:

  property("fail-on-unanswered-pings") = secure {
    val s = Stream.eval(async.unboundedQueue[Task, Unit]).flatMap { pingsQ =>
      Stream.eval(async.unboundedQueue[Task, PingPong]).flatMap { pongsQ =>
        val s = time.awakeEvery[Task](1.second).mapAccumulate(0) {
          case (x, _) if x >= 3 =>
            val s = Stream.eval_(pingsQ.enqueue1(()))
            (x + 1, s)
          case (x, _) =>
            val s = Stream.eval_(pingsQ.enqueue1(())) ++
              Stream.eval_(pongsQ.enqueue1(PingPong.Pong))
            (x + 1, s)
        }.flatMap(_._2)

        val s0 = WebSocket.impl.controlStream(pongsQ.dequeue, pingsQ.dequeue, 3)

        s mergeHaltR s0
      }
    }

    Prop.throws(classOf[Throwable]) {
      s.run.unsafeRun ?= (())
    }
  }

wedens avatar Jul 17 '17 05:07 wedens