Debian Codegraph @

examples/celery_http_gateway/README.rst

raw
1 ==============================
2 Example Celery->HTTP Gateway
3 ==============================
4
5 This is an example service exposing the ability to apply tasks and query
6 statuses/results over HTTP.
7
8 Some familiarity with Django is recommended.
9
10 `settings.py` contains the celery settings, you probably want to configure
11 at least the broker related settings.
12
13 To run the service you have to run the following commands::
14
15 $ python manage.py syncdb # (if running the database backend)
16
17 $ python manage.py runserver
18
19
20 The service is now running at http://localhost:8000
21
22
23 You can apply tasks, with the `/apply/<task_name>` URL::
24
25 $ curl http://localhost:8000/apply/celery.ping/
26 {"ok": "true", "task_id": "e3a95109-afcd-4e54-a341-16c18fddf64b"}
27
28 Then you can use the resulting task-id to get the return value::
29
30 $ curl http://localhost:8000/e3a95109-afcd-4e54-a341-16c18fddf64b/status/
31 {"task": {"status": "SUCCESS", "result": "pong", "id": "e3a95109-afcd-4e54-a341-16c18fddf64b"}}
32
33
34 If you don't want to expose all tasks there're a few possible
35 approaches. For instance you can extend the `apply` view to only
36 accept a white-list. Another possibility is to just make views for every task you want to
37 expose. We made on such view for ping in `views.ping`::
38
39 $ curl http://localhost:8000/ping/
40 {"ok": "true", "task_id": "383c902c-ba07-436b-b0f3-ea09cc22107c"}