wse-client 1.2.1 → 1.3.0
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.
- package/README.md +33 -4
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,7 +25,9 @@ The engine is Rust-accelerated via PyO3. Up to **2M msg/s** sustained throughput
|
|
|
25
25
|
|
|
26
26
|
## Quick Start
|
|
27
27
|
|
|
28
|
-
### Server (Python)
|
|
28
|
+
### Server (Python) -- Router Mode
|
|
29
|
+
|
|
30
|
+
Embed WSE into your existing FastAPI app on the same port:
|
|
29
31
|
|
|
30
32
|
```python
|
|
31
33
|
from fastapi import FastAPI
|
|
@@ -43,6 +45,31 @@ app.include_router(wse, prefix="/wse")
|
|
|
43
45
|
await wse.publish("notifications", {"text": "Order shipped!", "order_id": 42})
|
|
44
46
|
```
|
|
45
47
|
|
|
48
|
+
### Server (Python) -- Standalone Mode
|
|
49
|
+
|
|
50
|
+
Run the Rust WebSocket server on a dedicated port for maximum throughput:
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from wse_server._wse_accel import RustWSEServer
|
|
54
|
+
|
|
55
|
+
server = RustWSEServer(
|
|
56
|
+
"0.0.0.0", 5006,
|
|
57
|
+
max_connections=10000,
|
|
58
|
+
jwt_secret=b"your-secret-key", # Rust JWT validation in handshake
|
|
59
|
+
jwt_issuer="your-app",
|
|
60
|
+
jwt_audience="your-api",
|
|
61
|
+
)
|
|
62
|
+
server.start()
|
|
63
|
+
|
|
64
|
+
# Drain inbound events in a background thread
|
|
65
|
+
while True:
|
|
66
|
+
events = server.drain_inbound(256, 50) # batch size, timeout ms
|
|
67
|
+
for event in events:
|
|
68
|
+
handle(event)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Standalone mode gives you a dedicated Rust tokio runtime on its own port -- no FastAPI overhead, no GIL on the hot path. This is how WSE achieves 2M msg/s.
|
|
72
|
+
|
|
46
73
|
### Client (React)
|
|
47
74
|
|
|
48
75
|
```tsx
|
|
@@ -217,9 +244,11 @@ Client (React + TypeScript) Server (Python + Rust)
|
|
|
217
244
|
======================== ========================
|
|
218
245
|
|
|
219
246
|
useWSE hook FastAPI Router (/wse)
|
|
220
|
-
|
|
|
221
|
-
v
|
|
222
|
-
ConnectionPool
|
|
247
|
+
| -- OR --
|
|
248
|
+
v RustWSEServer (standalone :5006)
|
|
249
|
+
ConnectionPool |
|
|
250
|
+
| (multi-endpoint, v
|
|
251
|
+
| health scoring) Rust Engine (PyO3)
|
|
223
252
|
| (multi-endpoint, | (drain mode,
|
|
224
253
|
| health scoring) | write coalescing)
|
|
225
254
|
v v
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const WS_PROTOCOL_VERSION = 1;
|
|
2
|
-
export declare const WS_CLIENT_VERSION = "1.0
|
|
2
|
+
export declare const WS_CLIENT_VERSION = "1.3.0";
|
|
3
3
|
export declare const HEARTBEAT_INTERVAL = 15000;
|
|
4
4
|
export declare const IDLE_TIMEOUT = 40000;
|
|
5
5
|
export declare const CONNECTION_TIMEOUT = 10000;
|
package/dist/constants.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// Protocol Constants
|
|
6
6
|
// ---------------------------------------------------------------------------
|
|
7
7
|
export const WS_PROTOCOL_VERSION = 1;
|
|
8
|
-
export const WS_CLIENT_VERSION = '1.0
|
|
8
|
+
export const WS_CLIENT_VERSION = '1.3.0';
|
|
9
9
|
// ---------------------------------------------------------------------------
|
|
10
10
|
// Connection Constants
|
|
11
11
|
// ---------------------------------------------------------------------------
|
package/dist/index.d.ts
CHANGED
|
@@ -21,5 +21,5 @@ export type { OfflineQueueConfig } from './services/OfflineQueue';
|
|
|
21
21
|
export { EventHandlers } from './handlers/EventHandlers';
|
|
22
22
|
export { registerAllHandlers } from './handlers/index';
|
|
23
23
|
export * from './constants';
|
|
24
|
-
export declare const WSE_VERSION = "1.0
|
|
24
|
+
export declare const WSE_VERSION = "1.3.0";
|
|
25
25
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -44,5 +44,5 @@ export * from './constants';
|
|
|
44
44
|
// ---------------------------------------------------------------------------
|
|
45
45
|
// Version Info
|
|
46
46
|
// ---------------------------------------------------------------------------
|
|
47
|
-
export const WSE_VERSION = '1.0
|
|
47
|
+
export const WSE_VERSION = '1.3.0';
|
|
48
48
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED