Packages
SuperWorker is a powerful Elixir library for working with supervisors and background jobs. It provides a much simpler approach than traditional supervisors. This library is currently under development and is unstable, so it is not recommended for production use.
Current section
Files
Jump to
Current section
Files
lib/supervisor/message.ex
defmodule SuperWorker.Supervisor.Message do
@moduledoc false
alias __MODULE__
defstruct [
# Message id.
:id,
# Pid/alias of sender.
:from,
# Pid/alias of receiver.
:to,
# internal or api message
:type,
# Message to send.
:data
]
@type t :: %Message{
id: reference,
from: pid | atom | nil,
to: pid | atom | nil,
type: :internal | :api,
data: any
}
@spec new(atom, atom | pid, any) :: t
def new(type, to, data) when is_pid(to) or is_atom(to) or to == nil do
%Message{
id: make_ref(),
from: self(),
type: type,
to: to,
data: data
}
end
end