Simple job queue backed by PostgreSQL
- Add
kick
to dependencies
def deps do
[{:kick, "~> 0.1.0"}]
end
- Generate migration
$ mix ecto.gen.migration setup_kick
defmodule MyApp.Repo.Migrations.SetupKick do
use Ecto.Migration
def change do
create table(:kick_jobs) do
add :mod, :binary
add :fun, :binary
add :args, :binary
add :run_at, :utc_datetime, default: fragment("(NOW() AT TIME ZONE 'UTC')")
add :runs, {:array, :binary}, default: []
timestamps(type: :utc_datetime)
end
end
end
- Create a queue
# lib/myapp/queue.ex
defmodule MyApp.Queue do
use Kick, otp_app: :my_app, repo: MyApp.Repo
end
MyApp.Queue.enqueue Module, :function, [:arg, :ume, :nts]