svc-infra 0.1.610__py3-none-any.whl → 0.1.612__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 svc-infra might be problematic. Click here for more details.

svc_infra/app/README.md CHANGED
@@ -14,9 +14,8 @@ This README shows:
14
14
 
15
15
  ```python
16
16
  # main.py (or wherever your app starts)
17
- from svc_infra.logging.logging import setup_logging
17
+ from svc_infra.app.logging import setup_logging, LogLevelOptions
18
18
  from svc_infra.app.env import pick
19
- from svc_infra.logging.logging import LogLevelOptions
20
19
  ```
21
20
 
22
21
  ---
@@ -39,7 +38,8 @@ What you get by default:
39
38
  Set via code:
40
39
 
41
40
  ```python
42
- from svc_infra.logging.logging import LogFormatOptions, LogLevelOptions
41
+ from svc_infra.app.logging.formats import LogFormatOptions
42
+ from svc_infra.app.logging import LogLevelOptions
43
43
 
44
44
  setup_logging(
45
45
  level=LogLevelOptions.INFO, # or "INFO"
@@ -119,7 +119,7 @@ Old (pre-filter) example:
119
119
 
120
120
  ```python
121
121
  from svc_infra.app.env import pick
122
- from svc_infra.logging.logging import setup_logging, LogLevelOptions
122
+ from svc_infra.app.logging import setup_logging, LogLevelOptions
123
123
 
