KubeMQ.Subscription (kubemq v1.0.1)

Copy Markdown View Source

Handle for an active subscription. Provides cancellation and status checking.

Usage

{:ok, sub} = KubeMQ.Client.subscribe_to_events(client, "my-channel", on_event: &handler/1)
true = KubeMQ.Subscription.active?(sub)
:ok = KubeMQ.Subscription.cancel(sub)

Summary

Functions

Check whether the subscription process is still alive.

Cancel an active subscription and stop its process.

Types

t()

@type t() :: %KubeMQ.Subscription{pid: pid(), ref: reference()}

Functions

active?(subscription)

@spec active?(t()) :: boolean()

Check whether the subscription process is still alive.

Examples

true = KubeMQ.Subscription.active?(sub)

cancel(subscription)

@spec cancel(t()) :: :ok

Cancel an active subscription and stop its process.

Demonitors the subscription process and stops it gracefully. Safe to call on already-stopped subscriptions.

Examples

{:ok, sub} = KubeMQ.Client.subscribe_to_events(client, "channel", on_event: &handler/1)
:ok = KubeMQ.Subscription.cancel(sub)

new(pid)

@spec new(pid()) :: t()