Topic

abstract class Topic[F[_], A]

Asynchronous Topic.

Asynchronous Topic.

Topic allows you to distribute A published by arbitrary number of publishers to arbitrary number of subscribers.

Topic has built-in back-pressure support implemented as maximum bound (maxQueued) that a subscriber is allowed to enqueue. Once that bound is hit, publishing may semantically block until the lagging subscriber consumes some of its queued elements.

Additionally the subscriber has possibility to terminate whenever size of enqueued elements is over certain size by using subscribeSize.

Companion
object
class Object
trait Matchable
class Any

Value members

Abstract methods

def publish: (F, A) => Unit

Publishes elements from source of A to this topic. Pipe equivalent of publish1.

Publishes elements from source of A to this topic. Pipe equivalent of publish1.

def publish1(a: A): F[Unit]

Publishes one A to topic.

Publishes one A to topic.

This waits until a is published to all subscribers. If any of the subscribers is over the maxQueued limit, this will wait to complete until that subscriber processes enough of its elements such that a is enqueued.

def subscribe(maxQueued: Int): Stream[F, A]

Subscribes for A values that are published to this topic.

Subscribes for A values that are published to this topic.

Pulling on the returned stream opens a "subscription", which allows up to maxQueued elements to be enqueued as a result of publication.

The first element in the stream is always the last published A at the time the stream is first pulled from, followed by each published A value from that point forward.

If at any point, the queue backing the subscription has maxQueued elements in it, any further publications semantically block until elements are dequeued from the subscription queue.

Value Params
maxQueued

maximum number of elements to enqueue to the subscription queue before blocking publishers

def subscribeSize(maxQueued: Int): Stream[F, (A, Int)]

Like subscribe but emits an approximate number of queued elements for this subscription with each emitted A value.

Like subscribe but emits an approximate number of queued elements for this subscription with each emitted A value.

def subscribers: Stream[F, Int]

Signal of current active subscribers.

Signal of current active subscribers.

Concrete methods

def imap[B](f: A => B)(g: B => A): Topic[F, B]

Returns an alternate view of this Topic where its elements are of type B, given two functions, A => B and B => A.

Returns an alternate view of this Topic where its elements are of type B, given two functions, A => B and B => A.