Skip to content

Commit

Permalink
Run Huey tasks asynchronously in most environments
Browse files Browse the repository at this point in the history
The review apps have a Redis available, they can use the same settings
as production and demo environments.

Fast machines are made to run scripts, that could possibly send emails.
Make sure the tasks are run immediately.

The test environment remains in immediate mode to facilitate
testing the results of a task inside a test.

The development environment remains in immediate mode, to avoid
requiring developers to spawn a consumer.
  • Loading branch information
francoisfreitag committed Jun 25, 2024
1 parent 8bc7ce6 commit 8186cb2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,15 +462,17 @@
}

HUEY = {
"name": "ITOU",
# Use value from CleverCloud deployment config, or a value per REVIEW-APP.
"name": os.getenv("HUEY_QUEUE_NAME", DATABASES["default"]["NAME"]),
# Don't store task results (see our Redis Post-Morten in documentation for more information)
"results": False,
"url": f"{redis_url}/?db={redis_db}",
"consumer": {
"workers": 2,
"worker_type": "thread",
},
"immediate": ITOU_ENVIRONMENT not in (ItouEnvironment.DEMO, ItouEnvironment.PROD),
# Send emails immediately in FAST-MACHINE, there are no queue consumers in that environment.
"immediate": ITOU_ENVIRONMENT != ItouEnvironment.FAST_MACHINE,
}

MAILJET_API_KEY_PRINCIPAL = os.getenv("API_MAILJET_KEY_PRINCIPAL")
Expand Down
2 changes: 2 additions & 0 deletions config/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
DATABASES["default"]["USER"] = os.getenv("PGUSER", "postgres") # noqa: F405
DATABASES["default"]["PASSWORD"] = os.getenv("PGPASSWORD", "password") # noqa: F405

HUEY["immediate"] = True # noqa: F405

MAILJET_API_KEY_PRINCIPAL = "API_MAILJET_KEY_PRINCIPAL"
MAILJET_SECRET_KEY_PRINCIPAL = "API_MAILJET_SECRET_PRINCIPAL"

Expand Down

0 comments on commit 8186cb2

Please sign in to comment.