sovereign 0.25.0__py3-none-any.whl → 0.25.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of sovereign might be problematic. Click here for more details.

sovereign/__init__.py CHANGED
@@ -53,7 +53,9 @@ DIST_NAME = "sovereign"
53
53
  __version__ = version(DIST_NAME)
54
54
  config_path = os.getenv("SOVEREIGN_CONFIG", "file:///etc/sovereign.yaml")
55
55
 
56
- html_templates = Jinja2Templates(get_package_file(DIST_NAME, "templates")) # type: ignore[arg-type]
56
+ html_templates = Jinja2Templates(
57
+ directory=str(get_package_file(DIST_NAME, "templates"))
58
+ )
57
59
 
58
60
  try:
59
61
  config = SovereignConfigv2(**parse_raw_configuration(config_path))
sovereign/schemas.py CHANGED
@@ -367,6 +367,8 @@ class SovereignAsgiConfig(BaseSettings):
367
367
  worker_timeout: int = 30
368
368
  worker_tmp_dir: str = "/dev/shm"
369
369
  graceful_timeout: int = worker_timeout * 2
370
+ max_requests: int = 0
371
+ max_requests_jitter: int = 0
370
372
 
371
373
  class Config:
372
374
  fields = {
@@ -377,6 +379,8 @@ class SovereignAsgiConfig(BaseSettings):
377
379
  "threads": {"env": "SOVEREIGN_THREADS"},
378
380
  "preload_app": {"env": "SOVEREIGN_PRELOAD"},
379
381
  "worker_timeout": {"env": "SOVEREIGN_WORKER_TIMEOUT"},
382
+ "max_requests": {"env": "SOVEREIGN_MAX_REQUESTS"},
383
+ "max_requests_jitter": {"env": "SOVEREIGN_MAX_REQUESTS_JITTER"},
380
384
  }
381
385
 
382
386
  def as_gunicorn_conf(self) -> Dict[str, Any]:
@@ -392,6 +396,8 @@ class SovereignAsgiConfig(BaseSettings):
392
396
  "worker_class": self.worker_class,
393
397
  "worker_tmp_dir": self.worker_tmp_dir,
394
398
  "graceful_timeout": self.graceful_timeout,
399
+ "max_requests": self.max_requests,
400
+ "max_requests_jitter": self.max_requests_jitter,
395
401
  }
396
402
 
397
403
 
@@ -1,12 +1,13 @@
1
- from typing import List, Dict, Any
2
1
  from collections import defaultdict
3
- from fastapi import APIRouter, Query, Path, Cookie
2
+ from typing import Any, Dict, List
3
+
4
+ from fastapi import APIRouter, Cookie, Path, Query
4
5
  from fastapi.encoders import jsonable_encoder
5
6
  from fastapi.requests import Request
6
- from fastapi.responses import RedirectResponse, JSONResponse, Response
7
- from sovereign import html_templates, XDS_TEMPLATES
7
+ from fastapi.responses import HTMLResponse, JSONResponse, RedirectResponse, Response
8
+
9
+ from sovereign import XDS_TEMPLATES, html_templates, json_response_class, poller
8
10
  from sovereign.discovery import DiscoveryTypes
9
- from sovereign import poller, json_response_class
10
11
  from sovereign.utils.mock import mock_discovery_request
11
12
  from sovereign.views.discovery import perform_discovery
12
13
 
@@ -16,23 +17,23 @@ all_types = [t.value for t in DiscoveryTypes]
16
17
 
17
18
 
18
19
  @router.get("/")
19
- async def ui_main(request: Request) -> Response:
20
+ async def ui_main(request: Request) -> HTMLResponse:
20
21
  try:
21
22
  return html_templates.TemplateResponse(
23
+ request=request,
22
24
  name="base.html",
23
25
  media_type="text/html",
24
26
  context={
25
- "request": request,
26
27
  "all_types": all_types,
27
28
  "last_update": str(poller.last_updated),
28
29
  },
29
30
  )
30
31
  except IndexError:
