wse-client 1.3.0 → 1.3.1
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 +68 -38
- 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
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# WSE -- WebSocket Engine
|
|
2
2
|
|
|
3
|
-
**A complete, out-of-the-box solution for
|
|
3
|
+
**A complete, out-of-the-box solution for real-time communication between React, Python, and backend services.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Three packages. Four lines of code. Your frontend and backend talk in real time.
|
|
6
6
|
|
|
7
7
|
[](https://github.com/silvermpx/wse/actions/workflows/ci.yml)
|
|
8
|
-
[](https://pypi.org/project/wse-server/)
|
|
8
|
+
[](https://pypi.org/project/wse-server/)
|
|
9
|
+
[](https://pypi.org/project/wse-client/)
|
|
9
10
|
[](https://www.npmjs.com/package/wse-client)
|
|
10
11
|
[](LICENSE)
|
|
11
12
|
|
|
@@ -17,7 +18,7 @@ Building real-time features between React and Python is painful. You need WebSoc
|
|
|
17
18
|
|
|
18
19
|
**WSE gives you all of this out of the box.**
|
|
19
20
|
|
|
20
|
-
Install `wse-server` on your backend, `wse-client` on your frontend. Everything works immediately: auto-reconnection, message encryption, sequence ordering, offline queues, health monitoring. No configuration required for the defaults. Override what you need.
|
|
21
|
+
Install `wse-server` on your backend, `wse-client` on your frontend (React or Python). Everything works immediately: auto-reconnection, message encryption, sequence ordering, offline queues, health monitoring. No configuration required for the defaults. Override what you need.
|
|
21
22
|
|
|
22
23
|
The engine is Rust-accelerated via PyO3. Up to **2M msg/s** sustained throughput on AMD EPYC (64 cores). **0.5M msg/s** burst on Apple M2 (8 cores). Sub-millisecond connection latency (0.53ms median) with Rust JWT authentication.
|
|
23
24
|
|
|
@@ -95,6 +96,19 @@ function Dashboard() {
|
|
|
95
96
|
|
|
96
97
|
That's it. Your React app receives real-time updates from your Python backend.
|
|
97
98
|
|
|
99
|
+
### Client (Python)
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from wse_client import connect
|
|
103
|
+
|
|
104
|
+
async with connect("ws://localhost:5006/wse", token="your-jwt") as client:
|
|
105
|
+
await client.subscribe(["notifications", "live_data"])
|
|
106
|
+
async for event in client:
|
|
107
|
+
print(event.type, event.payload)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Same wire protocol, same features. Use the Python client for backend-to-backend communication, microservices, CLI tools, integration tests, or any non-browser use case.
|
|
111
|
+
|
|
98
112
|
---
|
|
99
113
|
|
|
100
114
|
## What You Get Out of the Box
|
|
@@ -177,6 +191,20 @@ Compression, sequencing, filtering, rate limiting, and the WebSocket server itse
|
|
|
177
191
|
| **Rate Limiter** | Client-side token-bucket rate limiter for outbound messages. Prevents flooding the server. |
|
|
178
192
|
| **Security Manager** | Client-side HMAC verification and optional decryption. Validates message integrity before dispatching to handlers. |
|
|
179
193
|
|
|
194
|
+
### Client (Python)
|
|
195
|
+
|
|
196
|
+
| Feature | Description |
|
|
197
|
+
|---------|-------------|
|
|
198
|
+
| **Async + Sync API** | `AsyncWSEClient` with async context manager and async iterator. `SyncWSEClient` wrapper for threaded/synchronous code. |
|
|
199
|
+
| **Connection Manager** | Auto-reconnection with 4 strategies (exponential, linear, fibonacci, adaptive). Jitter, configurable max attempts. Heartbeat with PING/PONG. |
|
|
200
|
+
| **Connection Pool** | Multi-endpoint support with health scoring. Weighted-random, least-connections, round-robin load balancing. |
|
|
201
|
+
| **Circuit Breaker** | Three-state machine (CLOSED / OPEN / HALF_OPEN). Prevents reconnection storms. |
|
|
202
|
+
| **Rate Limiter** | Client-side token-bucket rate limiter for outbound messages. |
|
|
203
|
+
| **Event Sequencer** | Duplicate detection (10K ID window) and out-of-order reordering buffer. |
|
|
204
|
+
| **Network Monitor** | Latency, jitter, packet loss analysis. Connection quality scoring. |
|
|
205
|
+
| **Security** | ECDH P-256 key exchange, AES-GCM-256 encryption, HMAC-SHA256 signing. Wire-compatible with server and TypeScript client. |
|
|
206
|
+
| **Compression + msgpack** | Zlib decompression and msgpack decoding. Automatic binary frame detection. |
|
|
207
|
+
|
|
180
208
|
---
|
|
181
209
|
|
|
182
210
|
## Performance
|
|
@@ -230,47 +258,47 @@ pip install wse-server
|
|
|
230
258
|
|
|
231
259
|
# Client (React/TypeScript)
|
|
232
260
|
npm install wse-client
|
|
261
|
+
|
|
262
|
+
# Client (Python) -- pure Python, no Rust required
|
|
263
|
+
pip install wse-client
|
|
233
264
|
```
|
|
234
265
|
|
|
235
|
-
|
|
236
|
-
|
|
266
|
+
Server: prebuilt wheels for Linux (x86_64, aarch64), macOS (Intel, Apple Silicon), and Windows. Python 3.12+ (ABI3 stable -- one wheel per platform).
|
|
267
|
+
|
|
268
|
+
Python client: pure Python, Python 3.11+. Optional extras: `pip install wse-client[crypto]` for encryption, `pip install wse-client[all]` for everything.
|
|
237
269
|
|
|
238
270
|
---
|
|
239
271
|
|
|
240
272
|
## Architecture
|
|
241
273
|
|
|
242
274
|
```
|
|
243
|
-
Client (
|
|
244
|
-
========================
|
|
245
|
-
|
|
246
|
-
useWSE hook
|
|
247
|
-
|
|
|
248
|
-
v
|
|
249
|
-
ConnectionPool
|
|
250
|
-
| (multi-endpoint,
|
|
251
|
-
| health scoring)
|
|
252
|
-
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
v
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
|
266
|
-
v
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
React Components PubSub Bus (Redis)
|
|
271
|
-
|
|
|
272
|
-
v
|
|
273
|
-
Dead Letter Queue
|
|
275
|
+
React Client (TypeScript) Python Client Server (Python + Rust)
|
|
276
|
+
======================== ======================== ========================
|
|
277
|
+
|
|
278
|
+
useWSE hook AsyncWSEClient FastAPI Router (/wse)
|
|
279
|
+
| | -- OR --
|
|
280
|
+
v v RustWSEServer (:5006)
|
|
281
|
+
ConnectionPool ConnectionPool |
|
|
282
|
+
| (multi-endpoint, | (multi-endpoint, v
|
|
283
|
+
| health scoring) | health scoring) Rust Engine (PyO3)
|
|
284
|
+
v v |
|
|
285
|
+
ConnectionManager ConnectionManager v
|
|
286
|
+
| (auto-reconnect, | (auto-reconnect, EventTransformer
|
|
287
|
+
| circuit breaker) | circuit breaker) |
|
|
288
|
+
v v v
|
|
289
|
+
MessageProcessor MessageCodec PriorityQueue
|
|
290
|
+
| (decompress, verify, | (decompress, |
|
|
291
|
+
| sequence, dispatch) | sequence, dedup) v
|
|
292
|
+
v v Sequencer + Dedup
|
|
293
|
+
AdaptiveQualityManager NetworkMonitor |
|
|
294
|
+
| | (quality scoring, v
|
|
295
|
+
v | latency, jitter) Compression + Rate Limiter
|
|
296
|
+
Zustand Store v |
|
|
297
|
+
| Event handlers / v
|
|
298
|
+
v async iterator PubSub Bus (Redis)
|
|
299
|
+
React Components |
|
|
300
|
+
v
|
|
301
|
+
Dead Letter Queue
|
|
274
302
|
```
|
|
275
303
|
|
|
276
304
|
**Wire format (v1):**
|
|
@@ -294,8 +322,9 @@ React Components PubSub Bus (Redis)
|
|
|
294
322
|
|---------|----------|----------|---------|
|
|
295
323
|
| `wse-server` | [PyPI](https://pypi.org/project/wse-server/) | Python + Rust | `pip install wse-server` |
|
|
296
324
|
| `wse-client` | [npm](https://www.npmjs.com/package/wse-client) | TypeScript + React | `npm install wse-client` |
|
|
325
|
+
| `wse-client` | [PyPI](https://pypi.org/project/wse-client/) | Python | `pip install wse-client` |
|
|
297
326
|
|
|
298
|
-
|
|
327
|
+
All packages are standalone. No shared dependencies between server and clients.
|
|
299
328
|
|
|
300
329
|
---
|
|
301
330
|
|
|
@@ -327,6 +356,7 @@ Both packages are standalone. No shared dependencies between server and client.
|
|
|
327
356
|
| Client state | Zustand | Lightweight React store |
|
|
328
357
|
| Client hooks | React 18+ | useWSE hook with TypeScript |
|
|
329
358
|
| Offline storage | IndexedDB | Persistent offline queue |
|
|
359
|
+
| Python client | websockets + cryptography | Async/sync WebSocket client |
|
|
330
360
|
| Build system | maturin | Rust+Python hybrid wheels |
|
|
331
361
|
|
|
332
362
|
---
|
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.3.
|
|
2
|
+
export declare const WS_CLIENT_VERSION = "1.3.1";
|
|
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.3.
|
|
8
|
+
export const WS_CLIENT_VERSION = '1.3.1';
|
|
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.3.
|
|
24
|
+
export declare const WSE_VERSION = "1.3.1";
|
|
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.3.
|
|
47
|
+
export const WSE_VERSION = '1.3.1';
|
|
48
48
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED