From e74183a78f99c2e93013529b9b1a78c791e2adb7 Mon Sep 17 00:00:00 2001
From: Remi Cresson <remi.cresson@inrae.fr>
Date: Tue, 25 Apr 2023 09:34:03 +0200
Subject: [PATCH 1/3] ENH: can change the TTL margin from environment variable

---
 dinamis_sdk/utils.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dinamis_sdk/utils.py b/dinamis_sdk/utils.py
index 923a324..ed5aab5 100644
--- a/dinamis_sdk/utils.py
+++ b/dinamis_sdk/utils.py
@@ -5,7 +5,7 @@ import json
 import appdirs
 from pydantic import BaseModel  # pylint: disable = no-name-in-module
 
-SIGNED_URL_TTL_MARGIN = 1800  # 30 minutes
+SIGNED_URL_TTL_MARGIN = os.environ.get("DINAMIS_SDK_TTL_MARGIN") or 1800  # 30 minutes
 logging.basicConfig(level=os.environ.get("LOGLEVEL") or "INFO")
 log = logging.getLogger("dinamis_sdk")
 
-- 
GitLab


From 54c11205b13b3bd29452f9139a7c18874121bb25 Mon Sep 17 00:00:00 2001
From: Remi Cresson <remi.cresson@inrae.fr>
Date: Tue, 25 Apr 2023 09:34:25 +0200
Subject: [PATCH 2/3] ADD: TTL margin setting

---
 doc/advanced.md | 13 +++++++++++++
 mkdocs.yml      |  1 +
 2 files changed, 14 insertions(+)
 create mode 100644 doc/advanced.md

diff --git a/doc/advanced.md b/doc/advanced.md
new file mode 100644
index 0000000..0a60a75
--- /dev/null
+++ b/doc/advanced.md
@@ -0,0 +1,13 @@
+# Advanced use
+
+## Signed URLs time to live (TTL) margin
+
+Every signed URL has a TTL, returned by the signing URL API (`expiry`).
+To prevent the expiry of one signed URL during a long process, a margin of 
+1800 seconds (30 minutes) is used by default. This duration can be changed 
+setting the environment variable `DINAMIS_SDK_TTL_MARGIN` to a number of 
+seconds. When one given URL has to be signed again, the cached URL will not be 
+used when the previous TTL minus the margin is negative.
+30 minutes should be enough for most processing, however feel free to increase 
+this value to prevent your long process crashing, if it has started with one 
+URL with a short TTL.
\ No newline at end of file
diff --git a/mkdocs.yml b/mkdocs.yml
index 048cfd1..9d8a8d1 100755
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -26,6 +26,7 @@ plugins:
 nav:
 - Home: index.md
 - Credentials: credentials.md
+- Advanced use: advanced.md
 - Additional resources: additional_resources.md
 - Examples:
   - Processing: processing_examples.md
-- 
GitLab


From be0c03e5c8a1ea7047c43e2cde6c0690c14a81aa Mon Sep 17 00:00:00 2001
From: Remi Cresson <remi.cresson@inrae.fr>
Date: Tue, 25 Apr 2023 09:42:05 +0200
Subject: [PATCH 3/3] ENH: can change the TTL margin from environment variable

---
 dinamis_sdk/utils.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/dinamis_sdk/utils.py b/dinamis_sdk/utils.py
index ed5aab5..817987b 100644
--- a/dinamis_sdk/utils.py
+++ b/dinamis_sdk/utils.py
@@ -5,7 +5,8 @@ import json
 import appdirs
 from pydantic import BaseModel  # pylint: disable = no-name-in-module
 
-SIGNED_URL_TTL_MARGIN = os.environ.get("DINAMIS_SDK_TTL_MARGIN") or 1800  # 30 minutes
+# Signed TTL margin default to 1800 seconds (30 minutes), or env. var.
+SIGNED_URL_TTL_MARGIN = os.environ.get("DINAMIS_SDK_TTL_MARGIN") or 1800
 logging.basicConfig(level=os.environ.get("LOGLEVEL") or "INFO")
 log = logging.getLogger("dinamis_sdk")
 
-- 
GitLab