31
32
  return html_templates.TemplateResponse(
33
+ request=request,
32
34
  name="err.html",
33
35
  media_type="text/html",
34
36
  context={
35
- "request": request,
36
37
  "title": "No resource types configured",
37
38
  "message": "A template should be defined for every resource "
38
39
  "type that you want your envoy proxies to discover.",
@@ -88,7 +89,7 @@ async def resources(
88
89
  envoy_version: str = Cookie(
89
90
  "__any__", title="The clients envoy version to emulate in this XDS request"
90
91
  ),
91
- ) -> Response:
92
+ ) -> HTMLResponse:
92
93
  ret: Dict[str, List[Dict[str, Any]]] = defaultdict(list)
93
94
  try:
94
95
  response = await perform_discovery(
@@ -107,11 +108,11 @@ async def resources(
107
108
  else:
108
109
  ret["resources"] += response.deserialize_resources()
109
110
  return html_templates.TemplateResponse(
111
+ request=request,
110
112
  name="resources.html",
111
113
  media_type="text/html",
112
114
  context={
113
115
  "resources": ret["resources"],
114
- "request": request,
115
116
  "resource_type": xds_type,
116
117
  "all_types": all_types,
117
118
  "version": envoy_version,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sovereign
3
- Version: 0.25.0
3
+ Version: 0.25.2
4
4
  Summary: Envoy Proxy control-plane written in Python
5
5
  Home-page: https://pypi.org/project/sovereign/
6
6
  License: Apache-2.0
@@ -39,11 +39,11 @@ Requires-Dist: cashews[redis] (>=6.3.0,<7.0.0) ; extra == "caching"
39
39
  Requires-Dist: croniter (>=1.4.1,<2.0.0)
40
40
  Requires-Dist: cryptography (>=41.0.4,<42.0.0)
41
41
  Requires-Dist: datadog (>=0.47.0,<0.48.0) ; extra == "statsd"
42
- Requires-Dist: fastapi (>=0.99.1,<0.100.0)
42
+ Requires-Dist: fastapi (>=0.110.0,<0.111.0)
43
43
  Requires-Dist: glom (>=23.3.0,<24.0.0)
44
44
  Requires-Dist: gunicorn (>=21.2.0,<22.0.0)
45
45
  Requires-Dist: httptools (>=0.6.0,<0.7.0) ; extra == "httptools"
46
- Requires-Dist: orjson (>=3.9.7,<4.0.0) ; extra == "orjson"
46
+ Requires-Dist: orjson (>=3.9.15,<4.0.0) ; extra == "orjson"
47
47
  Requires-Dist: redis (<=5.0.0)
48
48
  Requires-Dist: requests (>=2.31.0,<3.0.0)
49
49
  Requires-Dist: sentry-sdk (>=1.23.1,<2.0.0) ; extra == "sentry"
@@ -1,4 +1,4 @@
1
- sovereign/__init__.py,sha256=a8bCatvhtIQEw3_gZCdAbzXKP3fwA1AtyPlez-wQvGE,3274
1
+ sovereign/__init__.py,sha256=wwpeI6VR7n03N5tIg85jb9ME6Ef-rdzNPZODMlMx5so,3269
2
2
  sovereign/app.py,sha256=uozeEQJjefBUV6dZfIooTBJgDhEE4bd2ozRxWVdVMK4,4085
3
3
  sovereign/config_loader.py,sha256=ZLKlyuvJ8Wqhsg6xZI-zp_5ABslB3Tc9zEdpds7-d7Q,6349
4
4
  sovereign/configuration.py,sha256=thiNe_6x3wR8wc4Jy0aeBlQe3kSsIqpTOIlOoxp5UJg,2497
@@ -16,7 +16,7 @@ sovereign/modifiers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSu
16
16
  sovereign/modifiers/lib.py,sha256=DbXsxrrjnFE4Y7rbwpeiM5tS5w5NBwSdYH58AtDTP0I,2884
17
17
  sovereign/modifiers/test.py,sha256=7_c2hWXn_sYJ6997N1_uSWtClOikcOzu1yRCY56-l-4,361
18
18
  sovereign/response_class.py,sha256=beMAFV-4L6DwyWzJzy71GkEW4gb7fzH1jd8-Tul13cU,427
19
- sovereign/schemas.py,sha256=JsL_qL5dMhiAH2FB9UHb9nkRT4sUcT5qwuk129pNm3o,28718
19
+ sovereign/schemas.py,sha256=FL0iQAftCVVFOL7r_l9scqllyMum0g2AD0qhMyONyg0,29025
20
20
  sovereign/server.py,sha256=z8Uz1UYIZix0S40Srk774WIMDN2jl2SozO8irib0wc4,1402
21
21
  sovereign/sources/__init__.py,sha256=g9hEpFk8j5i1ApHQpbc9giTyJW41Ppgsqv5P9zGxOJk,78
22
22
  sovereign/sources/file.py,sha256=A4UWoRU39v2Ex5Mtdl_uw53iMkslYylF4CiiwW7LOpk,689
@@ -53,9 +53,9 @@ sovereign/views/admin.py,sha256=GtjSipSfLwrvU1axX3pJfJXiSO82e2pkw8izykZNtGA,4306
53
53
  sovereign/views/crypto.py,sha256=o8NSyiUBy7v1pMOXt_1UBi68FNcGkXSlEVg9C18y8kY,3324
54
54
  sovereign/views/discovery.py,sha256=TVvWTMzWydsC-SNKL9WsSss_Hfnt2Ed4SVC2A8Na7Jo,5932
55
55
  sovereign/views/healthchecks.py,sha256=_WkMunlrFpqGTLgtNtRr7gCsDCv5kiuYxCyTi-dMEKM,1357
56
- sovereign/views/interface.py,sha256=Y2fbR26cSF8eKQHfTbnv5WKEdgqaGNwys0lEGUTjXqw,7041
57
- sovereign-0.25.0.dist-info/LICENSE.txt,sha256=2X125zvAb9AYLjCgdMDQZuufhm0kwcg31A8pGKj_-VY,560
58
- sovereign-0.25.0.dist-info/METADATA,sha256=vIWzrbn5aJUnPeNtlqJkGvb3bdJBO_f-SDOT07TRjYU,6463
59
- sovereign-0.25.0.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
60
- sovereign-0.25.0.dist-info/entry_points.txt,sha256=kOn848ucVbNvtsGABDuwzOHmNiOb0Ey8dV85Z3dLv3Y,222
61
- sovereign-0.25.0.dist-info/RECORD,,
56
+ sovereign/views/interface.py,sha256=Xi5F36Zn7ATbMtuhlE8f9xTEKj9T7GzHg6XLdb3bQjY,7023
57
+ sovereign-0.25.2.dist-info/LICENSE.txt,sha256=2X125zvAb9AYLjCgdMDQZuufhm0kwcg31A8pGKj_-VY,560
58
+ sovereign-0.25.2.dist-info/METADATA,sha256=U5K9Wu30LfB9NpQn0w2VCkPd799ixlNHTZKNjZa1Gyw,6465
59
+ sovereign-0.25.2.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
60
+ sovereign-0.25.2.dist-info/entry_points.txt,sha256=kOn848ucVbNvtsGABDuwzOHmNiOb0Ey8dV85Z3dLv3Y,222
61
+ sovereign-0.25.2.dist-info/RECORD,,