Pixie.Monitor behaviour
Allows you to monitor various events within Pixie.
Internally Pixie.Monitor is implemented using GenEvent, so you're free to bypass using the Pixie.Monitor behaviour and use your own GenEvent if the need arises.
Usage example:
defmodule MyMonitor do
use Pixie.Monitor
def created_channel channel_name, at do
Logger.info "Channel #{channel_name} created at #{format at}"
end
def destroyed_channel channel_name, at do
Logger.info "Channel #{channel_name} destroyed at #{format at}"
end
defp format timestamp do
timestamp
|> Date.from(:timestamp)
|> DateFormat.format!("{UNIX}")
end
end
Summary
add_handler(handler, args \\ []) | Allows you to add a |
client_subscribed(client_id, channel_name) | Called by the backend when a client subscribes to a channel |
client_unsubscribed(client_id, channel_name) | Called by the backend when a client unsubscribes from a channel |
created_channel(channel_name) | Called by the backend when a new channel is created. New channels are created when the first client subscribes to them |
created_client(client_id) | Called by the backend when a new client is created either by protocol handshake, or via |
delivered_message(arg1) | Called by adapters when a message is finally delivered to a client |
destroyed_channel(channel_name) | Called by the backend when a channel is destroyed. Channels are destroyed when the last client unsubscribes from them |
destroyed_client(client_id, reason \\ "Unknown reason") | Called by the backend when a client is destroyed, either by an expicit protocol disconnect or for a system generated reason, such as a timeout |
received_message(arg1) | Called whenever a new message is received for publication. This includes server-generated messages using |
start_link(handlers) |
Functions
Allows you to add a Pixie.Monitor
or any other GenEvent
handler to the event stream. Expects the name of your handler module and any args which you wish to be provided to your module's init/1
callback.
Called by the backend when a client subscribes to a channel.
Called by the backend when a client unsubscribes from a channel.
Called by the backend when a new channel is created. New channels are created when the first client subscribes to them.
Called by the backend when a new client is created either by protocol handshake, or via Pixie.subscribe/2
Called by adapters when a message is finally delivered to a client.
Called by the backend when a channel is destroyed. Channels are destroyed when the last client unsubscribes from them.
Called by the backend when a client is destroyed, either by an expicit protocol disconnect or for a system generated reason, such as a timeout.
Called whenever a new message is received for publication. This includes server-generated messages using Pixie.publish/2