PingPong.Notification (PingPong v0.1.0)

Copy Markdown View Source

Normalizes notification tuples before dispatching.

This module is used by PingPong.send_multiple/1 and is also useful when a notification has already been represented as {service, payload, options}. It validates the tuple shape before delegating to PingPong.send/3 or PingPong.send_async/3.

Summary

Functions

Sends a notification tuple with the requested delivery mode.

Functions

send_notification(notification, send_type)

@spec send_notification(PingPong.config(), PingPong.send_type()) :: PingPong.result()

Sends a notification tuple with the requested delivery mode.

Valid notifications are three-element tuples:

{service, payload, options}

The service must be an atom, and both payload and options must be maps.

Examples

iex> PingPong.Notification.send_notification({:mock, %{message: "Ping!"}, %{}}, :sync)
{:ok, "Pong! 🏓"}

iex> PingPong.Notification.send_notification([:mock], :sync)
{:error, {:missing, :payload}}