Hub

sealed abstract class Hub[F[_], A] extends Serializable

A CHub[F, A, B] is an asynchronous message hub. Publishers can publish messages of type A to the hub and subscribers can subscribe to take messages of type B from the hub within the context of the effect F.

Companion:
object
class Object
trait Matchable
class Any

Value members

Abstract methods

def awaitShutdown(implicit trace: Trace): F[Unit]

Waits for the hub to be shut down.

Waits for the hub to be shut down.

The maximum capacity of the hub.

The maximum capacity of the hub.

def isEmpty(implicit trace: Trace): F[Boolean]

Checks if this hub is empty.

Checks if this hub is empty.

def isFull(implicit trace: Trace): F[Boolean]

Checks if this hub is full.

Checks if this hub is full.

def isShutdown(implicit trace: Trace): F[Boolean]

Checks whether the hub is shut down.

Checks whether the hub is shut down.

def publish(a: A)(implicit trace: Trace): F[Boolean]

Publishes a message to the hub, returning whether the message was published to the hub.

Publishes a message to the hub, returning whether the message was published to the hub.

def publishAll(as: Iterable[A])(implicit trace: Trace): F[Boolean]

Publishes all of the specified messages to the hub, returning whether they were published to the hub.

Publishes all of the specified messages to the hub, returning whether they were published to the hub.

def shutdown(implicit trace: Trace): F[Unit]

Shuts down the hub.

Shuts down the hub.

def size(implicit trace: Trace): F[Int]

The current number of messages in the hub.

The current number of messages in the hub.

def subscribe(implicit trace: Trace): Resource[F, Dequeue[F, A]]

Subscribes to receive messages from the hub. The resulting subscription can be evaluated multiple times within the scope of the resource to take a message from the hub each time.

Subscribes to receive messages from the hub. The resulting subscription can be evaluated multiple times within the scope of the resource to take a message from the hub each time.