Examples.EEventBroker.Subscribe (event_broker v1.1.1)

Copy Markdown

I define examples on how to susbcribe to topics in the event broker.

Summary

Functions

I subscribe using the Trivial filter and assert that I receive any events sent on the message broker.

I unsubscribe a process from a filter and verify that it is unsubscribed.

I subscribe a process to events, and check whether the registry cleans up its subscriptions when it goes offline.

I assert that the current process is subscribed to the given filter.

Callback implementation for ExExample.Behaviour.copy/1.

Given a list of filters, I make sure that the current process is not subscribed to them.

Callback implementation for ExExample.Behaviour.rerun?/1.

Functions

__ex_example__subscribe_to_filter__(filter \\ %EFilter.AcceptAll{})

I subscribe using the Trivial filter and assert that I receive any events sent on the message broker.

__ex_example__subscribe_to_multiple_filters__(filters \\ [%{__struct__: Examples.EEventBroker.EFilter.AcceptAll}, %{__struct__: Examples.EEventBroker.EFilter.Error}])

I subscribe to multiple filters and assert that I receive the events that are allowed by those filters.

__ex_example__unsubscribe_from_filter__(filter \\ %EFilter.AcceptAll{})

I unsubscribe a process from a filter and verify that it is unsubscribed.

__ex_example__unsubscribe_on_down__()

I subscribe a process to events, and check whether the registry cleans up its subscriptions when it goes offline.

assert_subscription(filter)

@spec assert_subscription([struct()] | struct()) :: [struct()] | struct()

I assert that the current process is subscribed to the given filter.

copy(item)

Callback implementation for ExExample.Behaviour.copy/1.

refute_subscription(filters)

@spec refute_subscription([struct()] | struct()) :: [struct()] | struct()
@spec refute_subscription(struct()) :: struct()

Given a list of filters, I make sure that the current process is not subscribed to them.

rerun?(_)

Callback implementation for ExExample.Behaviour.rerun?/1.

subscribe_to_filter(filter \\ %EFilter.AcceptAll{})

@spec subscribe_to_filter(struct()) :: {:received, any()}

subscribe_to_multiple_filters(filters \\ [%{__struct__: Examples.EEventBroker.EFilter.AcceptAll}, %{__struct__: Examples.EEventBroker.EFilter.Error}])

@spec subscribe_to_multiple_filters([struct()]) :: {:received, any()}

unsubscribe_from_filter(filter \\ %EFilter.AcceptAll{})

@spec unsubscribe_from_filter(struct()) :: {:received, any()}

unsubscribe_on_down()

@spec unsubscribe_on_down() :: any()