Skip to content
A Celery task producer for Elixir.
Elixir
Branch: master
Clone or download
Latest commit e56c83b Jan 22, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib Use a proper application with config params Nov 8, 2016
test Use a proper application with config params Nov 8, 2016
.gitignore Initial commit Oct 31, 2016
.travis.yml Test with OTP 19.2 Jan 17, 2017
LICENSE Add LICENSE Nov 2, 2016
README.md Bump version to 0.2.0 Nov 8, 2016
mix.exs Bump version to 0.2.0 Nov 8, 2016
mix.lock Initial commit Oct 31, 2016

README.md

ex_celery

Build Status

A Celery task producer for Elixir. Currently only supports delaying tasks, not retrieving their result.

Installation

First, add ex_celery to your mix.exs dependencies:

def deps do
  [{:ex_celery, "~> 0.2.0"}]
end

Then, update your dependencies:

$ mix deps.get

Usage

Add ex_celery to your applications list:

def application do
  [applications: [:ex_celery]]
end

Add configuration parameters for ex_celery using Mix.Config:

use Mix.Config

config :ex_celery,
       broker_url: "amqp://username:password@host/vhost",
       exchange: "custom_exchange"

### Delaying tasks

{:ok, task_id} = ExCelery.apply_async(pid, "my_app.tasks.add", [
    args: [1, 2],
])
{:ok, "f59b0d20-3f2c-46c7-9f01-c787b488e96c"}
{:ok, task_id} = ExCelery.apply_async(pid, "my_app.tasks.high_priority_task", [
    routing_key: "priority.high",
})
{:ok, "7f9ebbe2-a146-11e6-8328-3c15c2e06802"}

Broker support

RabbitMQ is the only broker currently supported. The broker_url is expected to be in the AMQP URI format.

Note: Celery messages will be encoded in JSON format. You must ensure that json is listed in CELERY_ACCEPT_CONTENT.

### Task options

{:ok, task_id} = ExCelery.apply_async(pid, "my_app.tasks.shorten_url", [
    args: ["http://elixir-lang.org/"],
    kwargs: %{allow_duplicates: true},
    routing_key: "tasks.misc",
])

## Licence

ex_celery is released under the MIT license (see LICENSE).

You can’t perform that action at this time.