sovereign 1.0.0b107__py3-none-any.whl → 1.0.0b109__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/statistics.py CHANGED
@@ -3,15 +3,12 @@ from typing import Optional, Any, Callable, Dict
3
3
  from functools import wraps
4
4
  from sovereign.schemas import config as sovereign_config
5
5
 
6
- emitted: Dict[str, Any] = dict()
7
-
8
6
  STATSD: Dict[str, Optional["StatsDProxy"]] = {"instance": None}
9
7
 
10
8
 
11
9
  class StatsDProxy:
12
10
  def __init__(self, statsd_instance: Optional[Any] = None) -> None:
13
11
  self.statsd = statsd_instance
14
- self.emitted = emitted
15
12
 
16
13
  def __getattr__(self, item: str) -> Any:
17
14
  if self.statsd is not None:
@@ -23,14 +20,9 @@ class StatsDProxy:
23
20
 
24
21
  def do_nothing(self, *args: Any, **kwargs: Any) -> None:
25
22
  k = args[0]
26
- emitted[k] = emitted.setdefault(k, 0) + 1
27
23
 
28
24
 
29
25
  class StatsdNoop:
30
- def __init__(self, *args: Any, **kwargs: Any) -> None:
31
- k = args[0]
32
- emitted[k] = emitted.setdefault(k, 0) + 1
33
-
34
26
  def __enter__(self): # type: ignore
35
27
  return self
36
28
 
@@ -41,7 +33,6 @@ class StatsdNoop:
41
33
  @wraps(func)
42
34
  def wrapped(*args: Any, **kwargs: Any): # type: ignore
43
35
  return func(*args, **kwargs)
44
-
45
36
  return wrapped
46
37
 
47
38
 
@@ -51,18 +42,9 @@ def configure_statsd() -> StatsDProxy:
51
42
  config = sovereign_config.statsd
52
43
  try:
53
44
  from datadog import DogStatsd
54
-
55
- class CustomStatsd(DogStatsd): # type: ignore
56
- def _report(self, *args, **kwargs) -> None: # type: ignore
57
- super()._report(*args, **kwargs)
58
- # Capture the metric name and increment its count for debugging
59
- if metric := kwargs.get("metric"):
60
- self.emitted: Dict[str, Any] = dict()
61
- self.emitted[metric] = self.emitted.setdefault(metric, 0) + 1
62
-
63
- module: Optional[CustomStatsd]
64
- module = CustomStatsd()
65
- if config.enabled:
45
+ module: Optional[DogStatsd]
46
+ module = DogStatsd()
47
+ if config.enabled and module:
66
48
  module.host = config.host
67
49
  module.port = config.port
68
50
  module.namespace = config.namespace
@@ -10,8 +10,17 @@ from sovereign.schemas import (
10
10
  )
11
11
 
12
12
 
13
- def not_modified() -> Response:
14
- return Response(status_code=304)
13
+ def response_headers(
14
+ discovery_request: DiscoveryRequest, response: cache.Entry, xds: str
15
+ ) -> dict[str, str]:
16
+ return {
17
+ "X-Sovereign-Client-Build": discovery_request.envoy_version,
18
+ "X-Sovereign-Client-Version": discovery_request.version_info,
19
+ "X-Sovereign-Requested-Resources": ",".join(discovery_request.resource_names)
20
+ or "all",
21
+ "X-Sovereign-Requested-Type": xds,
22
+ "X-Sovereign-Response-Version": response.version,
23
+ }
15
24
 
16
25
 
17
26
  router = APIRouter()
@@ -51,11 +60,12 @@ async def discovery_response(
51
60
  XDS_CLIENT_VERSION=xds_req.version_info,
52
61
  XDS_SERVER_VERSION=entry.version,
53
62
  )
63
+ headers = response_headers(xds_req, entry, xds_type)
54
64
  if entry.len == 0:
55
- return Response(status_code=404)
65
+ return Response(status_code=404, headers=headers)
56
66
  if entry.version == xds_req.version_info:
57
- return not_modified()
58
- return Response(entry.text, media_type="application/json")
67
+ return Response(status_code=304, headers=headers)
68
+ return Response(entry.text, media_type="application/json", headers=headers)
59
69
 
60
70
  if entry := await cache.blocking_read(xds_req):
61
71
  return handle_response(entry)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sovereign
3
- Version: 1.0.0b107
3
+ Version: 1.0.0b109
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
@@ -41,7 +41,7 @@ Requires-Dist: cashews[redis] (>=6.3.0,<7.0.0) ; extra == "caching"
41
41
  Requires-Dist: croniter (>=1.4.1,<2.0.0)
42
42
  Requires-Dist: cryptography (>=45.0.2)
43
43
  Requires-Dist: datadog (>=0.50.1) ; extra == "statsd"
44
- Requires-Dist: fastapi (>=0.115.2,<0.116.0)
44
+ Requires-Dist: fastapi (>=0.116.0,<0.117.0)
45
45
  Requires-Dist: glom (>=23.3.0,<24.0.0)
46
46
  Requires-Dist: h11 (>=0.16.0,<0.17.0)
47
47
  Requires-Dist: httptools (>=0.6.0,<0.7.0) ; extra == "httptools"
@@ -52,6 +52,7 @@ Requires-Dist: pydantic-settings (<2.6.0)
52
52
  Requires-Dist: redis (<=5.0.0)
53
53
  Requires-Dist: requests (>=2.32.4,<3.0.0)
54
54
  Requires-Dist: sentry-sdk (>=2.14.0,<3.0.0) ; extra == "sentry"
55
+ Requires-Dist: starlette (>=0.47.2,<0.48.0)
55
56
  Requires-Dist: starlette-context (>=0.3.6,<0.4.0)
56
57
  Requires-Dist: structlog (>=23.1.0,<24.0.0)
57
58
  Requires-Dist: supervisor (>=4.2.5,<5.0.0)
@@ -28,7 +28,7 @@ sovereign/static/node_expression.js,sha256=dL9QLM49jorqavf3Qtye6E1QTWYDT1rFI0tQR
28
28
  sovereign/static/panel.js,sha256=i5mGExjv-I4Gtt9dQiTyFwPZa8pg5rXeuTeidXNUiTE,2695
29
29
  sovereign/static/sass/style.scss,sha256=tPHPEm3sZeBFGDyyn3pHcA-nbaKT-h-UsSTsf6dHNDU,1158
30
30
  sovereign/static/style.css,sha256=vG8HPsbCbPIZfHgy7gSeof97Pnp0okkyaXyJzIEEW-8,447517
31
- sovereign/statistics.py,sha256=-me83Bkfya5vQai3Irrf5R-RNG-XE7wlyqQFqKeueFo,2666
31
+ sovereign/statistics.py,sha256=OGhya1KMeFv5sNpYJz2dVrbFqBDo3M9Ss_3pVMrfBxo,1976
32
32
  sovereign/templates/base.html,sha256=5vw3-NmN291pXRdArpCwhSce9bAYBWCJVRhvO5EmE9g,2296
33
33
  sovereign/templates/err.html,sha256=a3cEzOqyqWOIe3YxfTEjkxbTfxBxq1knD6GwzEFljfs,603
34
34
  sovereign/templates/resources.html,sha256=QaZ1S38JhAZg3-PfQS1cAKhCczVLXw9e4pztBrqr4qs,40217
@@ -56,12 +56,12 @@ sovereign/utils/weighted_clusters.py,sha256=bPzuRE7Qgvv04HcR2AhMDvBrFlZ8AfteweLK
56
56
  sovereign/views/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
57
57
  sovereign/views/api.py,sha256=jKVjSvi0Tr1HHix3hc0H8yGZoyDind2sJ4w7a4pJvy0,2168
58
58
  sovereign/views/crypto.py,sha256=7y0eHWtt-bbr2CwHEkH7odPaJ1IEviU-71U-MYJD0Kc,3360
59
- sovereign/views/discovery.py,sha256=4sVRPWpH8nYwY26GWK9N8maOYUNbIJTrUckZ3MahqAU,1876
59
+ sovereign/views/discovery.py,sha256=B_D1ckfbN1dSKBvuFCTyfB79GUUriCADTB53OwZ8D4Q,2409
60
60
  sovereign/views/healthchecks.py,sha256=TaXbxkX679jyQ8v5FxtBa2Qa0Z7KuqQ10WgAqfuVGUc,1743
61
61
  sovereign/views/interface.py,sha256=FmQ7LiUPLSvkEDOKCncrnKMD9g1lJKu-DQNbbyi8mqk,6346
62
62
  sovereign/worker.py,sha256=NqXlfi9QRlXcWeUPqHWvnYx2CPldY44iLb_fBJAiZ-4,4983
63
- sovereign-1.0.0b107.dist-info/LICENSE.txt,sha256=2X125zvAb9AYLjCgdMDQZuufhm0kwcg31A8pGKj_-VY,560
64
- sovereign-1.0.0b107.dist-info/METADATA,sha256=r01WJzQCvbZ3YXhs-xsehoOMcpPM5sguHhCXOTCJmyA,6260
65
- sovereign-1.0.0b107.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
66
- sovereign-1.0.0b107.dist-info/entry_points.txt,sha256=VKJdnnN_HNL8xYQMXsFXfFmN6QkdXMEk5S964avxQJI,1404
67
- sovereign-1.0.0b107.dist-info/RECORD,,
63
+ sovereign-1.0.0b109.dist-info/LICENSE.txt,sha256=2X125zvAb9AYLjCgdMDQZuufhm0kwcg31A8pGKj_-VY,560
64
+ sovereign-1.0.0b109.dist-info/METADATA,sha256=aBxCeJJ7LVqOxmWrNhwQuGu27tKosk58o0WHS2af3lc,6304
65
+ sovereign-1.0.0b109.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
66
+ sovereign-1.0.0b109.dist-info/entry_points.txt,sha256=VKJdnnN_HNL8xYQMXsFXfFmN6QkdXMEk5S964avxQJI,1404
67
+ sovereign-1.0.0b109.dist-info/RECORD,,