All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sttp.client3.impl.zio.ZioSimpleQueue.scala Maven / Gradle / Ivy

There is a newer version: 3.10.0
Show newest version
package sttp.client3.impl.zio

import sttp.client3.internal.ws.SimpleQueue
import sttp.ws.WebSocketBufferFull
import zio.{Queue, RIO, Runtime, Unsafe}

private[client3] class ZioSimpleQueue[R, A](queue: Queue[A], runtime: Runtime[Any]) extends SimpleQueue[RIO[R, *], A] {
  override def offer(t: A): Unit = {
    Unsafe.unsafeCompat { implicit u =>
      if (!runtime.unsafe.run(queue.offer(t)).getOrThrowFiberFailure()) {
        throw WebSocketBufferFull(queue.capacity)
      }
    }
  }
  override def poll: RIO[R, A] = {
    queue.take
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy