pixie v0.3.9 Pixie.Backend behaviour
Used to implement the persistence backend for Pixie.
Summary
Functions
Responds true
or false
depending on whether the client_id
is subscribed
to the given channel
Create a client. Used internally by the protocol, you probably will never call this
Dequeue any messages awaiting delivery to the specified client. This is
usually only called by the protocol when a client reconnects to retrieve
any messages that arrived while the client was disconnected.
Use publish
instead
Destroy the specified client registered to the provided client_id
Generate a unique identifier which can be used as a client_id
, etc
Retrieve the pid of the client registered to the provided client_id
Ping the specified client. This is specifically used for backends which will expire clients for inactivity (ie Redis)
Publishes a collection of messages to all their receiving clients
Queue messages for delivery to the specified client. This is usually only
called by the protocol when publishing messages for clients which are either
in-between polls or located on another Pixie instance. Use publish
instead
Release a namespace, which means it’s theoretically possible to reuse it
Called by the Pixie supervisor to start the selected backend
Subscribe the specified client to the specified channel
Returns a HashSet
containing the list of channels the client is subscribed to
Returns a HashSet
containing the list of client_id
s subscribed to the
provided channel
Unsubscribe the specified client from the specified channel
Callbacks
Check whether the client is subscribed to the mentioned channel
Create a new Pixie.Client
process
Deliver messages to clients, local or otherwise
Dequeue any stored messages for a given client
Destroy a client
Used to create a unique identifier for client ID’s, etc
Retrieve the process of a client by it’s ID
Temporarily store messages for a client if it’s transport is unconnected
Used to release a unique identifier that’s no longer in use
Used to start your Backend’s process
Subscribe a client to a channel
Retrieve the channels that the client is subscribed to
Retrieve the unique subscribers of channels matching the channel pattern
Unsubscribe a client from a channel
Functions
Responds true
or false
depending on whether the client_id
is subscribed
to the given channel.
Create a client. Used internally by the protocol, you probably will never call this.
Dequeue any messages awaiting delivery to the specified client. This is
usually only called by the protocol when a client reconnects to retrieve
any messages that arrived while the client was disconnected.
Use publish
instead.
Destroy the specified client registered to the provided client_id
.
This function has the following side effects:
- unsubscribes the client from all their subscribed channels.
- destroys any channels with no subscribers left.
- destroys any queued messages for the client.
- releases the client_id namespace.
- destroys the client process.
- destroys the transport process (which has the side-effect of disconnecting the user).
Ping the specified client. This is specifically used for backends which will expire clients for inactivity (ie Redis).
Queue messages for delivery to the specified client. This is usually only
called by the protocol when publishing messages for clients which are either
in-between polls or located on another Pixie instance. Use publish
instead.
Release a namespace, which means it’s theoretically possible to reuse it.
Returns a HashSet
containing the list of channels the client is subscribed to.
Returns a HashSet
containing the list of client_id
s subscribed to the
provided channel.
Callbacks
Check whether the client is subscribed to the mentioned channel.
Specs
create_client :: {client_id :: String.t, pid}
Create a new Pixie.Client
process.
Specs
deliver(client_id :: String.t, messages :: list) :: atom
Deliver messages to clients, local or otherwise.
Specs
dequeue_for(client_id :: String.t) :: [map]
Dequeue any stored messages for a given client.
Specs
destroy_client(client_id :: String.t, reason :: atom) :: atom
Destroy a client.
Specs
generate_namespace(length :: integer) :: String.t
Used to create a unique identifier for client ID’s, etc.
Specs
get_client(client_id :: String.t) :: pid
Retrieve the process of a client by it’s ID.
Specs
queue_for(client_id :: String.t, messages :: [map]) :: atom
Temporarily store messages for a client if it’s transport is unconnected.
Specs
release_namespace(namespace :: String.t) :: atom
Used to release a unique identifier that’s no longer in use.
Specs
start_link(options :: list) :: {atom, pid}
Used to start your Backend’s process.
Subscribe a client to a channel
Retrieve the channels that the client is subscribed to.
Specs
subscribers_of(channel_pattern :: String.t) :: [pid]
Retrieve the unique subscribers of channels matching the channel pattern.