teamon / kick

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Kick

Simple job queue backed by PostgreSQL

Installation

  1. Add kick to dependencies
def deps do
  [{:kick, "~> 0.1.0"}]
end
  1. 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
  1. Create a queue
# lib/myapp/queue.ex

defmodule MyApp.Queue do
  use Kick, otp_app: :my_app, repo: MyApp.Repo
end

Usage

MyApp.Queue.enqueue Module, :function, [:arg, :ume, :nts]

About


Languages

Language:Elixir 49.0%Language:JavaScript 46.7%Language:HTML 4.2%