Skip to content

Commit 6305a1a

Browse files
committed
remove 3.9
Signed-off-by: Filinto Duran <1373693+filintod@users.noreply.github.com>
1 parent c44c28d commit 6305a1a

File tree

6 files changed

+139
-16
lines changed

6 files changed

+139
-16
lines changed

.github/workflows/build-push-to-main.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v5
14-
- name: Set up Python 3.9
14+
- name: Set up Python 3.10
1515
uses: actions/setup-python@v6
1616
with:
17-
python-version: 3.9
17+
python-version: 3.10
1818
- name: Install dependencies
1919
run: |
2020
python -m pip install --upgrade pip
@@ -37,7 +37,7 @@ jobs:
3737
strategy:
3838
fail-fast: false
3939
matrix:
40-
python_ver: ["3.9", "3.10", "3.11", "3.12", "3.13"]
40+
python_ver: ["3.10", "3.11", "3.12", "3.13"]
4141
steps:
4242
- uses: actions/checkout@v5
4343
- name: Set up Python ${{ matrix.python_ver }}
@@ -64,10 +64,10 @@ jobs:
6464
TWINE_USERNAME: "__token__"
6565
steps:
6666
- uses: actions/checkout@v5
67-
- name: Set up Python 3.9
67+
- name: Set up Python 3.10
6868
uses: actions/setup-python@v6
6969
with:
70-
python-version: 3.9
70+
python-version: 3.10
7171
- name: Install dependencies
7272
run: |
7373
python -m pip install --upgrade pip

.github/workflows/build-tag.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- uses: actions/checkout@v5
18-
- name: Set up Python 3.9
18+
- name: Set up Python 3.10
1919
uses: actions/setup-python@v6
2020
with:
21-
python-version: 3.9
21+
python-version: 3.10
2222
- name: Install dependencies
2323
run: |
2424
python -m pip install --upgrade pip
@@ -41,7 +41,7 @@ jobs:
4141
strategy:
4242
fail-fast: false
4343
matrix:
44-
python_ver: ["3.9", "3.10", "3.11", "3.12", "3.13"]
44+
python_ver: ["3.10", "3.11", "3.12", "3.13"]
4545
steps:
4646
- uses: actions/checkout@v5
4747
- name: Set up Python ${{ matrix.python_ver }}
@@ -68,10 +68,10 @@ jobs:
6868
TWINE_USERNAME: "__token__"
6969
steps:
7070
- uses: actions/checkout@v5
71-
- name: Set up Python 3.9
71+
- name: Set up Python 3.10
7272
uses: actions/setup-python@v6
7373
with:
74-
python-version: 3.9
74+
python-version: 3.10
7575
- name: Install dependencies
7676
run: |
7777
python -m pip install --upgrade pip

.github/workflows/build.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ jobs:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- uses: actions/checkout@v5
20-
- name: Set up Python 3.9
20+
- name: Set up Python 3.10
2121
uses: actions/setup-python@v6
2222
with:
23-
python-version: 3.9
23+
python-version: 3.10
2424
- name: Install dependencies
2525
run: |
2626
python -m pip install --upgrade pip
@@ -43,7 +43,7 @@ jobs:
4343
strategy:
4444
fail-fast: false
4545
matrix:
46-
python_ver: ["3.9", "3.10", "3.11", "3.12", "3.13"]
46+
python_ver: ["3.10", "3.11", "3.12", "3.13"]
4747
steps:
4848
- uses: actions/checkout@v5
4949
- name: Set up Python ${{ matrix.python_ver }}

