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 #
# ------------------------------------------------------- #
require Logger
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 = [restart: :temporary, id: id] ++ opts
child = worker(NSQ.Message, [message], opts)
Supervisor.start_child(msg_sup_pid, child)
end
def init(:ok) do
supervise([], strategy: :one_for_one)
end
end