engin 0.0.9__py3-none-any.whl → 0.0.10__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.
engin/_assembler.py CHANGED
@@ -152,6 +152,8 @@ class Assembler:
152
152
  if type_id.multi:
153
153
  LOG.warning(f"no provider for '{type_id}' defaulting to empty list")
154
154
  providers = [(Supply([], type_hint=list[type_id.type]))] # type: ignore[name-defined]
155
+ # store default to prevent the warning appearing multiple times
156
+ self._multiproviders[type_id] = providers
155
157
  else:
156
158
  raise LookupError(f"No Provider registered for dependency '{type_id}'")
157
159
 
engin/_engin.py CHANGED
@@ -39,6 +39,7 @@ class Engin:
39
39
  but for advanced usecases it can be easier to use the `start` and `stop` methods.
40
40
 
41
41
  When ran the Engin takes care of the complete application lifecycle:
42
+
42
43
  1. The Engin assembles all Invocations. Only Providers that are required to satisfy
43
44
  the Invoke options parameters are assembled.
44
45
  2. All Invocations are run sequentially in the order they were passed in to the Engin.
engin/ext/asgi.py CHANGED
@@ -1,10 +1,11 @@
1
1
  import traceback
2
- from collections.abc import Awaitable, Callable, MutableMapping
2
+ from collections.abc import AsyncIterator, Awaitable, Callable, MutableMapping
3
+ from contextlib import AbstractAsyncContextManager, asynccontextmanager
3
4
  from typing import Any, ClassVar, Protocol, TypeAlias
4
5
 
5
6
  from engin import Engin, Entrypoint, Option
6
7
 
7
- __all__ = ["ASGIEngin", "ASGIType"]
8
+ __all__ = ["ASGIEngin", "ASGIType", "engin_to_lifespan"]
8
9
 
9
10
  from engin._graph import DependencyGrapher, Node
10
11
 
@@ -61,3 +62,26 @@ class _Rereceive:
61
62
 
62
63
  async def __call__(self, *args: Any, **kwargs: Any) -> _Message:
63
64
  return self._message
65
+
66
+
67
+ def engin_to_lifespan(engin: Engin) -> Callable[[ASGIType], AbstractAsyncContextManager[None]]:
68
+ """
69
+ Transforms the Engin instance into an ASGI lifespan task.
70
+
71
+ This is to enable users to use the Engin framework with existing ASGI applications,
72
+ where it is not desired to replace the ASGI application with an ASGIEngin.
73
+
74
+ Args:
75
+ engin: the engin instance to transform.
76
+
77
+ Returns:
78
+ An ASGI lifespan task.
79
+ """
80
+
81
+ @asynccontextmanager
82
+ async def engin_lifespan(_: ASGIType) -> AsyncIterator[None]:
83
+ await engin.start()
84
+ yield
85
+ await engin.stop()
86
+
87
+ return engin_lifespan
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: engin
3
- Version: 0.0.9
3
+ Version: 0.0.10
4
4
  Summary: An async-first modular application framework
5
5
  Project-URL: Homepage, https://github.com/invokermain/engin
6
6
  Project-URL: Documentation, https://engin.readthedocs.io/en/latest/
@@ -1,20 +1,20 @@
1
1
  engin/__init__.py,sha256=yTc8k0HDGMIrxDdEEA90qGD_dExQjVIbXCyaOFRrnMg,508
2
- engin/_assembler.py,sha256=VCZA_Gq4hnH5LueB_vEVqsKbGXx-nI6KQ65YhzXw-VY,7575
2
+ engin/_assembler.py,sha256=6n8RBOwano3U3WM1P8Y6HLHo8IuPD_7jUMoTHBJoEA8,7713
3
3
  engin/_block.py,sha256=0QJtqyP5uTFjXsdVGr4ZONLI2LhfzUKmQGnNQWouB3o,2121
4
4
  engin/_dependency.py,sha256=Nmyk4cGcK6ZZA8YWNZWgckLpDdKsRwOeRQhqRlxZmI0,5883
5
- engin/_engin.py,sha256=i2IxMIz-3yKjedyg5L6gQEpdFDUZnCbXi9Pwhw8Hsxk,9133
5
+ engin/_engin.py,sha256=MTE4MkLrK45h0Nv7p5H92Kv5URa1nX246B9Pp1JkM3A,9134
6
6
  engin/_exceptions.py,sha256=fsc4pTOIGHUh0x7oZhEXPJUTE268sIhswLoiqXaudiw,635
7
7
  engin/_graph.py,sha256=1pMB0cr--uS0XJycDb1rS_X45RBpoyA6NkKqbeSuz1Q,1628
8
8
  engin/_lifecycle.py,sha256=_jQnGFj4RYXsxMpcXPJQagFOwnoTVh7oSN8oUYoYuW0,3246
9
9
  engin/_type_utils.py,sha256=C71kX2Dr-gluGSL018K4uihX3zkTe7QNWaHhFU10ZmA,2127
10
10
  engin/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  engin/ext/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
- engin/ext/asgi.py,sha256=ViAWw-PNaP6y5fHK2rSGRfaxj7xxo217eqU2z2rhnq8,2200
12
+ engin/ext/asgi.py,sha256=PCnemGVVB0jUZVcphz7y283sZ7D5Gog1o6rJ6g2TuCQ,2944
13
13
  engin/ext/fastapi.py,sha256=p9NekfRHbdNzK_1ttVNr500AO-IwLpBlG9Fhk6R0mmg,5649
14
14
  engin/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  engin/scripts/graph.py,sha256=kmC_sSypGvIH89GddHz3KoRBEvooGNsGtrwLgw_uxNQ,4968
16
- engin-0.0.9.dist-info/METADATA,sha256=fzCqyXhGBzC1hMcTtbRM9-oXVaHEP000abzPi9QZbFQ,2161
17
- engin-0.0.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
18
- engin-0.0.9.dist-info/entry_points.txt,sha256=Dehk4j5nK6zyuQtgOSRAoLE609V6eLzEp32bjqhO62Q,64
19
- engin-0.0.9.dist-info/licenses/LICENSE,sha256=XHh5LPUPKZWTBqBv2xxN2RU7D59nHoiJGb5RIt8f45w,1070
20
- engin-0.0.9.dist-info/RECORD,,
16
+ engin-0.0.10.dist-info/METADATA,sha256=qal9-bNGzl3dvBhuoc9wZUN3F8dCl23oxvZKLMXSPFc,2162
17
+ engin-0.0.10.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
18
+ engin-0.0.10.dist-info/entry_points.txt,sha256=Dehk4j5nK6zyuQtgOSRAoLE609V6eLzEp32bjqhO62Q,64
19
+ engin-0.0.10.dist-info/licenses/LICENSE,sha256=XHh5LPUPKZWTBqBv2xxN2RU7D59nHoiJGb5RIt8f45w,1070
20
+ engin-0.0.10.dist-info/RECORD,,
File without changes