.github/workflows/validate_examples.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
strategy:
4747
fail-fast: false
4848
matrix:
49-
python_ver: ["3.9", "3.10", "3.11", "3.12", "3.13"]
49+
python_ver: ["3.10", "3.11", "3.12", "3.13"]
5050
steps:
5151
- name: Parse repository_dispatch payload
5252
if: github.event_name == 'repository_dispatch'
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
import json
2+
import os
3+
from typing import Any, Iterable, Optional
4+
5+
6+
def _get_env_bool(name: str, default: bool) -> bool:
7+
""" helper to convert the environment variable to a bool"""
8+
val = os.environ.get(name)
9+
if val is None:
10+
return default
11+
return val.strip().lower() in {"1", "true", "t", "yes", "y"}
12+
13+
14+
def _get_env_int(name: str, default: int) -> int:
15+
""" helper to convert the env var to an int or if we could not to the default value given """
16+
val = os.environ.get(name)
17+
if val is None:
18+
return default
19+
try:
20+
return int(val)
21+
except Exception:
22+
return default
23+
24+
25+
def _get_env_float(name: str, default: float) -> float:
26+
""" helper to convert the env var to a float or if we could not to the default value given """
27+
val = os.environ.get(name)
28+
if val is None:
29+
return default
30+
try:
31+
return float(val)
32+
except Exception:
33+
return default
34+
35+
36+
def _get_env_csv(name: str, default_csv: str) -> list[str]:
37+
""" helper to convert the env var to a list or if we could not to the default value given """
38+
val = os.environ.get(name, default_csv)
39+
return [s.strip().upper() for s in val.split(",") if s.strip()]
40+
41+
42+
def get_grpc_keepalive_options() -> list[tuple[str, Any]]:
43+
"""Build gRPC keepalive channel options from environment variables.
44+
45+
Environment variables (defaults in parentheses):
46+
- DAPR_GRPC_KEEPALIVE_ENABLED (false)
47+
- DAPR_GRPC_KEEPALIVE_TIME_MS (120000)
48+
- DAPR_GRPC_KEEPALIVE_TIMEOUT_MS (20000)
49+
- DAPR_GRPC_KEEPALIVE_PERMIT_WITHOUT_CALLS (false)
50+
"""
51+
enabled = _get_env_bool("DAPR_GRPC_KEEPALIVE_ENABLED", False)
52+
if not enabled:
53+
return []
54+
time_ms = _get_env_int("DAPR_GRPC_KEEPALIVE_TIME_MS", 120000)
55+
timeout_ms = _get_env_int("DAPR_GRPC_KEEPALIVE_TIMEOUT_MS", 20000)
56+
permit_without_calls = (
57+
1 if _get_env_bool("DAPR_GRPC_KEEPALIVE_PERMIT_WITHOUT_CALLS", False) else 0
58+
)
59+
return [
60+
("grpc.keepalive_time_ms", time_ms),
61+
("grpc.keepalive_timeout_ms", timeout_ms),
62+
("grpc.keepalive_permit_without_calls", permit_without_calls),
63+
]
64+
65+
66+
def get_grpc_retry_service_config_option() -> Optional[tuple[str, str]]:
67+
"""Return ("grpc.service_config", json_str) if retry is enabled via env; else None.
68+
69+
Environment variables (defaults in parentheses):
70+
- DAPR_GRPC_RETRY_ENABLED (false)
71+
- DAPR_GRPC_RETRY_MAX_ATTEMPTS (4)
72+
- DAPR_GRPC_RETRY_INITIAL_BACKOFF_MS (100)
73+
- DAPR_GRPC_RETRY_MAX_BACKOFF_MS (1000)
74+
- DAPR_GRPC_RETRY_BACKOFF_MULTIPLIER (2.0)
75+
- DAPR_GRPC_RETRY_CODES (UNAVAILABLE,DEADLINE_EXCEEDED)
76+
"""
77+
enabled = _get_env_bool("DAPR_GRPC_RETRY_ENABLED", False)
78+
if not enabled:
79+
return None
80+
81+
max_attempts = _get_env_int("DAPR_GRPC_RETRY_MAX_ATTEMPTS", 4)
82+
initial_backoff_ms = _get_env_int("DAPR_GRPC_RETRY_INITIAL_BACKOFF_MS", 100)
83+
max_backoff_ms = _get_env_int("DAPR_GRPC_RETRY_MAX_BACKOFF_MS", 1000)
84+
backoff_multiplier = _get_env_float("DAPR_GRPC_RETRY_BACKOFF_MULTIPLIER", 2.0)
85+
codes = _get_env_csv("DAPR_GRPC_RETRY_CODES", "UNAVAILABLE,DEADLINE_EXCEEDED")
86+
87+
# service_config ref => https://github.com/grpc/grpc-proto/blob/master/grpc/service_config/service_config.proto#L44
88+
service_config = {
89+
"methodConfig": [
90+
{
91+
"name": [{"service": ""}], # match all services/methods
92+
"retryPolicy": {
93+
"maxAttempts": max_attempts,
94+
"initialBackoff": f"{initial_backoff_ms / 1000.0}s",
95+
"maxBackoff": f"{max_backoff_ms / 1000.0}s",
96+
"backoffMultiplier": backoff_multiplier,
97+
"retryableStatusCodes": codes,
98+
},
99+
}
100+
]
101+
}
102+
# we are not applying retry throttling policy (but a user can pass the whole option string via options)
103+
return "grpc.service_config", json.dumps(service_config)
104+
105+
106+
def build_grpc_channel_options(
107+
base_options: Optional[Iterable[tuple[str, Any]]] = None,
108+
) -> Optional[list[tuple[str, Any]]]:
109+
"""Combine base options + env-driven keepalive and retry service config.
110+
111+
The returned list is safe to pass as the `options` argument to grpc.secure_channel/insecure_channel.
112+
"""
113+
combined: list[tuple[str, Any]] = []
114+
if base_options:
115+
combined.extend(list(base_options))
116+
117+
keepalive = get_grpc_keepalive_options()
118+
if keepalive:
119+
combined.extend(keepalive)
120+
retry_opt = get_grpc_retry_service_config_option()
121+
if retry_opt is not None:
122+
combined.append(retry_opt)
123+
return combined if combined else None

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[tox]
22
skipsdist = True
3-
minversion = 3.9.0
3+
minversion = 3.10.0
44
envlist =
5-
py{39,310,311,312,313}
5+
py{310,311,312,313}
66
ruff,
77
mypy,
88

0 commit comments

Comments
 (0)