sovereign 1.0.0b108__py3-none-any.whl → 1.0.0b121__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,13 +20,11 @@ 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
26
+ def __init__(self, *args, **kwargs):
27
+ pass
33
28
 
34
29
  def __enter__(self): # type: ignore
35
30
  return self
@@ -52,17 +47,9 @@ def configure_statsd() -> StatsDProxy:
52
47
  try:
53
48
  from datadog import DogStatsd
54
49
 
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:
50
+ module: Optional[DogStatsd]
51
+ module = DogStatsd()
52
+ if config.enabled and module:
66
53
  module.host = config.host
67
54
  module.port = config.port
68
55
  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)
sovereign/worker.py CHANGED
@@ -62,12 +62,17 @@ if config.sources is not None:
62
62
 
63
63
  def render(job: rendering.RenderJob):
64
64
  log.debug(f"Spawning render process for {job.id}")
65
- Process(target=rendering.generate, args=[job]).start()
65
+ process = Process(target=rendering.generate, args=[job])
66
+ process.start()
67
+ return process
66
68
 
67
69
 
68
70
  async def submit_render(job: rendering.RenderJob):
69
71
  async with RENDER_SEMAPHORE:
70
- render(job)
72
+ process = render(job)
73
+ # Wait for the process to complete to ensure semaphore is held
74
+ # until the actual rendering work is done
75
+ await asyncio.get_event_loop().run_in_executor(None, process.join)
71
76
 
72
77
 
73
78
  async def render_on_event():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sovereign
3
- Version: 1.0.0b108
3
+ Version: 1.0.0b121
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
@@ -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=XKwblg_00TAdr7EjZ9gf7MEzvGR6tQ21bsJ-m-fSJE4,2033
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
- sovereign/worker.py,sha256=NqXlfi9QRlXcWeUPqHWvnYx2CPldY44iLb_fBJAiZ-4,4983
63
- sovereign-1.0.0b108.dist-info/LICENSE.txt,sha256=2X125zvAb9AYLjCgdMDQZuufhm0kwcg31A8pGKj_-VY,560
64
- sovereign-1.0.0b108.dist-info/METADATA,sha256=HknFrhiSn4aRtUyRUxQYqGNkL7617PgNzIV8v5UsEFA,6304
65
- sovereign-1.0.0b108.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
66
- sovereign-1.0.0b108.dist-info/entry_points.txt,sha256=VKJdnnN_HNL8xYQMXsFXfFmN6QkdXMEk5S964avxQJI,1404
67
- sovereign-1.0.0b108.dist-info/RECORD,,
62
+ sovereign/worker.py,sha256=sOVHVVv63I08_KIdaKR0hUnYLMXwoqh9jmsCw8albZE,5230
63
+ sovereign-1.0.0b121.dist-info/LICENSE.txt,sha256=2X125zvAb9AYLjCgdMDQZuufhm0kwcg31A8pGKj_-VY,560
64
+ sovereign-1.0.0b121.dist-info/METADATA,sha256=iPs_H0klgEjiVvrzINuD7-SIek9EsGcqIOJHC5mMP3E,6304
65
+ sovereign-1.0.0b121.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
66
+ sovereign-1.0.0b121.dist-info/entry_points.txt,sha256=VKJdnnN_HNL8xYQMXsFXfFmN6QkdXMEk5S964avxQJI,1404
67
+ sovereign-1.0.0b121.dist-info/RECORD,,