124
124
  setup_logging(
125
125
  level=pick(
@@ -183,7 +183,7 @@ LOG_DROP_PATHS=/metrics,/health,/healthz
183
183
  ## 7) One-liner quickstart
184
184
 
185
185
  ```python
186
- from svc_infra.logging import setup_logging
186
+ from svc_infra.app.logging import setup_logging
187
187
  setup_logging() # done: sensible defaults + filters in prod/test
188
188
  ```
189
189
 
@@ -80,9 +80,12 @@ def setup_cache(
80
80
  logger.info(f"Cache version updated to: {_current_version}")
81
81
 
82
82
  # Setup backend connection
83
+ # Newer cashews versions require an explicit settings_url; default to in-memory
84
+ # backend when no URL is provided so acceptance/unit tests work out of the box.
83
85
  try:
84
- setup_awaitable = _cache.setup(url) if url else _cache.setup()
85
- logger.info(f"Cache backend setup initiated with URL: {url or 'default'}")
86
+ settings_url = url or "mem://"
87
+ setup_awaitable = _cache.setup(settings_url)
88
+ logger.info(f"Cache backend setup initiated with URL: {settings_url}")
86
89
  except Exception as e:
87
90
  logger.error(f"Failed to setup cache backend: {e}")
88
91
  raise
@@ -98,7 +98,25 @@ def cache_read(
98
98
  ttl_val = validate_ttl(ttl)
99
99
  template = build_key_template(key)
100
100
  namespace = _alias() or ""
101
- tags_func = create_tags_function(tags)
101
+ # Build a tags function that renders any templates against the call kwargs
102
+ base_tags_func = create_tags_function(tags)
103
+
104
+ def tags_func(*_args, **call_kwargs):
105
+ try:
106
+ raw = base_tags_func(*_args, **call_kwargs) or []
107
+ rendered = []
108
+ for t in raw:
109
+ if isinstance(t, str) and ("{" in t and "}" in t):
110
+ try:
111
+ rendered.append(t.format(**call_kwargs))
112
+ except Exception:
113
+ # Best effort: fall back to original
114
+ rendered.append(t)
115
+ else:
116
+ rendered.append(t)
117
+ return rendered
118
+ except Exception:
119
+ return raw if isinstance(raw, list) else []
102
120
 
103
121
  def _decorator(func: Callable[..., Awaitable[Any]]):
104
122
  # Try different cashews cache decorator signatures for compatibility
svc_infra/cache/keys.py CHANGED
@@ -88,12 +88,32 @@ def build_key_variants_renderer(template: str) -> Callable[..., list[str]]:
88
88
 
89
89
 
90
90
  def resolve_tags(tags, *args, **kwargs) -> list[str]:
91
- """Resolve tags from static list or callable."""
91
+ """Resolve tags from static list or callable and render templates with kwargs.
92
+
93
+ Supports entries like "thing:{id}" which will be formatted using provided kwargs.
94
+ Non-string items are passed through as str(). Missing keys are skipped with a warning.
95
+ """
92
96
  try:
97
+ # 1) Obtain raw tags list
93
98
  if callable(tags):
94
- result = tags(*args, **kwargs)
95
- return list(result) if result is not None else []
96
- return list(tags)
99
+ raw = tags(*args, **kwargs)
100
+ raw_list = list(raw) if raw is not None else []
101
+ else:
102
+ raw_list = list(tags)
103
+
104
+ # 2) Render any templates using kwargs
105
+ rendered: list[str] = []
106
+ for t in raw_list:
107
+ try:
108
+ if isinstance(t, str) and ("{" in t and "}" in t):
109
+ rendered.append(t.format(**kwargs))
110
+ else:
111
+ rendered.append(str(t))
112
+ except KeyError as e:
113
+ logger.warning(f"Tag template missing key {e} in '{t}'")
114
+ except Exception as e:
115
+ logger.warning(f"Failed to render tag '{t}': {e}")
116
+ return [r for r in rendered if r]
97
117
  except Exception as e:
98
118
  logger.error(f"Failed to resolve cache tags: {e}")
99
119
  return []
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: svc-infra
3
- Version: 0.1.610
3
+ Version: 0.1.612
4
4
  Summary: Infrastructure for building and deploying prod-ready services
5
5
  License: MIT
6
6
  Keywords: fastapi,sqlalchemy,alembic,auth,infra,async,pydantic
@@ -104,7 +104,7 @@ svc_infra/api/fastapi/routers/ping.py,sha256=71DGaklMAkCL8g_NHdQk9LXG7C_cVem1p8q
104
104
  svc_infra/api/fastapi/setup.py,sha256=zm7mgyhTZVFNbrRaCerBN8fDfglpWStAYLMZHfVmEjU,9574
105
105
  svc_infra/api/fastapi/tenancy/add.py,sha256=47lhWoHjuqbgSckJBTNGz-Mo5R6W7SQ0hQDiOGC0HU0,509
106
106
  svc_infra/api/fastapi/tenancy/context.py,sha256=nYnUKKP88Xy5mZCY7B7ob9PTDAnaKIhrj7pN6s-lBqg,3308
107
- svc_infra/app/README.md,sha256=jWbgyvP90NobTgxlkwyzCZpFOS-zDSkKw0JoRNauCrs,5074
107
+ svc_infra/app/README.md,sha256=MqnKTVjE9txaqlcl41wAv34hWhNfc_fJXCqCTsEWNdk,5070
108
108
  svc_infra/app/__init__.py,sha256=za20ALo_kvJMgf7R_kF98DWk3h9acmvhYrCMhThcSmU,209
109
109
  svc_infra/app/env.py,sha256=AOs4ksLZDXoAWrXeSnkYZ2yyS4UP68QUYfaWDcQ1QfA,4426
110
110
  svc_infra/app/logging/__init__.py,sha256=Nbu2wWySPztxvjW73yIdIi5NEnVNOrOH1PlaUWYIxIM,116
@@ -117,10 +117,10 @@ svc_infra/billing/models.py,sha256=bnCGPKfnK__6x0f0bwKYQsG2GwXjJFi3YRXnq5JYs7c,6
117
117
  svc_infra/billing/service.py,sha256=3SDpPA3NF2lMYiOP4U99sgXpZAXaauexBfZQmYE2kvU,3727
118
118
  svc_infra/cache/README.md,sha256=ZgIpmE0UVlGktp2nXUYv6FKJATCdkR_01v-GGxHN6Ao,10795
119
119
  svc_infra/cache/__init__.py,sha256=Fz3NS81jrY5sLikRhITCeHDT4MlOLcbMed5EjVecSAg,956
120
- svc_infra/cache/backend.py,sha256=Vrza_8oi1AYUG1KdFmxg8S11WB4rKpKI246fZn4pdWs,4233
121
- svc_infra/cache/decorators.py,sha256=1lsQyEEGC3etwqKdh-GxUHmudfoZnVy3UjNTZjDOusA,7606
120
+ svc_infra/cache/backend.py,sha256=-dbZ2qkhebzbKosQqgvBNb01A-2_jGt6_0WmJhPoHy8,4418
121
+ svc_infra/cache/decorators.py,sha256=hsXTcdGo-Q1RKMrqQB0ROmFuce9A1JTt9sJAcWaHvMc,8330
122
122
  svc_infra/cache/demo.py,sha256=MX8LK-4Ju1xAxZtBh-p_Weh8yPNWmmPnDkOW5wAiGKI,2507
123
- svc_infra/cache/keys.py,sha256=6wczoSu4OFBAx4XZdNS94_mParNMox2WTrZRZHgUTpI,3146
123
+ svc_infra/cache/keys.py,sha256=8A122Te4VI40-CpLazEPOBgibX62cyjwClM5SIFeYac,3978
124
124
  svc_infra/cache/recache.py,sha256=adS9OK_dZNGaJKcG0caQlIm449GJ53zd3BkaB_dUF2c,8572
125
125
  svc_infra/cache/resources.py,sha256=BhvPAZvCQ-fitUdniGEOOE4g1ZvljdCA_R5pR8WfJz4,7421
126
126
  svc_infra/cache/tags.py,sha256=9URw4BRlnb4QFAYpDI36fMms6642xq4TeV9jqsEjzE8,2625
@@ -292,7 +292,7 @@ svc_infra/webhooks/fastapi.py,sha256=BCNvGNxukf6dC2a4i-6en-PrjBGV19YvCWOot5lXWsA
292
292
  svc_infra/webhooks/router.py,sha256=6JvAVPMEth_xxHX-IsIOcyMgHX7g1H0OVxVXKLuMp9w,1596
293
293
  svc_infra/webhooks/service.py,sha256=hWgiJRXKBwKunJOx91C7EcLUkotDtD3Xp0RT6vj2IC0,1797
294
294
  svc_infra/webhooks/signing.py,sha256=NCwdZzmravUe7HVIK_uXK0qqf12FG-_MVsgPvOw6lsM,784
295
- svc_infra-0.1.610.dist-info/METADATA,sha256=c9jkkcA2VUAksqH7fyCYQD81SbqHaiI8JVQyf8SQlpA,8106
296
- svc_infra-0.1.610.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
297
- svc_infra-0.1.610.dist-info/entry_points.txt,sha256=6x_nZOsjvn6hRZsMgZLgTasaCSKCgAjsGhACe_CiP0U,48
298
- svc_infra-0.1.610.dist-info/RECORD,,
295
+ svc_infra-0.1.612.dist-info/METADATA,sha256=lsaRaSaDXhaN7O1GaR_f6VkV6CTHXHU7oI9FGDnpLeo,8106
296
+ svc_infra-0.1.612.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
297
+ svc_infra-0.1.612.dist-info/entry_points.txt,sha256=6x_nZOsjvn6hRZsMgZLgTasaCSKCgAjsGhACe_CiP0U,48
298
+ svc_infra-0.1.612.dist-info/RECORD,,