y_process v0.1.4 YProcess.Backend behaviour
Behaviour to implement backends for the communication between YProcess
es.
Summary
Functions
Creates channels
using a backend module
Deletes channels
using a backend module
Emits messages. Uses a backend module
to send a message
to a list of
channels
. Also uses a function transform/2
that receives the channel
and the message
to make modifications to the message
before sending it
Joins the channels
using a backend module
Leaves the channels
using a backend module
Callbacks
Callback to create a channel
Callback to delete a channel
Callback used to send a message
to a channel
Callback used to make a process with pid
a channel
Callback used to make a process with pid
leave a channel
Functions
Specs
create(module, channels) ::
:ok |
:no_return when channels: YProcess.channels
Creates channels
using a backend module
.
Specs
delete(module, channels) ::
:ok |
:no_return when channels: YProcess.channels
Deletes channels
using a backend module
.
Specs
emit(module, channels, message, (channel, message -> term)) ::
:ok |
:no_return when channel: YProcess.channel, channels: YProcess.channels, message: term
Emits messages. Uses a backend module
to send a message
to a list of
channels
. Also uses a function transform/2
that receives the channel
and the message
to make modifications to the message
before sending it.
If it fails to send the message
to any of the channels, sends an exit
signal to the calling process. If no error is found while sending the
message
to any of the channels
return :ok
.
Specs
join(module, channels) ::
:ok |
:no_return when channels: YProcess.channels
Joins the channels
using a backend module
.
Specs
leave(module, channels) ::
:ok |
:no_return when channels: YProcess.channels
Leaves the channels
using a backend module
.
Callbacks
Specs
create(channel) ::
:ok |
{:error, reason} when channel: YProcess.channel, reason: term
Callback to create a channel
.
Returns :ok
when the channel has been created succesfully.
Returns {:error, reason}
when the channel couldn’t be created.
Specs
delete(channel) ::
:ok |
{:error, reason} when channel: YProcess.channel, reason: term
Callback to delete a channel
.
Returns :ok
when the channel has been deleted succesfully.
Returns {:error, reason}
when the channel couldn’t be deleted.
Specs
emit(channel, message) ::
:ok |
{:error, reason} when channel: YProcess.channel, message: term, reason: term
Callback used to send a message
to a channel
.
Returns :ok
when the message is sent.
Returns {:error, reason}
when the message couldn’t be sent.
Specs
join(channel, pid) ::
:ok |
{:error, reason} when channel: YProcess.channel, reason: term
Callback used to make a process with pid
a channel
.
Returns :ok
when the process joins the channel successfully.
Returns {:error, reason}
when the process couldn’t join the channel.
Specs
leave(channel, pid) ::
:ok |
{:error, reason} when channel: YProcess.channel, reason: term
Callback used to make a process with pid
leave a channel
.
Returns :ok
when the process leaves the channel successfully.
Returns {:error, reason}
when the process couldn’t leave the channel.