ipc-framework 1.1.0__py3-none-any.whl → 1.1.2__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.
- ipc_framework/__init__.py +1 -1
- ipc_framework-1.1.2.dist-info/METADATA +273 -0
- {ipc_framework-1.1.0.dist-info → ipc_framework-1.1.2.dist-info}/RECORD +7 -7
- ipc_framework-1.1.0.dist-info/METADATA +0 -273
- {ipc_framework-1.1.0.dist-info → ipc_framework-1.1.2.dist-info}/WHEEL +0 -0
- {ipc_framework-1.1.0.dist-info → ipc_framework-1.1.2.dist-info}/entry_points.txt +0 -0
- {ipc_framework-1.1.0.dist-info → ipc_framework-1.1.2.dist-info}/licenses/LICENSE +0 -0
- {ipc_framework-1.1.0.dist-info → ipc_framework-1.1.2.dist-info}/top_level.txt +0 -0
ipc_framework/__init__.py
CHANGED
@@ -0,0 +1,273 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: ipc-framework
|
3
|
+
Version: 1.1.2
|
4
|
+
Summary: Python IPC server for high-performance communication with Node.js applications using TCP sockets
|
5
|
+
Home-page: https://github.com/ifesol/ipc-framework
|
6
|
+
Author: IPC Framework Team
|
7
|
+
Author-email: IPC Framework Team <ifesol@example.com>
|
8
|
+
Maintainer-email: IPC Framework Team <ifesol@example.com>
|
9
|
+
License: MIT
|
10
|
+
Project-URL: Homepage, https://github.com/ifesol/ipc-framework
|
11
|
+
Project-URL: Documentation, https://github.com/ifesol/ipc-framework#readme
|
12
|
+
Project-URL: Repository, https://github.com/ifesol/ipc-framework.git
|
13
|
+
Project-URL: Bug Tracker, https://github.com/ifesol/ipc-framework/issues
|
14
|
+
Keywords: ipc,inter-process-communication,tcp,sockets,nodejs,python,server,microservices,real-time,messaging
|
15
|
+
Classifier: Development Status :: 4 - Beta
|
16
|
+
Classifier: Intended Audience :: Developers
|
17
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
18
|
+
Classifier: Topic :: System :: Networking
|
19
|
+
Classifier: License :: OSI Approved :: MIT License
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
21
|
+
Classifier: Programming Language :: Python :: 3.7
|
22
|
+
Classifier: Programming Language :: Python :: 3.8
|
23
|
+
Classifier: Programming Language :: Python :: 3.9
|
24
|
+
Classifier: Programming Language :: Python :: 3.10
|
25
|
+
Classifier: Programming Language :: Python :: 3.11
|
26
|
+
Classifier: Programming Language :: Python :: 3.12
|
27
|
+
Classifier: Operating System :: OS Independent
|
28
|
+
Requires-Python: >=3.7
|
29
|
+
Description-Content-Type: text/markdown
|
30
|
+
License-File: LICENSE
|
31
|
+
Provides-Extra: examples
|
32
|
+
Requires-Dist: psutil>=5.8.0; extra == "examples"
|
33
|
+
Provides-Extra: dev
|
34
|
+
Requires-Dist: pytest>=6.0.0; extra == "dev"
|
35
|
+
Requires-Dist: black>=21.0.0; extra == "dev"
|
36
|
+
Requires-Dist: flake8>=3.8.0; extra == "dev"
|
37
|
+
Requires-Dist: mypy>=0.910; extra == "dev"
|
38
|
+
Requires-Dist: isort>=5.0.0; extra == "dev"
|
39
|
+
Provides-Extra: all
|
40
|
+
Requires-Dist: ipc-framework[dev,examples]; extra == "all"
|
41
|
+
Dynamic: author
|
42
|
+
Dynamic: home-page
|
43
|
+
Dynamic: license-file
|
44
|
+
Dynamic: requires-python
|
45
|
+
|
46
|
+
# IPC Framework - Inter-Process Communication
|
47
|
+
|
48
|
+
[](https://www.npmjs.com/package/@ifesol/ipc-framework-nodejs)
|
49
|
+
[](https://opensource.org/licenses/MIT)
|
50
|
+
|
51
|
+
**Efficient Inter-Process Communication Framework** for **Python ↔ Node.js** backend integration. This is the **Python server package** that enables seamless **bidirectional communication** with Node.js applications using TCP sockets.
|
52
|
+
|
53
|
+
## 🐍 **Python Server Package**
|
54
|
+
|
55
|
+
This package provides the **Python IPC server** for communication with Node.js clients.
|
56
|
+
|
57
|
+
**✅ Production Ready Features:**
|
58
|
+
- ✅ TCP socket server (high-performance, low-latency)
|
59
|
+
- ✅ Hierarchical application and channel management
|
60
|
+
- ✅ Request/response and publish/subscribe patterns
|
61
|
+
- ✅ Connection pooling and auto-reconnection support
|
62
|
+
- ✅ Thread-safe operation with robust error handling
|
63
|
+
|
64
|
+
## 🚀 **Quick Start**
|
65
|
+
|
66
|
+
### **Installation**
|
67
|
+
|
68
|
+
```bash
|
69
|
+
# Install Python IPC server
|
70
|
+
pip install ipc-framework
|
71
|
+
|
72
|
+
# Install Node.js client (separate package)
|
73
|
+
npm install @ifesol/ipc-framework-nodejs
|
74
|
+
```
|
75
|
+
|
76
|
+
### **Python Server Usage**
|
77
|
+
|
78
|
+
```python
|
79
|
+
from ipc_framework import FrameworkServer, MessageType
|
80
|
+
import time
|
81
|
+
|
82
|
+
# Create server
|
83
|
+
server = FrameworkServer(host="localhost", port=8888)
|
84
|
+
|
85
|
+
# Create application and channel
|
86
|
+
app = server.create_application("my_app", "My Application")
|
87
|
+
api_channel = app.create_channel("api")
|
88
|
+
|
89
|
+
# Handle requests from Node.js clients
|
90
|
+
def handle_request(message):
|
91
|
+
action = message.payload.get('action')
|
92
|
+
|
93
|
+
if action == 'get_data':
|
94
|
+
response = message.create_response({
|
95
|
+
'success': True,
|
96
|
+
'data': {'timestamp': time.time(), 'message': 'Hello from Python!'},
|
97
|
+
'server': 'Python IPC Framework'
|
98
|
+
})
|
99
|
+
|
100
|
+
connection = server.connection_manager.get_connection(
|
101
|
+
message.payload.get('connection_id')
|
102
|
+
)
|
103
|
+
server.send_to_connection(connection, response)
|
104
|
+
|
105
|
+
api_channel.set_handler(MessageType.REQUEST, handle_request)
|
106
|
+
|
107
|
+
print("🐍 Python IPC Server starting on localhost:8888")
|
108
|
+
server.start()
|
109
|
+
```
|
110
|
+
|
111
|
+
### **Node.js Client Usage**
|
112
|
+
|
113
|
+
```javascript
|
114
|
+
const { IPCClient } = require('@ifesol/ipc-framework-nodejs');
|
115
|
+
|
116
|
+
async function main() {
|
117
|
+
const client = new IPCClient('my_app', {
|
118
|
+
host: 'localhost',
|
119
|
+
port: 8888
|
120
|
+
});
|
121
|
+
|
122
|
+
try {
|
123
|
+
await client.connect();
|
124
|
+
console.log('✅ Connected to Python server!');
|
125
|
+
|
126
|
+
const response = await client.sendRequest('api', {
|
127
|
+
action: 'get_data'
|
128
|
+
});
|
129
|
+
|
130
|
+
console.log('📨 Response from Python:', response.payload);
|
131
|
+
} catch (error) {
|
132
|
+
console.error('❌ Error:', error.message);
|
133
|
+
} finally {
|
134
|
+
client.disconnect();
|
135
|
+
}
|
136
|
+
}
|
137
|
+
|
138
|
+
main();
|
139
|
+
```
|
140
|
+
|
141
|
+
## 🎯 **Architecture Features**
|
142
|
+
|
143
|
+
### **✅ Production-Ready Server:**
|
144
|
+
- **High-performance TCP sockets** for low-latency communication
|
145
|
+
- **Hierarchical structure** with applications and channels
|
146
|
+
- **Message routing** and automatic connection management
|
147
|
+
- **Thread-safe operations** with robust error handling
|
148
|
+
|
149
|
+
### **✅ Communication Patterns:**
|
150
|
+
- **Request/Response** - Direct client-server communication
|
151
|
+
- **Publish/Subscribe** - Real-time notifications and broadcasts
|
152
|
+
- **Channel-based routing** - Organized message handling
|
153
|
+
- **Connection pooling** - Efficient resource management
|
154
|
+
|
155
|
+
## 🏗️ **Integration with Node.js**
|
156
|
+
|
157
|
+
This Python server works seamlessly with Node.js applications. Here's how to connect an Express.js app:
|
158
|
+
|
159
|
+
**Node.js Express.js Integration:**
|
160
|
+
```javascript
|
161
|
+
const express = require('express');
|
162
|
+
const { IPCClient } = require('@ifesol/ipc-framework-nodejs');
|
163
|
+
|
164
|
+
const app = express();
|
165
|
+
const pythonClient = new IPCClient('web_api');
|
166
|
+
|
167
|
+
app.use(express.json());
|
168
|
+
|
169
|
+
// Initialize connection to Python IPC server
|
170
|
+
pythonClient.connect().then(() => {
|
171
|
+
console.log('🔗 Connected to Python IPC server');
|
172
|
+
});
|
173
|
+
|
174
|
+
// API endpoint proxying to Python backend
|
175
|
+
app.post('/api/process', async (req, res) => {
|
176
|
+
try {
|
177
|
+
const result = await pythonClient.sendRequest('processing', {
|
178
|
+
action: 'process_user_data',
|
179
|
+
data: req.body,
|
180
|
+
connection_id: pythonClient.connectionId
|
181
|
+
});
|
182
|
+
|
183
|
+
res.json(result.payload);
|
184
|
+
} catch (error) {
|
185
|
+
res.status(500).json({ error: error.message });
|
186
|
+
}
|
187
|
+
});
|
188
|
+
|
189
|
+
app.listen(3000, () => {
|
190
|
+
console.log('🌐 Express server running on port 3000');
|
191
|
+
console.log('📡 Proxying requests to Python IPC server');
|
192
|
+
});
|
193
|
+
```
|
194
|
+
|
195
|
+
## 📊 **Performance Characteristics**
|
196
|
+
|
197
|
+
| Feature | Performance | Details |
|
198
|
+
|---------|-------------|---------|
|
199
|
+
| **Connection Handling** | Sub-millisecond | Fast TCP connection establishment |
|
200
|
+
| **Message Processing** | <1ms latency | Direct socket communication |
|
201
|
+
| **Concurrent Connections** | 100+ clients | Thread-safe connection management |
|
202
|
+
| **Message Throughput** | High-volume | Efficient message routing |
|
203
|
+
| **Memory Usage** | Low footprint | Optimized Python implementation |
|
204
|
+
| **Error Recovery** | Automatic | Robust connection cleanup |
|
205
|
+
|
206
|
+
## 🎯 **Use Cases**
|
207
|
+
|
208
|
+
This Python IPC server enables powerful hybrid architectures:
|
209
|
+
|
210
|
+
### **Backend Services**
|
211
|
+
- **AI/ML model serving** - Host machine learning models and serve predictions to Node.js frontends
|
212
|
+
- **Data processing pipelines** - Heavy computational tasks handled by Python, coordinated with Node.js
|
213
|
+
- **Real-time analytics** - Python analytics engines feeding real-time dashboards
|
214
|
+
- **Scientific computing** - NumPy/SciPy computations accessible from Node.js applications
|
215
|
+
|
216
|
+
### **Microservice Architecture**
|
217
|
+
- **Polyglot microservices** - Python services integrated with Node.js API gateways
|
218
|
+
- **Event-driven architecture** - Python services publishing events to Node.js consumers
|
219
|
+
- **Service mesh integration** - Python backend services in cloud-native environments
|
220
|
+
- **Legacy system integration** - Bridge existing Python systems with modern Node.js frontends
|
221
|
+
|
222
|
+
### **Hybrid Applications**
|
223
|
+
- **E-commerce platforms** - Python inventory/pricing engines with Node.js storefronts
|
224
|
+
- **Financial services** - Python quantitative analysis with Node.js trading interfaces
|
225
|
+
- **IoT platforms** - Python device controllers with Node.js monitoring dashboards
|
226
|
+
- **Chat applications** - Python NLP processing with Node.js real-time messaging
|
227
|
+
|
228
|
+
## 🆚 **Why Choose IPC over HTTP?**
|
229
|
+
|
230
|
+
| HTTP API Approach | IPC Framework |
|
231
|
+
|-------------------|---------------|
|
232
|
+
| ❌ High latency overhead | ✅ Direct TCP communication |
|
233
|
+
| ❌ Request/response only | ✅ Request/response + pub/sub |
|
234
|
+
| ❌ Manual connection management | ✅ Automatic reconnection |
|
235
|
+
| ❌ Complex error handling | ✅ Built-in fault tolerance |
|
236
|
+
| ❌ No real-time capabilities | ✅ Live notifications |
|
237
|
+
| ❌ Stateless limitations | ✅ Persistent connections |
|
238
|
+
|
239
|
+
## 🔗 **Companion Packages**
|
240
|
+
|
241
|
+
This Python server works with the Node.js client package:
|
242
|
+
|
243
|
+
- **Node.js Client**: [@ifesol/ipc-framework-nodejs](https://www.npmjs.com/package/@ifesol/ipc-framework-nodejs) - Production-ready TCP client
|
244
|
+
- **Installation**: `npm install @ifesol/ipc-framework-nodejs`
|
245
|
+
- **Documentation**: [Node.js Package Docs](https://www.npmjs.com/package/@ifesol/ipc-framework-nodejs)
|
246
|
+
|
247
|
+
## 🚀 **Getting Started**
|
248
|
+
|
249
|
+
1. **Install the Python server:**
|
250
|
+
```bash
|
251
|
+
pip install ipc-framework
|
252
|
+
```
|
253
|
+
|
254
|
+
2. **Install the Node.js client:**
|
255
|
+
```bash
|
256
|
+
npm install @ifesol/ipc-framework-nodejs
|
257
|
+
```
|
258
|
+
|
259
|
+
3. **Run the examples above** to see the integration in action!
|
260
|
+
|
261
|
+
## 📚 **Documentation**
|
262
|
+
|
263
|
+
- [Python API Reference](https://github.com/ifesol/ipc-framework#python-api)
|
264
|
+
- [Node.js Client Usage](https://www.npmjs.com/package/@ifesol/ipc-framework-nodejs)
|
265
|
+
- [Integration Examples](https://github.com/ifesol/ipc-framework/tree/main/examples)
|
266
|
+
|
267
|
+
## 📄 License
|
268
|
+
|
269
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
270
|
+
|
271
|
+
## 🤝 Contributing
|
272
|
+
|
273
|
+
Contributions welcome! Help us improve the Python ↔ Node.js IPC communication experience.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
ipc_framework/__init__.py,sha256=
|
1
|
+
ipc_framework/__init__.py,sha256=bxe--vOgaHlO5JIu4V9DEfLk9cU11OgpDwaqqOqbkxw,701
|
2
2
|
ipc_framework/client.py,sha256=MDXQ_V2DpeYeyTt3Asia7yqznC8PZKtHitxEyRvvMW8,10623
|
3
3
|
ipc_framework/core.py,sha256=SXYPNmyUUfkdoB6thJpZ0RCYodb8naqeN2EAVcDy_0c,13113
|
4
4
|
ipc_framework/demo.py,sha256=X3dTeY9j4GvzF659iU0uDRLUu_kY-M3Xe1IYLRh0WIo,9633
|
@@ -10,9 +10,9 @@ ipc_framework/examples/basic_server.py,sha256=JagIYvdJzien_D5_ltrLcXV8l2R7tXmfMz
|
|
10
10
|
ipc_framework/examples/chat_client.py,sha256=I0SklgNfNok_Mxh3sogCRFU0ZPn-h1FK4PGzyiCFyTg,5597
|
11
11
|
ipc_framework/examples/file_client.py,sha256=5-pTSj2ihn9GcMpjNreEc-Pql3cUiSajfmqpFYmd5pw,6699
|
12
12
|
ipc_framework/examples/monitoring_client.py,sha256=P_e_AzAEMi3pYNKwqpnnybwTDJ-JrL6IeJaqLs2paEs,8685
|
13
|
-
ipc_framework-1.1.
|
14
|
-
ipc_framework-1.1.
|
15
|
-
ipc_framework-1.1.
|
16
|
-
ipc_framework-1.1.
|
17
|
-
ipc_framework-1.1.
|
18
|
-
ipc_framework-1.1.
|
13
|
+
ipc_framework-1.1.2.dist-info/licenses/LICENSE,sha256=TNNfib3sWn_knMftcB1VFB66qVWPO6H6XQgKQUT59QI,1095
|
14
|
+
ipc_framework-1.1.2.dist-info/METADATA,sha256=to5LcA26fgvboCfqXXO1pJYli9SSabgSinpnrT8_5aQ,10199
|
15
|
+
ipc_framework-1.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
16
|
+
ipc_framework-1.1.2.dist-info/entry_points.txt,sha256=JYQQJs3l0-Rp8drzTljNe9ZTiWmBIdKwuUBwM59D7Hg,269
|
17
|
+
ipc_framework-1.1.2.dist-info/top_level.txt,sha256=z8_yaAPugqYnekc8wt3hntHtZ5hNqv0hKwQv818yT1o,14
|
18
|
+
ipc_framework-1.1.2.dist-info/RECORD,,
|
@@ -1,273 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.4
|
2
|
-
Name: ipc-framework
|
3
|
-
Version: 1.1.0
|
4
|
-
Summary: Efficient Inter-Process Communication Framework with hierarchical application and channel management
|
5
|
-
Home-page: https://github.com/ifesol/ipc-framework
|
6
|
-
Author: IPC Framework Team
|
7
|
-
Author-email: ifesol <ifesol@example.com>
|
8
|
-
Maintainer-email: ifesol <ifesol@example.com>
|
9
|
-
License: MIT
|
10
|
-
Project-URL: Homepage, https://github.com/ifesol/ipc-framework
|
11
|
-
Project-URL: Documentation, https://github.com/ifesol/ipc-framework#readme
|
12
|
-
Project-URL: Repository, https://github.com/ifesol/ipc-framework.git
|
13
|
-
Project-URL: Bug Tracker, https://github.com/ifesol/ipc-framework/issues
|
14
|
-
Keywords: ipc,communication,networking,client-server,messaging
|
15
|
-
Classifier: Development Status :: 4 - Beta
|
16
|
-
Classifier: Intended Audience :: Developers
|
17
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
18
|
-
Classifier: Topic :: System :: Networking
|
19
|
-
Classifier: License :: OSI Approved :: MIT License
|
20
|
-
Classifier: Programming Language :: Python :: 3
|
21
|
-
Classifier: Programming Language :: Python :: 3.7
|
22
|
-
Classifier: Programming Language :: Python :: 3.8
|
23
|
-
Classifier: Programming Language :: Python :: 3.9
|
24
|
-
Classifier: Programming Language :: Python :: 3.10
|
25
|
-
Classifier: Programming Language :: Python :: 3.11
|
26
|
-
Classifier: Programming Language :: Python :: 3.12
|
27
|
-
Classifier: Operating System :: OS Independent
|
28
|
-
Requires-Python: >=3.7
|
29
|
-
Description-Content-Type: text/markdown
|
30
|
-
License-File: LICENSE
|
31
|
-
Provides-Extra: examples
|
32
|
-
Requires-Dist: psutil>=5.8.0; extra == "examples"
|
33
|
-
Provides-Extra: dev
|
34
|
-
Requires-Dist: pytest>=6.0.0; extra == "dev"
|
35
|
-
Requires-Dist: black>=21.0.0; extra == "dev"
|
36
|
-
Requires-Dist: flake8>=3.8.0; extra == "dev"
|
37
|
-
Requires-Dist: mypy>=0.910; extra == "dev"
|
38
|
-
Requires-Dist: isort>=5.0.0; extra == "dev"
|
39
|
-
Provides-Extra: all
|
40
|
-
Requires-Dist: ipc-framework[dev,examples]; extra == "all"
|
41
|
-
Dynamic: author
|
42
|
-
Dynamic: home-page
|
43
|
-
Dynamic: license-file
|
44
|
-
Dynamic: requires-python
|
45
|
-
|
46
|
-
# IPC Framework - Python Package
|
47
|
-
|
48
|
-
[](https://pypi.org/project/ipc-framework/)
|
49
|
-
[](https://pypi.org/project/ipc-framework/)
|
50
|
-
[](https://opensource.org/licenses/MIT)
|
51
|
-
|
52
|
-
**Efficient Inter-Process Communication Framework** with hierarchical application and channel management. Enables seamless **bidirectional communication** between Python servers and JavaScript/TypeScript clients.
|
53
|
-
|
54
|
-
## 🚀 Key Features
|
55
|
-
|
56
|
-
- **🔄 Bidirectional Communication**: Full two-way messaging between Python ↔ JavaScript
|
57
|
-
- **🏗️ Hierarchical Organization**: Applications → Channels → Messages
|
58
|
-
- **📡 Multiple Patterns**: Request/Response, Pub/Sub, Notifications
|
59
|
-
- **🌍 Cross-Language**: Python server + JavaScript/TypeScript clients
|
60
|
-
- **⚡ High Performance**: WebSocket-based with optimized binary protocol
|
61
|
-
- **🛡️ Built-in Reliability**: Auto-reconnection, timeouts, error handling
|
62
|
-
- **📦 Zero Dependencies**: Pure Python implementation
|
63
|
-
- **🎯 Thread-Safe**: Safe for multi-threaded applications
|
64
|
-
|
65
|
-
## ✨ What's New in v1.1.0
|
66
|
-
|
67
|
-
🛠️ **Critical Bug Fixes**:
|
68
|
-
- ✅ **Fixed missing `create_response()` method** - Request/response now working
|
69
|
-
- ✅ **Fixed socket timeout deadlock** - Stable connections after handshake
|
70
|
-
- ✅ **Fixed threading deadlock** - Resolved receive/send blocking issue
|
71
|
-
- ✅ **Fully functional bidirectional communication** - Both directions working perfectly
|
72
|
-
|
73
|
-
## 📦 Installation
|
74
|
-
|
75
|
-
```bash
|
76
|
-
pip install ipc-framework
|
77
|
-
```
|
78
|
-
|
79
|
-
## 🎯 Quick Start
|
80
|
-
|
81
|
-
### Python Server
|
82
|
-
|
83
|
-
```python
|
84
|
-
from ipc_framework import FrameworkServer, MessageType
|
85
|
-
import time
|
86
|
-
|
87
|
-
# Create server
|
88
|
-
server = FrameworkServer(host="localhost", port=8888)
|
89
|
-
|
90
|
-
# Create application and channel
|
91
|
-
app = server.create_application("my_app", "My Application")
|
92
|
-
api_channel = app.create_channel("api")
|
93
|
-
|
94
|
-
# Handle requests
|
95
|
-
def handle_request(message):
|
96
|
-
if message.payload.get('action') == 'get_time':
|
97
|
-
# Use the working create_response() method!
|
98
|
-
response = message.create_response({
|
99
|
-
'success': True,
|
100
|
-
'time': time.time(),
|
101
|
-
'message': 'Current server time'
|
102
|
-
})
|
103
|
-
|
104
|
-
connection = server.connection_manager.get_connection(
|
105
|
-
message.payload.get('connection_id')
|
106
|
-
)
|
107
|
-
server.send_to_connection(connection, response)
|
108
|
-
|
109
|
-
api_channel.set_handler(MessageType.REQUEST, handle_request)
|
110
|
-
server.start()
|
111
|
-
```
|
112
|
-
|
113
|
-
### Python Client
|
114
|
-
|
115
|
-
```python
|
116
|
-
from ipc_framework import FrameworkClient
|
117
|
-
|
118
|
-
# Create and connect client
|
119
|
-
client = FrameworkClient("my_app", host="localhost", port=8888)
|
120
|
-
client.connect()
|
121
|
-
|
122
|
-
# Send request and get response
|
123
|
-
response = client.send_request("api", {
|
124
|
-
"action": "get_time",
|
125
|
-
"connection_id": client.connection_id
|
126
|
-
})
|
127
|
-
|
128
|
-
print(f"Server time: {response.payload['time']}")
|
129
|
-
client.disconnect()
|
130
|
-
```
|
131
|
-
|
132
|
-
### JavaScript Client (Works with Python Server!)
|
133
|
-
|
134
|
-
```javascript
|
135
|
-
import { IPCClient } from '@ifesol/ipc-framework-js';
|
136
|
-
|
137
|
-
const client = new IPCClient('my_app', {
|
138
|
-
host: 'localhost',
|
139
|
-
port: 8888
|
140
|
-
});
|
141
|
-
|
142
|
-
await client.connect();
|
143
|
-
|
144
|
-
const response = await client.sendRequest('api', {
|
145
|
-
action: 'get_time',
|
146
|
-
connection_id: client.connectionId
|
147
|
-
});
|
148
|
-
|
149
|
-
console.log('Server time:', response.payload.time);
|
150
|
-
```
|
151
|
-
|
152
|
-
## 🔄 Communication Patterns
|
153
|
-
|
154
|
-
### 1. Request/Response (Bidirectional)
|
155
|
-
```python
|
156
|
-
# Client → Server → Client
|
157
|
-
response = client.send_request("api", {"action": "get_users"})
|
158
|
-
```
|
159
|
-
|
160
|
-
### 2. Pub/Sub Notifications (Server → Client)
|
161
|
-
```python
|
162
|
-
# Server broadcasts to all subscribers
|
163
|
-
def notification_handler(message):
|
164
|
-
print(f"Notification: {message.payload}")
|
165
|
-
|
166
|
-
client.subscribe("notifications", notification_handler)
|
167
|
-
```
|
168
|
-
|
169
|
-
### 3. Real-time Updates (Both Directions)
|
170
|
-
```python
|
171
|
-
# Client can trigger server notifications
|
172
|
-
client.request("api", {"action": "trigger_notification"})
|
173
|
-
# Server sends real-time updates to all clients
|
174
|
-
```
|
175
|
-
|
176
|
-
## 🌍 Cross-Language Architecture
|
177
|
-
|
178
|
-
```
|
179
|
-
┌─────────────────┐ WebSocket ┌──────────────────┐
|
180
|
-
│ Python Server │ ←──────────────→ │ JavaScript Client│
|
181
|
-
│ │ │ (Browser/Node) │
|
182
|
-
│ - Applications │ │ - TypeScript │
|
183
|
-
│ - Channels │ │ - React/Vue │
|
184
|
-
│ - Message Routing │ - Auto-reconnect│
|
185
|
-
└─────────────────┘ └──────────────────┘
|
186
|
-
```
|
187
|
-
|
188
|
-
## 📊 Performance & Reliability
|
189
|
-
|
190
|
-
| Feature | Status |
|
191
|
-
|---------|---------|
|
192
|
-
| **Bidirectional Messaging** | ✅ Working |
|
193
|
-
| **Connection Stability** | ✅ Fixed deadlocks |
|
194
|
-
| **Request/Response** | ✅ Working |
|
195
|
-
| **Pub/Sub** | ✅ Working |
|
196
|
-
| **Error Handling** | ✅ Built-in |
|
197
|
-
| **Thread Safety** | ✅ Fixed |
|
198
|
-
| **Auto-reconnection** | ✅ JS client |
|
199
|
-
|
200
|
-
## 🛠️ Command Line Tools
|
201
|
-
|
202
|
-
The package includes several CLI tools for testing:
|
203
|
-
|
204
|
-
```bash
|
205
|
-
# Start demo server
|
206
|
-
ipc-server
|
207
|
-
|
208
|
-
# Interactive chat client
|
209
|
-
ipc-chat your_username
|
210
|
-
|
211
|
-
# File sharing demo
|
212
|
-
ipc-file
|
213
|
-
|
214
|
-
# System monitoring
|
215
|
-
ipc-monitor
|
216
|
-
|
217
|
-
# Full framework demo
|
218
|
-
ipc-demo
|
219
|
-
```
|
220
|
-
|
221
|
-
## 🎯 Use Cases
|
222
|
-
|
223
|
-
### Real-time Applications
|
224
|
-
- **Chat systems** with multiple channels
|
225
|
-
- **Live dashboards** with metric streaming
|
226
|
-
- **Collaborative editors** with real-time updates
|
227
|
-
- **Gaming** with real-time state sync
|
228
|
-
|
229
|
-
### Web Applications
|
230
|
-
- **Python backend** ↔ **React frontend**
|
231
|
-
- **API servers** with real-time notifications
|
232
|
-
- **Microservice communication**
|
233
|
-
- **IoT device control**
|
234
|
-
|
235
|
-
### Multi-Process Systems
|
236
|
-
- **Service-to-service** communication
|
237
|
-
- **Background task** coordination
|
238
|
-
- **Distributed processing**
|
239
|
-
- **Event-driven architectures**
|
240
|
-
|
241
|
-
## 📚 Documentation
|
242
|
-
|
243
|
-
- **[Complete Documentation](./docs/README.md)** - Full guides and examples
|
244
|
-
- **[API Reference](./docs/api-reference.md)** - Detailed API documentation
|
245
|
-
- **[Integration Guide](./docs/integration-guide.md)** - Framework integration examples
|
246
|
-
- **[Examples](./docs/examples.md)** - Real-world usage examples
|
247
|
-
|
248
|
-
## 🆚 Why Choose IPC Framework?
|
249
|
-
|
250
|
-
| Traditional IPC | IPC Framework |
|
251
|
-
|----------------|---------------|
|
252
|
-
| ❌ Complex setup | ✅ 3-line setup |
|
253
|
-
| ❌ Python-only | ✅ Python ↔ JavaScript |
|
254
|
-
| ❌ Manual protocols | ✅ Built-in patterns |
|
255
|
-
| ❌ No web support | ✅ Direct browser clients |
|
256
|
-
| ❌ External dependencies | ✅ Zero dependencies |
|
257
|
-
|
258
|
-
## 🔗 Related Packages
|
259
|
-
|
260
|
-
- **JavaScript Client**: [@ifesol/ipc-framework-js](https://www.npmjs.com/package/@ifesol/ipc-framework-js)
|
261
|
-
- **NPM Package**: Full TypeScript support for Node.js and browsers
|
262
|
-
|
263
|
-
## 📄 License
|
264
|
-
|
265
|
-
MIT License - see [LICENSE](LICENSE) file for details.
|
266
|
-
|
267
|
-
## 🤝 Contributing
|
268
|
-
|
269
|
-
Contributions are welcome! Please feel free to submit issues and pull requests.
|
270
|
-
|
271
|
-
---
|
272
|
-
|
273
|
-
**Ready for production use!** 🚀 The framework now provides reliable, bidirectional communication between Python servers and JavaScript clients.
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|