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

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

package sttp.client3.impl.zio

import sttp.capabilities.zio.ZioStreams
import sttp.model.sse.ServerSentEvent
import zio.stream.ZTransducer

object ZioServerSentEvents {
  val parse: ZioStreams.Pipe[Byte, ServerSentEvent] = { stream =>
    stream
      .aggregate(ZTransducer.utf8Decode)
      .aggregate(ZTransducer.splitLines)
      .aggregate(ZTransducer.collectAllWhile[String](_.nonEmpty))
      .map(ServerSentEvent.parse)
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy