package reactivestreams
Implementation of the reactivestreams protocol for fs2
- Source
- package.scala
scala> import fs2._ scala> import fs2.interop.reactivestreams._ scala> import cats.effect.{IO, Resource}, cats.effect.unsafe.implicits.global scala> scala> val upstream: Stream[IO, Int] = Stream(1, 2, 3).covary[IO] scala> val publisher: Resource[IO, StreamUnicastPublisher[IO, Int]] = upstream.toUnicastPublisher scala> val downstream: Stream[IO, Int] = Stream.resource(publisher).flatMap(_.toStreamBuffered[IO](bufferSize = 16)) scala> scala> downstream.compile.toVector.unsafeRunSync() res0: Vector[Int] = Vector(1, 2, 3)
- See also
- Alphabetic
- By Inheritance
- reactivestreams
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- implicit final class PublisherOps[A] extends AnyVal
- implicit final class StreamOps[F[_], A] extends AnyRef
- final class StreamSubscriber[F[_], A] extends Subscriber[A]
Implementation of a
org.reactivestreams.Subscriber.Implementation of a
org.reactivestreams.Subscriber.This is used to obtain a
fs2.Streamfrom an upstream reactivestreams system. - final class StreamUnicastPublisher[F[_], A] extends Publisher[A]
Implementation of a
org.reactivestreams.PublisherImplementation of a
org.reactivestreams.PublisherThis is used to publish elements from a
fs2.Streamto a downstream reactivestreams system.
Value Members
- def fromPublisher[F[_], A](p: Publisher[A], bufferSize: Int)(implicit arg0: Async[F]): Stream[F, A]
Creates a lazy stream from an
org.reactivestreams.Publisher.Creates a lazy stream from an
org.reactivestreams.Publisher.The publisher only receives a subscriber when the stream is run.
- bufferSize
setup the number of elements asked each time from the
org.reactivestreams.Publisher. A high number can be useful is the publisher is triggering from IO, like requesting elements from a database. The publisher can use thisbufferSizeto query elements in batch. A high number will also lead to more elements in memory.
- object StreamSubscriber
- object StreamUnicastPublisher
Deprecated Value Members
- def fromPublisher[F[_], A](p: Publisher[A])(implicit arg0: Async[F]): Stream[F, A]
Creates a lazy stream from an
org.reactivestreams.Publisher.Creates a lazy stream from an
org.reactivestreams.Publisher.The publisher only receives a subscriber when the stream is run.
- Annotations
- @deprecated
- Deprecated
(Since version 3.1.4) Use fromPublisher method with a buffer size. Use a buffer size of 1 to keep the same behavior.