zndraw-socketio 0.1.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.
- zndraw_socketio/__init__.py +13 -0
- zndraw_socketio/params.py +48 -0
- zndraw_socketio/py.typed +0 -0
- zndraw_socketio/wrapper.py +1639 -0
- zndraw_socketio-0.1.0.dist-info/METADATA +212 -0
- zndraw_socketio-0.1.0.dist-info/RECORD +8 -0
- zndraw_socketio-0.1.0.dist-info/WHEEL +4 -0
- zndraw_socketio-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from .wrapper import (
|
|
2
|
+
AsyncClientWrapper as AsyncClientWrapper,
|
|
3
|
+
AsyncServerWrapper as AsyncServerWrapper,
|
|
4
|
+
AsyncSimpleClientWrapper as AsyncSimpleClientWrapper,
|
|
5
|
+
Depends as Depends,
|
|
6
|
+
EventContext as EventContext,
|
|
7
|
+
SimpleClientWrapper as SimpleClientWrapper,
|
|
8
|
+
SioRequest as SioRequest,
|
|
9
|
+
SyncClientWrapper as SyncClientWrapper,
|
|
10
|
+
SyncServerWrapper as SyncServerWrapper,
|
|
11
|
+
get_event_name as get_event_name,
|
|
12
|
+
wrap as wrap,
|
|
13
|
+
)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""Dependency injection parameters for zndraw-socketio.
|
|
2
|
+
|
|
3
|
+
Provides a lightweight Depends compatible with FastAPI's Depends.
|
|
4
|
+
When FastAPI is installed, its Depends is used directly instead.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from dataclasses import dataclass
|
|
10
|
+
from typing import Any, Callable, Optional
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass(frozen=True)
|
|
14
|
+
class _DependsBase:
|
|
15
|
+
"""Internal sentinel class for dependency declarations.
|
|
16
|
+
|
|
17
|
+
Use the :func:`Depends` function instead of instantiating directly.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
dependency: Optional[Callable[..., Any]] = None
|
|
21
|
+
use_cache: bool = True
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def Depends( # noqa: N802
|
|
25
|
+
dependency: Optional[Callable[..., Any]] = None,
|
|
26
|
+
*,
|
|
27
|
+
use_cache: bool = True,
|
|
28
|
+
) -> Any:
|
|
29
|
+
"""Declare a dependency for a Socket.IO event handler.
|
|
30
|
+
|
|
31
|
+
Returns ``Any`` so that ``param: str = Depends(get_value)`` passes
|
|
32
|
+
type-checking — the same convention FastAPI uses.
|
|
33
|
+
|
|
34
|
+
When FastAPI is installed, use ``fastapi.Depends`` instead — it is
|
|
35
|
+
automatically recognised by the wrapper.
|
|
36
|
+
|
|
37
|
+
Example::
|
|
38
|
+
|
|
39
|
+
from zndraw_socketio.params import Depends
|
|
40
|
+
|
|
41
|
+
async def get_redis():
|
|
42
|
+
return Redis()
|
|
43
|
+
|
|
44
|
+
@tsio.on(MyEvent)
|
|
45
|
+
async def handler(sid: str, data: MyEvent, redis: Redis = Depends(get_redis)):
|
|
46
|
+
...
|
|
47
|
+
"""
|
|
48
|
+
return _DependsBase(dependency=dependency, use_cache=use_cache)
|
zndraw_socketio/py.typed
ADDED
|
File without changes
|