I have built an async job processing app using Elixir exq. The documentation says that I can run the application using both the terminal (with iex -S mix
) or as a standalone application (with mix exq.run
). When I run on the terminal, everything works fine, but when I run the standalone app, I get this message when the jobs are fetched:
16:52:55.028 [info] Elixir.MyWorker[128f902c-dd22-4706-95a2-89dc974b95d6] start
16:52:55.045 [error] Process #PID<0.196.0> raised an exception
** (UndefinedFunctionError) function MyWorker.perform/1 is undefined (module MyWorker is not available)
MyWorker.perform("arg1")
(exq 0.14.0) lib/exq/worker/server.ex:186: anonymous fn/4 in Exq.Worker.Server.dispatch_work/3
16:52:55.052 [info] Queueing job 128f902c-dd22-4706-95a2-89dc974b95d6 to retry in 24.0 seconds
What am I doing wrong?
Here is my lib/my_worker.ex
file:
defmodule MyWorker do
def perform(arg) do
IO.puts("teste: " <> arg)
end
end
and my mix.exs
defmodule WorkersSandbox.MixProject do
use Mix.Project
def project do
[
app: :workers_sandbox,
version: "0.1.0",
elixir: "~> 1.10",
start_permanent: Mix.env() == :prod,
deps: deps()
]
end
# Run "mix help compile.app" to learn about applications.
def application do
[
applications: [:exq_ui, :exq],
extra_applications: [:logger]
]
end
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:exq, "~> 0.14.0"},
{:jason, "~> 1.0"},
{:exq_ui, "~> 0.11.0"},
{:plug_cowboy, "~> 2.0"}
]
end
end
and my config/config.exs
:
import Config
config :exq,
start_on_application: true,
name: Exq,
host: "127.0.0.1",
port: 6379,
# password: "",
namespace: "exq",
queues: [{"default", 10_000}, {"fila2", 10_000}],
poll_timeout: 50,
scheduler_poll_timeout: 200,
scheduler_enable: true,
max_retries: 25,
mode: :default,
shutdown_timeout: 5000