haiway 0.16.0__py3-none-any.whl → 0.17.0__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.
haiway/__init__.py CHANGED
@@ -3,7 +3,6 @@ from haiway.context import (
3
3
  Disposables,
4
4
  MetricsContext,
5
5
  MetricsHandler,
6
- MetricsReading,
7
6
  MetricsRecording,
8
7
  MetricsScopeEntering,
9
8
  MetricsScopeExiting,
@@ -76,7 +75,6 @@ __all__ = [
76
75
  "MetricsHandler",
77
76
  "MetricsHolder",
78
77
  "MetricsLogger",
79
- "MetricsReading",
80
78
  "MetricsRecording",
81
79
  "MetricsScopeEntering",
82
80
  "MetricsScopeExiting",
@@ -4,7 +4,6 @@ from haiway.context.identifier import ScopeIdentifier
4
4
  from haiway.context.metrics import (
5
5
  MetricsContext,
6
6
  MetricsHandler,
7
- MetricsReading,
8
7
  MetricsRecording,
9
8
  MetricsScopeEntering,
10
9
  MetricsScopeExiting,
@@ -17,7 +16,6 @@ __all__ = [
17
16
  "Disposables",
18
17
  "MetricsContext",
19
18
  "MetricsHandler",
20
- "MetricsReading",
21
19
  "MetricsRecording",
22
20
  "MetricsScopeEntering",
23
21
  "MetricsScopeExiting",
haiway/context/access.py CHANGED
@@ -513,62 +513,6 @@ class ctx:
513
513
 
514
514
  MetricsContext.record(metric)
515
515
 
516
- @overload
517
- @staticmethod
518
- async def read[Metric: State](
519
- metric: type[Metric],
520
- /,
521
- *,
522
- merged: bool = False,
523
- ) -> Metric | None: ...
524
-
525
- @overload
526
- @staticmethod
527
- async def read[Metric: State](
528
- metric: type[Metric],
529
- /,
530
- *,
531
- merged: bool = False,
532
- default: Metric,
533
- ) -> Metric: ...
534
-
535
- @staticmethod
536
- async def read[Metric: State](
537
- metric: type[Metric],
538
- /,
539
- *,
540
- merged: bool = False,
541
- default: Metric | None = None,
542
- ) -> Metric | None:
543
- """
544
- Read metric within current scope context.
545
-
546
- Parameters
547
- ----------
548
- metric: type[Metric]
549
- type of metric to be read from current context.
550
-
551
- merged: bool
552
- control wheather to merge metrics from nested scopes (True)\
553
- or access only the current scope value (False) without combining them
554
-
555
- default: Metric | None
556
- default value to return when metric was not recorded yet.
557
-
558
- Returns
559
- -------
560
- Metric | None
561
- """
562
-
563
- value: Metric | None = await MetricsContext.read(
564
- metric,
565
- merged=merged,
566
- )
567
- if value is None:
568
- return default
569
-
570
- return value
571
-
572
516
  @staticmethod
573
517
  def log_error(
574
518
  message: str,
haiway/context/metrics.py CHANGED
@@ -9,7 +9,6 @@ from haiway.state import State
9
9
  __all__ = [
10
10
  "MetricsContext",
11
11
  "MetricsHandler",
12
- "MetricsReading",
13
12
  "MetricsRecording",
14
13
  "MetricsScopeEntering",
15
14
  "MetricsScopeExiting",
@@ -26,18 +25,6 @@ class MetricsRecording(Protocol):
26
25
  ) -> None: ...
27
26
 
28
27
 
29
- @runtime_checkable
30
- class MetricsReading(Protocol):
31
- async def __call__[Metric: State](
32
- self,
33
- scope: ScopeIdentifier,
34
- /,
35
- *,
36
- metric: type[Metric],
37
- merged: bool,
38
- ) -> Metric | None: ...
39
-
40
-
41
28
  @runtime_checkable
42
29
  class MetricsScopeEntering(Protocol):
43
30
  def __call__[Metric: State](
@@ -58,7 +45,6 @@ class MetricsScopeExiting(Protocol):
58
45
 
59
46
  class MetricsHandler(State):
60
47
  record: MetricsRecording
61
- read: MetricsReading
62
48
  enter_scope: MetricsScopeEntering
63
49
  exit_scope: MetricsScopeExiting
64
50
 
@@ -114,30 +100,6 @@ class MetricsContext:
114
100
  exception=exc,
115
101
  )
116
102
 
117
- @classmethod
118
- async def read[Metric: State](
119
- cls,
120
- metric: type[Metric],
121
- /,
122
- merged: bool,
123
- ) -> Metric | None:
124
- try: # catch exceptions - we don't wan't to blow up on metrics
125
- metrics: Self = cls._context.get()
126
-
127
- if metrics._metrics is not None:
128
- return await metrics._metrics.read(
129
- metrics._scope,
130
- metric=metric,
131
- merged=merged,
132
- )
133
-
134
- except Exception as exc:
135
- LoggerContext.log_error(
136
- "Failed to read metric: %s",
137
- metric.__qualname__,
138
- exception=exc,
139
- )
140
-
141
103
  __slots__ = (
142
104
  "_metrics",
143
105
  "_scope",
haiway/helpers/metrics.py CHANGED
@@ -105,7 +105,6 @@ class MetricsHolder:
105
105
  store_handler: Self = cls()
106
106
  return MetricsHandler(
107
107
  record=store_handler.record,
108
- read=store_handler.read,
109
108
  enter_scope=store_handler.enter_scope,
110
109
  exit_scope=store_handler.exit_scope,
111
110
  )
@@ -135,23 +134,6 @@ class MetricsHolder:
135
134
 
136
135
  metrics[type(metric)] = metric
137
136
 
138
- async def read[Metric: State](
139
- self,
140
- scope: ScopeIdentifier,
141
- /,
142
- *,
143
- metric: type[Metric],
144
- merged: bool,
145
- ) -> Metric | None:
146
- assert self.root_scope is not None # nosec: B101
147
- assert scope.scope_id in self.scopes # nosec: B101
148
-
149
- if merged:
150
- return self.scopes[scope.scope_id].merged(metric)
151
-
152
- else:
153
- return cast(Metric | None, self.scopes[scope.scope_id].metrics.get(metric))
154
-
155
137
  def enter_scope[Metric: State](
156
138
  self,
157
139
  scope: ScopeIdentifier,
@@ -207,7 +189,6 @@ class MetricsLogger:
207
189
  )
208
190
  return MetricsHandler(
209
191
  record=logger_handler.record,
210
- read=logger_handler.read,
211
192
  enter_scope=logger_handler.enter_scope,
212
193
  exit_scope=logger_handler.exit_scope,
213
194
  )
@@ -251,23 +232,6 @@ class MetricsLogger:
251
232
  ):
252
233
  ctx.log_debug(f"Recorded metric:\n⎡ {type(metric).__qualname__}:{log}\n⌊")
253
234
 
254
- async def read[Metric: State](
255
- self,
256
- scope: ScopeIdentifier,
257
- /,
258
- *,
259
- metric: type[Metric],
260
- merged: bool,
261
- ) -> Metric | None:
262
- assert self.root_scope is not None # nosec: B101
263
- assert scope.scope_id in self.scopes # nosec: B101
264
-
265
- if merged:
266
- return self.scopes[scope.scope_id].merged(metric)
267
-
268
- else:
269
- return cast(Metric | None, self.scopes[scope.scope_id].metrics.get(metric))
270
-
271
235
  def enter_scope[Metric: State](
272
236
  self,
273
237
  scope: ScopeIdentifier,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: haiway
3
- Version: 0.16.0
3
+ Version: 0.17.0
4
4
  Summary: Framework for dependency injection and state management within structured concurrency model.
5
5
  Project-URL: Homepage, https://miquido.com
6
6
  Project-URL: Repository, https://github.com/miquido/haiway.git
@@ -1,18 +1,18 @@
1
- haiway/__init__.py,sha256=XahuBwbI7ZFBBkcbs5882Go7QrzLtEq9XylQzuR1AJY,2125
1
+ haiway/__init__.py,sha256=6MMG7skee77t_K4dPDjL-TDt_6iYa-nQGBTXAGApWJ4,2083
2
2
  haiway/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- haiway/context/__init__.py,sha256=feqd0eJnGQwh4B8BZXpS0fQRE-DqoFCFOHipF1jOY8A,762
4
- haiway/context/access.py,sha256=yfQ65h37FF11-ZbhnjvYTTLnj9dhQx630mzpqcYt_Co,19209
3
+ haiway/context/__init__.py,sha256=ZG9-bareYjGWZGGXChzGs0z0bh4hlisBJ6tDdS5w5Wo,720
4
+ haiway/context/access.py,sha256=SOwr4u7auS_E9Y4t6Bb5Z6ucjQw_1ZQtpyhvbND4A9A,17908
5
5
  haiway/context/disposables.py,sha256=vcsh8jRaJ8Q1ob7oh5LsrSPw9f5AMTcaD_p_Gb7tXAI,2588
6
6
  haiway/context/identifier.py,sha256=lz-FuspOtsaEsfb7QPrEVWYfbcMJgd3A6BGG3kLbaV0,3914
7
7
  haiway/context/logging.py,sha256=F3dr6MLjodg3MX5WTInxn3r3JuihG-giBzumI0GGUQw,5590
8
- haiway/context/metrics.py,sha256=N20XQtC8au_e_3iWrsZdej78YBEIWF44fdtWcZBWono,5223
8
+ haiway/context/metrics.py,sha256=WRcyRHDiHROluyYvnCt_Nk8sZ6-DXT_q-uVhedf_WDI,4244
9
9
  haiway/context/state.py,sha256=61SndKeMF3uS_HNeF-6gZUyVI6f4hi5pUXNG95VZLA8,5981
10
10
  haiway/context/tasks.py,sha256=VjYrsf9OxQb_m0etmEO0BAs0syLGC728E5TjkdMUMEE,2913
11
11
  haiway/context/types.py,sha256=VvJA7wAPZ3ISpgyThVguioYUXqhHf0XkPfRd0M1ERiQ,142
12
12
  haiway/helpers/__init__.py,sha256=ZKDlL3twDqXyI1a9FDgRy3m1-Dfycvke6BJ4C3CndEk,671
13
13
  haiway/helpers/asynchrony.py,sha256=pmPvlH4UiIaHXfQNsHvlDmzu5gCa8Pzc0_gNBAPgirU,6266
14
14
  haiway/helpers/caching.py,sha256=3M5JVI6dq-Xx6qI2DbLw2wek8U7xVjqbCZowldApXnc,13257
15
- haiway/helpers/metrics.py,sha256=VNxgPgV8pgt-51f2CANy1IVx8VMYIAxT3F849t3IeQs,14604
15
+ haiway/helpers/metrics.py,sha256=6F4WYDxm8Pqpq9JZWSw03miMTp4Ew2igGF2LtHJxOQ8,13563
16
16
  haiway/helpers/retries.py,sha256=3m1SsJW_YY_HPufX9LEzcd_MEyRRFNXvSExLeEti8W8,7539
17
17
  haiway/helpers/throttling.py,sha256=r9HnUuo4nX36Pf-oMFHUJk-ZCDeXQ__JTDHlkSltRhA,4121
18
18
  haiway/helpers/timeouted.py,sha256=DthIm4ytKhmiIKf-pcO_vrO1X-ImZh-sLNCWcLY9gfw,3337
@@ -37,7 +37,7 @@ haiway/utils/mimic.py,sha256=BkVjTVP2TxxC8GChPGyDV6UXVwJmiRiSWeOYZNZFHxs,1828
37
37
  haiway/utils/noop.py,sha256=qgbZlOKWY6_23Zs43OLukK2HagIQKRyR04zrFVm5rWI,344
38
38
  haiway/utils/queue.py,sha256=mF0wayKg6MegfBkgxghPDVCbX2rka6sX7KCzQCGl10s,4120
39
39
  haiway/utils/stream.py,sha256=Vqyi0EwcupkVyKQ7eple6z9DkcbSHkE-6yMw85mak9Q,2832
40
- haiway-0.16.0.dist-info/METADATA,sha256=n68Bb5H8FH_CE1uOvZ4u-eYfiuCCrHBOIFXRnPtmmtw,4299
41
- haiway-0.16.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
42
- haiway-0.16.0.dist-info/licenses/LICENSE,sha256=3phcpHVNBP8jsi77gOO0E7rgKeDeu99Pi7DSnK9YHoQ,1069
43
- haiway-0.16.0.dist-info/RECORD,,
40
+ haiway-0.17.0.dist-info/METADATA,sha256=2G26J5-sV_PEm9hJIDfdRVxk41yQILsCJqRF4BJdHWU,4299
41
+ haiway-0.17.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
42
+ haiway-0.17.0.dist-info/licenses/LICENSE,sha256=3phcpHVNBP8jsi77gOO0E7rgKeDeu99Pi7DSnK9YHoQ,1069
43
+ haiway-0.17.0.dist-info/RECORD,,