Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MSN-2665] Set env var default to None #51

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Additionally, you can configure with more settings or environment variables:
- `DJANGO_CLOUD_TASKS_SUBSCRIBERS_URL_NAME`: Django URL-name that process Subscribers. We provide a view for that, but if you want to create your own, set this value. Default: `subscriptions-endpoint`.
- `DJANGO_CLOUD_TASKS_PROPAGATED_HEADERS`: . Default: `["traceparent"]`.
- `DJANGO_CLOUD_TASKS_PROPAGATED_HEADERS_KEY`: when propagating headers in PubSub, use a key to store the values in the Message data. Default: `_http_headers`.
- `DJANGO_CLOUD_TASKS_MAXIMUM_ETA_TASK`: maximum time in seconds to schedule a task in the future. Default: `86400`.
- `DJANGO_CLOUD_TASKS_MAXIMUM_ETA_TASK`: maximum time in seconds to schedule a task in the future. Default: `None`. In [GCP documentation](https://cloud.google.com/tasks/docs/quotas) the maximum schedule time for a task is 30 days from current date and time.

## On Demand Task

Expand Down
2 changes: 1 addition & 1 deletion django_cloud_tasks/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self, *args, **kwargs):
self.delimiter = self._fetch_config(name="DELIMITER", default="--")
self.eager = self._fetch_config(name="EAGER", default=False)
self.tasks_url_name = self._fetch_config(name="URL_NAME", default="tasks-endpoint")
self.tasks_max_eta = self._fetch_config(name="MAXIMUM_ETA_TASK", default=60 * 60 * 24) # 1 day
self.tasks_max_eta = self._fetch_config(name="MAXIMUM_ETA_TASK", default=None)
self.subscribers_url_name = self._fetch_config(name="SUBSCRIBERS_URL_NAME", default="subscriptions-endpoint")

self.subscribers_max_retries = self._fetch_config(name="SUBSCRIBER_MAX_RETRIES", default=None)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "django-google-cloud-tasks"
version = "2.16.0"
version = "2.16.1"
description = "Async Tasks with HTTP endpoints"
authors = ["Joao Daher <[email protected]>"]
packages = [
Expand Down
7 changes: 5 additions & 2 deletions sample_project/sample_app/tests/tests_tasks/tests_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,13 @@ def test_task_later_delay_exceeds_maximum_eta(self):
task_kwargs = dict(price=30, quantity=4, discount=0.2)
excessive_delay = int(60 * 60 * 24 * 2) # 2 days

with self.assertRaises(ValueError) as context:
max_eta_task = 60 * 60 * 24 # 1 day
with (
patch("django_cloud_tasks.tasks.task.get_config", return_value=max_eta_task),
self.assertRaises(ValueError) as context,
):
tasks.CalculatePriceTask.later(eta=excessive_delay, task_kwargs=task_kwargs)

max_eta_task = get_config("tasks_max_eta")
self.assertEqual(f"Invalid delay time {excessive_delay}, maximum is {max_eta_task}", str(context.exception))

def test_singleton_client_on_task(self):
Expand Down
Loading