fs2.interop.reactivestreams

Implementation of the reactivestreams protocol for fs2

Attributes

See also
Example

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)

Members list

Type members

Classlikes

final implicit class PublisherOps[A](val publisher: Publisher[A]) extends AnyVal

Attributes

Source
package.scala
Supertypes
class AnyVal
trait Matchable
class Any
final implicit class StreamOps[F[_], A](val stream: Stream[F, A])

Attributes

Source
package.scala
Supertypes
class Object
trait Matchable
class Any
final class StreamSubscriber[F[_], A](val sub: FSM[F, A])(implicit F: ApplicativeError[F, Throwable]) extends Subscriber[A]

Implementation of a org.reactivestreams.Subscriber.

Implementation of a org.reactivestreams.Subscriber.

This is used to obtain a fs2.Stream from an upstream reactivestreams system.

Attributes

See also
Companion
object
Source
StreamSubscriber.scala
Supertypes
trait Subscriber[A]
class Object
trait Matchable
class Any

Attributes

Companion
class
Source
StreamSubscriber.scala
Supertypes
class Object
trait Matchable
class Any
Self type
final class StreamUnicastPublisher[F[_], A](val stream: Stream[F, A], startDispatcher: Dispatcher[F])(implicit evidence$1: Async[F]) extends Publisher[A]

Implementation of a org.reactivestreams.Publisher

Implementation of a org.reactivestreams.Publisher

This is used to publish elements from a Stream to a downstream reactive-streams system.

Attributes

See also
Note

Not longer unicast, this Publisher can be reused for multiple Subscribers: each subscription will re-run the Stream from the beginning. However, a _parallel_ Dispatcher is required to allow concurrent subscriptions. Please, refer to the apply factory in the companion object that only requires a stream.

Companion
object
Source
StreamUnicastPublisher.scala
Supertypes
trait Publisher[A]
class Object
trait Matchable
class Any

Attributes

Companion
class
Source
StreamUnicastPublisher.scala
Supertypes
class Object
trait Matchable
class Any
Self type

Value members

Concrete methods

def fromPublisher[F[_] : Async, A](p: Publisher[A], bufferSize: Int): 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.

Value parameters

bufferSize

setup the number of elements asked each time from the org.reactivestreams.Publisher. A high number can be useful if the publisher is triggering from IO, like requesting elements from a database. The publisher can use this bufferSize to query elements in batch. A high number will also lead to more elements in memory.

Attributes

Source
package.scala
def subscribeStream[F[_], A](stream: Stream[F, A], subscriber: Subscriber[A])(implicit F: Async[F]): F[Unit]

Allows subscribing a org.reactivestreams.Subscriber to a Stream.

Allows subscribing a org.reactivestreams.Subscriber to a Stream.

The returned program will run until all the stream elements were consumed. Cancelling this program will gracefully shutdown the subscription.

Value parameters

stream

the Stream that will be consumed by the subscriber.

subscriber

the Subscriber that will receive the elements of the stream.

Attributes

Source
package.scala

Deprecated methods

def fromPublisher[F[_] : Async, A](p: Publisher[A]): 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.

Attributes

Deprecated
true
Source
package.scala

Implicits

Implicits

final implicit def PublisherOps[A](publisher: Publisher[A]): PublisherOps[A]

Attributes

Source
package.scala
final implicit def StreamOps[F[_], A](stream: Stream[F, A]): StreamOps[F, A]

Attributes

Source
package.scala