Packages

A client library for NSQ, `elixir_nsq` aims to be complete, easy to use, and well tested. Developed at Wistia (http://wistia.com).

Current section

Files

Jump to
elixir_nsq lib nsq message supervisor.ex
Raw

lib/nsq/message/supervisor.ex

defmodule NSQ.Message.Supervisor do
@moduledoc """
"""
# ------------------------------------------------------- #
# Directives #
# ------------------------------------------------------- #
use Supervisor
# ------------------------------------------------------- #
# Behaviour Implementation #
# ------------------------------------------------------- #
def start_link(opts \\ []) do
Supervisor.start_link(__MODULE__, :ok, opts)
end
def start_child(msg_sup_pid, message, opts \\ []) do
# If a message fails, NSQ will handle requeueing.
id = message.id <> "-" <> UUID.uuid4(:hex)
opts = [id: id, restart: :temporary] ++ opts
child = Supervisor.child_spec({NSQ.Message, message}, opts)
Supervisor.start_child(msg_sup_pid, child)
end
@impl true
def init(:ok) do
Supervisor.init([], strategy: :one_for_one)
end
end