ipc-framework 1.1.0__tar.gz → 1.1.2__tar.gz
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-1.1.2/CHANGELOG.md +139 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/MANIFEST.in +24 -20
- ipc_framework-1.1.2/PKG-INFO +273 -0
- ipc_framework-1.1.2/README.md +228 -0
- ipc_framework-1.1.2/docs/README.md +362 -0
- ipc_framework-1.1.2/docs/api-reference.md +556 -0
- ipc_framework-1.1.2/docs/examples.md +846 -0
- ipc_framework-1.1.2/docs/getting-started.md +277 -0
- ipc_framework-1.1.2/docs/installation-guide.md +290 -0
- ipc_framework-1.1.2/docs/integration-guide.md +1180 -0
- ipc_framework-1.1.2/docs/nodejs-package.md +2061 -0
- ipc_framework-1.1.2/docs/python-package.md +1422 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/ipc_framework/__init__.py +1 -1
- ipc_framework-1.1.2/ipc_framework.egg-info/PKG-INFO +273 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/ipc_framework.egg-info/SOURCES.txt +9 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/pyproject.toml +5 -5
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/setup.py +2 -2
- ipc_framework-1.1.0/PKG-INFO +0 -273
- ipc_framework-1.1.0/README.md +0 -228
- ipc_framework-1.1.0/ipc_framework.egg-info/PKG-INFO +0 -273
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/LICENSE +0 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/examples/__init__.py +0 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/examples/basic_server.py +0 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/examples/chat_client.py +0 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/examples/file_client.py +0 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/examples/monitoring_client.py +0 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/ipc_framework/client.py +0 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/ipc_framework/core.py +0 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/ipc_framework/demo.py +0 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/ipc_framework/examples/__init__.py +0 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/ipc_framework/examples/basic_server.py +0 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/ipc_framework/examples/chat_client.py +0 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/ipc_framework/examples/file_client.py +0 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/ipc_framework/examples/monitoring_client.py +0 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/ipc_framework/exceptions.py +0 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/ipc_framework/py.typed +0 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/ipc_framework/server.py +0 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/ipc_framework.egg-info/dependency_links.txt +0 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/ipc_framework.egg-info/entry_points.txt +0 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/ipc_framework.egg-info/not-zip-safe +0 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/ipc_framework.egg-info/requires.txt +0 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/ipc_framework.egg-info/top_level.txt +0 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/requirements.txt +0 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/setup.cfg +0 -0
- {ipc_framework-1.1.0 → ipc_framework-1.1.2}/tests/test_basic.py +0 -0
@@ -0,0 +1,139 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [1.1.3] - 2024-01-XX
|
9
|
+
|
10
|
+
### Documentation Distribution
|
11
|
+
- **FIXED**: Documentation now included in published NPM package
|
12
|
+
- **ADDED**: `docs/`, `examples/`, `test/` directories to NPM package files
|
13
|
+
- **FIXED**: Documentation now included in Python package via updated MANIFEST.in
|
14
|
+
- **PACKAGE SIZE**: NPM package now ~265KB (vs 25KB) with full documentation
|
15
|
+
- **DISTRIBUTION**: Users can now access docs offline after `npm install`
|
16
|
+
|
17
|
+
## [1.1.2] - 2024-01-XX
|
18
|
+
|
19
|
+
### Fixed (PyPI Documentation)
|
20
|
+
- **CRITICAL**: Fixed PyPI documentation to correctly describe Python TCP server (not WebSocket)
|
21
|
+
- **CRITICAL**: Updated package references from `@ifesol/ipc-framework-js` to `@ifesol/ipc-framework-nodejs`
|
22
|
+
- **CRITICAL**: Removed incorrect WebSocket architecture descriptions
|
23
|
+
- **CRITICAL**: Updated to focus on Python server capabilities with Node.js client integration
|
24
|
+
- **IMPROVED**: Added correct TCP-based performance characteristics and use cases
|
25
|
+
|
26
|
+
### Changed (Documentation)
|
27
|
+
- **BREAKING**: Documentation now correctly represents this as Python server package
|
28
|
+
- **ARCHITECTURE**: Properly describes TCP socket communication (not WebSocket)
|
29
|
+
- **EXAMPLES**: Python-focused examples with correct Node.js client integration
|
30
|
+
- **METADATA**: Updated package description and keywords for better discoverability
|
31
|
+
|
32
|
+
### Package Contents
|
33
|
+
**NPM Package now includes:**
|
34
|
+
- Core implementation (`index.js`, `src/tcp-client.js`)
|
35
|
+
- **Full documentation** (`docs/nodejs-package.md`, `docs/api-reference.md`, etc.)
|
36
|
+
- **Working examples** (`examples/basic-usage.js`, `examples/express-integration.js`)
|
37
|
+
- **Tests** (`test/basic-test.js`)
|
38
|
+
|
39
|
+
**Python Package now includes:**
|
40
|
+
- All Python source code and examples
|
41
|
+
- **Full documentation** (`docs/` directory with all .md files)
|
42
|
+
- **CHANGELOG.md** for version history
|
43
|
+
|
44
|
+
## [1.1.2] - 2024-01-XX
|
45
|
+
|
46
|
+
### Documentation
|
47
|
+
- **UPDATED**: Comprehensive `docs/nodejs-package.md` documentation with v1.1.1 fixes
|
48
|
+
- **ADDED**: Complete API reference with TCP implementation details
|
49
|
+
- **ADDED**: Express.js integration examples and patterns
|
50
|
+
- **ADDED**: Microservices architecture examples
|
51
|
+
- **ADDED**: Advanced usage patterns (connection pooling, message queuing)
|
52
|
+
- **ADDED**: Performance optimization techniques
|
53
|
+
- **ADDED**: Migration guide from broken v1.1.0
|
54
|
+
- **ADDED**: Troubleshooting section with common issues
|
55
|
+
- **REMOVED**: All outdated WebSocket/browser references
|
56
|
+
|
57
|
+
### Changes
|
58
|
+
- No code changes - documentation-only release
|
59
|
+
- Package includes updated comprehensive documentation
|
60
|
+
|
61
|
+
## [1.1.1] - 2024-01-XX
|
62
|
+
|
63
|
+
### CRITICAL FIXES
|
64
|
+
- **FIXED**: Replaced broken WebSocket implementation with TCP socket communication
|
65
|
+
- **FIXED**: Removed module system conflicts (CommonJS/ESM) that caused require() errors
|
66
|
+
- **FIXED**: Eliminated WebSocket dependency resolution issues
|
67
|
+
- **FIXED**: Removed complex Rollup/TypeScript build system causing distribution problems
|
68
|
+
- **FIXED**: Context-dependent behavior that made package work from CLI but fail in scripts
|
69
|
+
|
70
|
+
### Changed
|
71
|
+
- **BREAKING**: Now uses TCP sockets instead of WebSockets for Python server communication
|
72
|
+
- **ARCHITECTURE**: Simplified to pure CommonJS module (removed ESM complexity)
|
73
|
+
- **BUILD**: Removed Rollup, TypeScript, and complex build pipeline
|
74
|
+
- **DEPENDENCIES**: Removed all external dependencies - now uses only Node.js built-ins
|
75
|
+
- **PACKAGE**: Simplified structure with direct `index.js` entry point
|
76
|
+
|
77
|
+
### Added
|
78
|
+
- Full TCP message framing with proper buffering for reliable communication
|
79
|
+
- Automatic reconnection with configurable attempts and delays
|
80
|
+
- Heartbeat system for connection health monitoring
|
81
|
+
- Express.js middleware integration helper
|
82
|
+
- Comprehensive error handling and logging
|
83
|
+
- Server-Sent Events example for real-time browser updates
|
84
|
+
|
85
|
+
### Technical Details
|
86
|
+
- Uses `net` module for raw TCP socket communication (matches Python server protocol)
|
87
|
+
- Implements 4-byte length headers for proper message framing
|
88
|
+
- Fixed message field names to match Python server (`message_id` vs `messageId`)
|
89
|
+
- Added connection pooling support for high-throughput applications
|
90
|
+
- Improved memory management with proper buffer cleanup
|
91
|
+
|
92
|
+
### Migration from 1.1.0
|
93
|
+
The v1.1.0 package was fundamentally broken. v1.1.1 is a complete rewrite:
|
94
|
+
|
95
|
+
```javascript
|
96
|
+
// OLD (v1.1.0) - BROKEN
|
97
|
+
const { IPCClient } = require('@ifesol/ipc-framework-nodejs'); // Failed to load
|
98
|
+
|
99
|
+
// NEW (v1.1.1) - WORKING
|
100
|
+
const { IPCClient } = require('@ifesol/ipc-framework-nodejs'); // ✅ Works correctly
|
101
|
+
const client = new IPCClient('my-app');
|
102
|
+
await client.connect(); // ✅ TCP connection to Python server
|
103
|
+
```
|
104
|
+
|
105
|
+
## [1.1.0] - 2024-01-XX
|
106
|
+
|
107
|
+
### Fixed (Python Package Only)
|
108
|
+
- **CRITICAL**: Fixed missing `create_response()` method in Message class
|
109
|
+
- **CRITICAL**: Fixed socket timeout deadlock in client after successful handshake
|
110
|
+
- **CRITICAL**: Fixed threading deadlock in receive operations causing eternal hangs
|
111
|
+
- **PERFORMANCE**: Optimized message handling and reduced memory usage
|
112
|
+
- **STABILITY**: Improved error handling and connection resilience
|
113
|
+
|
114
|
+
### Added (Python Package Only)
|
115
|
+
- Enhanced logging for better debugging
|
116
|
+
- Connection state validation
|
117
|
+
- Automatic cleanup of failed connections
|
118
|
+
- Performance monitoring capabilities
|
119
|
+
|
120
|
+
### Technical Details (Python Package Only)
|
121
|
+
- Removed socket timeout after successful connection establishment
|
122
|
+
- Removed socket lock from `_receive_message()` method to prevent deadlocks
|
123
|
+
- Added proper message creation API matching documentation
|
124
|
+
- Fixed notification delivery mechanism
|
125
|
+
|
126
|
+
## [1.0.0] - 2024-01-XX
|
127
|
+
|
128
|
+
### Added
|
129
|
+
- Initial release of IPC Framework
|
130
|
+
- WebSocket-based communication (later found to be incompatible with Python servers)
|
131
|
+
- Basic client-server messaging
|
132
|
+
- Channel subscription system
|
133
|
+
- Real-time notifications
|
134
|
+
|
135
|
+
### Known Issues (Fixed in 1.1.1)
|
136
|
+
- ❌ Used WebSocket instead of TCP (incompatible with Python servers)
|
137
|
+
- ❌ Module system conflicts preventing package loading
|
138
|
+
- ❌ Complex build system causing distribution issues
|
139
|
+
- ❌ Dependency resolution problems with 'ws' package
|
@@ -1,21 +1,25 @@
|
|
1
|
-
# Include the README and other documentation
|
2
|
-
include README.md
|
3
|
-
include LICENSE
|
4
|
-
include requirements.txt
|
5
|
-
include pyproject.toml
|
6
|
-
|
7
|
-
# Include
|
8
|
-
recursive-include
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
1
|
+
# Include the README and other documentation
|
2
|
+
include README.md
|
3
|
+
include LICENSE
|
4
|
+
include requirements.txt
|
5
|
+
include pyproject.toml
|
6
|
+
|
7
|
+
# Include comprehensive documentation
|
8
|
+
recursive-include docs *.md
|
9
|
+
include CHANGELOG.md
|
10
|
+
|
11
|
+
# Include example scripts
|
12
|
+
recursive-include examples *.py
|
13
|
+
|
14
|
+
# Include package data
|
15
|
+
include ipc_framework/py.typed
|
16
|
+
|
17
|
+
# Exclude development and build files
|
18
|
+
exclude demo.py
|
19
|
+
exclude .gitignore
|
20
|
+
exclude *.yaml
|
21
|
+
exclude *.yml
|
22
|
+
global-exclude __pycache__
|
23
|
+
global-exclude *.py[co]
|
24
|
+
global-exclude *.so
|
21
25
|
global-exclude .DS_Store
|
@@ -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.
|
@@ -0,0 +1,228 @@
|
|
1
|
+
# IPC Framework - Inter-Process Communication
|
2
|
+
|
3
|
+
[](https://www.npmjs.com/package/@ifesol/ipc-framework-nodejs)
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
5
|
+
|
6
|
+
**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.
|
7
|
+
|
8
|
+
## 🐍 **Python Server Package**
|
9
|
+
|
10
|
+
This package provides the **Python IPC server** for communication with Node.js clients.
|
11
|
+
|
12
|
+
**✅ Production Ready Features:**
|
13
|
+
- ✅ TCP socket server (high-performance, low-latency)
|
14
|
+
- ✅ Hierarchical application and channel management
|
15
|
+
- ✅ Request/response and publish/subscribe patterns
|
16
|
+
- ✅ Connection pooling and auto-reconnection support
|
17
|
+
- ✅ Thread-safe operation with robust error handling
|
18
|
+
|
19
|
+
## 🚀 **Quick Start**
|
20
|
+
|
21
|
+
### **Installation**
|
22
|
+
|
23
|
+
```bash
|
24
|
+
# Install Python IPC server
|
25
|
+
pip install ipc-framework
|
26
|
+
|
27
|
+
# Install Node.js client (separate package)
|
28
|
+
npm install @ifesol/ipc-framework-nodejs
|
29
|
+
```
|
30
|
+
|
31
|
+
### **Python Server Usage**
|
32
|
+
|
33
|
+
```python
|
34
|
+
from ipc_framework import FrameworkServer, MessageType
|
35
|
+
import time
|
36
|
+
|
37
|
+
# Create server
|
38
|
+
server = FrameworkServer(host="localhost", port=8888)
|
39
|
+
|
40
|
+
# Create application and channel
|
41
|
+
app = server.create_application("my_app", "My Application")
|
42
|
+
api_channel = app.create_channel("api")
|
43
|
+
|
44
|
+
# Handle requests from Node.js clients
|
45
|
+
def handle_request(message):
|
46
|
+
action = message.payload.get('action')
|
47
|
+
|
48
|
+
if action == 'get_data':
|
49
|
+
response = message.create_response({
|
50
|
+
'success': True,
|
51
|
+
'data': {'timestamp': time.time(), 'message': 'Hello from Python!'},
|
52
|
+
'server': 'Python IPC Framework'
|
53
|
+
})
|
54
|
+
|
55
|
+
connection = server.connection_manager.get_connection(
|
56
|
+
message.payload.get('connection_id')
|
57
|
+
)
|
58
|
+
server.send_to_connection(connection, response)
|
59
|
+
|
60
|
+
api_channel.set_handler(MessageType.REQUEST, handle_request)
|
61
|
+
|
62
|
+
print("🐍 Python IPC Server starting on localhost:8888")
|
63
|
+
server.start()
|
64
|
+
```
|
65
|
+
|
66
|
+
### **Node.js Client Usage**
|
67
|
+
|
68
|
+
```javascript
|
69
|
+
const { IPCClient } = require('@ifesol/ipc-framework-nodejs');
|
70
|
+
|
71
|
+
async function main() {
|
72
|
+
const client = new IPCClient('my_app', {
|
73
|
+
host: 'localhost',
|
74
|
+
port: 8888
|
75
|
+
});
|
76
|
+
|
77
|
+
try {
|
78
|
+
await client.connect();
|
79
|
+
console.log('✅ Connected to Python server!');
|
80
|
+
|
81
|
+
const response = await client.sendRequest('api', {
|
82
|
+
action: 'get_data'
|
83
|
+
});
|
84
|
+
|
85
|
+
console.log('📨 Response from Python:', response.payload);
|
86
|
+
} catch (error) {
|
87
|
+
console.error('❌ Error:', error.message);
|
88
|
+
} finally {
|
89
|
+
client.disconnect();
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
main();
|
94
|
+
```
|
95
|
+
|
96
|
+
## 🎯 **Architecture Features**
|
97
|
+
|
98
|
+
### **✅ Production-Ready Server:**
|
99
|
+
- **High-performance TCP sockets** for low-latency communication
|
100
|
+
- **Hierarchical structure** with applications and channels
|
101
|
+
- **Message routing** and automatic connection management
|
102
|
+
- **Thread-safe operations** with robust error handling
|
103
|
+
|
104
|
+
### **✅ Communication Patterns:**
|
105
|
+
- **Request/Response** - Direct client-server communication
|
106
|
+
- **Publish/Subscribe** - Real-time notifications and broadcasts
|
107
|
+
- **Channel-based routing** - Organized message handling
|
108
|
+
- **Connection pooling** - Efficient resource management
|
109
|
+
|
110
|
+
## 🏗️ **Integration with Node.js**
|
111
|
+
|
112
|
+
This Python server works seamlessly with Node.js applications. Here's how to connect an Express.js app:
|
113
|
+
|
114
|
+
**Node.js Express.js Integration:**
|
115
|
+
```javascript
|
116
|
+
const express = require('express');
|
117
|
+
const { IPCClient } = require('@ifesol/ipc-framework-nodejs');
|
118
|
+
|
119
|
+
const app = express();
|
120
|
+
const pythonClient = new IPCClient('web_api');
|
121
|
+
|
122
|
+
app.use(express.json());
|
123
|
+
|
124
|
+
// Initialize connection to Python IPC server
|
125
|
+
pythonClient.connect().then(() => {
|
126
|
+
console.log('🔗 Connected to Python IPC server');
|
127
|
+
});
|
128
|
+
|
129
|
+
// API endpoint proxying to Python backend
|
130
|
+
app.post('/api/process', async (req, res) => {
|
131
|
+
try {
|
132
|
+
const result = await pythonClient.sendRequest('processing', {
|
133
|
+
action: 'process_user_data',
|
134
|
+
data: req.body,
|
135
|
+
connection_id: pythonClient.connectionId
|
136
|
+
});
|
137
|
+
|
138
|
+
res.json(result.payload);
|
139
|
+
} catch (error) {
|
140
|
+
res.status(500).json({ error: error.message });
|
141
|
+
}
|
142
|
+
});
|
143
|
+
|
144
|
+
app.listen(3000, () => {
|
145
|
+
console.log('🌐 Express server running on port 3000');
|
146
|
+
console.log('📡 Proxying requests to Python IPC server');
|
147
|
+
});
|
148
|
+
```
|
149
|
+
|
150
|
+
## 📊 **Performance Characteristics**
|
151
|
+
|
152
|
+
| Feature | Performance | Details |
|
153
|
+
|---------|-------------|---------|
|
154
|
+
| **Connection Handling** | Sub-millisecond | Fast TCP connection establishment |
|
155
|
+
| **Message Processing** | <1ms latency | Direct socket communication |
|
156
|
+
| **Concurrent Connections** | 100+ clients | Thread-safe connection management |
|
157
|
+
| **Message Throughput** | High-volume | Efficient message routing |
|
158
|
+
| **Memory Usage** | Low footprint | Optimized Python implementation |
|
159
|
+
| **Error Recovery** | Automatic | Robust connection cleanup |
|
160
|
+
|
161
|
+
## 🎯 **Use Cases**
|
162
|
+
|
163
|
+
This Python IPC server enables powerful hybrid architectures:
|
164
|
+
|
165
|
+
### **Backend Services**
|
166
|
+
- **AI/ML model serving** - Host machine learning models and serve predictions to Node.js frontends
|
167
|
+
- **Data processing pipelines** - Heavy computational tasks handled by Python, coordinated with Node.js
|
168
|
+
- **Real-time analytics** - Python analytics engines feeding real-time dashboards
|
169
|
+
- **Scientific computing** - NumPy/SciPy computations accessible from Node.js applications
|
170
|
+
|
171
|
+
### **Microservice Architecture**
|
172
|
+
- **Polyglot microservices** - Python services integrated with Node.js API gateways
|
173
|
+
- **Event-driven architecture** - Python services publishing events to Node.js consumers
|
174
|
+
- **Service mesh integration** - Python backend services in cloud-native environments
|
175
|
+
- **Legacy system integration** - Bridge existing Python systems with modern Node.js frontends
|
176
|
+
|
177
|
+
### **Hybrid Applications**
|
178
|
+
- **E-commerce platforms** - Python inventory/pricing engines with Node.js storefronts
|
179
|
+
- **Financial services** - Python quantitative analysis with Node.js trading interfaces
|
180
|
+
- **IoT platforms** - Python device controllers with Node.js monitoring dashboards
|
181
|
+
- **Chat applications** - Python NLP processing with Node.js real-time messaging
|
182
|
+
|
183
|
+
## 🆚 **Why Choose IPC over HTTP?**
|
184
|
+
|
185
|
+
| HTTP API Approach | IPC Framework |
|
186
|
+
|-------------------|---------------|
|
187
|
+
| ❌ High latency overhead | ✅ Direct TCP communication |
|
188
|
+
| ❌ Request/response only | ✅ Request/response + pub/sub |
|
189
|
+
| ❌ Manual connection management | ✅ Automatic reconnection |
|
190
|
+
| ❌ Complex error handling | ✅ Built-in fault tolerance |
|
191
|
+
| ❌ No real-time capabilities | ✅ Live notifications |
|
192
|
+
| ❌ Stateless limitations | ✅ Persistent connections |
|
193
|
+
|
194
|
+
## 🔗 **Companion Packages**
|
195
|
+
|
196
|
+
This Python server works with the Node.js client package:
|
197
|
+
|
198
|
+
- **Node.js Client**: [@ifesol/ipc-framework-nodejs](https://www.npmjs.com/package/@ifesol/ipc-framework-nodejs) - Production-ready TCP client
|
199
|
+
- **Installation**: `npm install @ifesol/ipc-framework-nodejs`
|
200
|
+
- **Documentation**: [Node.js Package Docs](https://www.npmjs.com/package/@ifesol/ipc-framework-nodejs)
|
201
|
+
|
202
|
+
## 🚀 **Getting Started**
|
203
|
+
|
204
|
+
1. **Install the Python server:**
|
205
|
+
```bash
|
206
|
+
pip install ipc-framework
|
207
|
+
```
|
208
|
+
|
209
|
+
2. **Install the Node.js client:**
|
210
|
+
```bash
|
211
|
+
npm install @ifesol/ipc-framework-nodejs
|
212
|
+
```
|
213
|
+
|
214
|
+
3. **Run the examples above** to see the integration in action!
|
215
|
+
|
216
|
+
## 📚 **Documentation**
|
217
|
+
|
218
|
+
- [Python API Reference](https://github.com/ifesol/ipc-framework#python-api)
|
219
|
+
- [Node.js Client Usage](https://www.npmjs.com/package/@ifesol/ipc-framework-nodejs)
|
220
|
+
- [Integration Examples](https://github.com/ifesol/ipc-framework/tree/main/examples)
|
221
|
+
|
222
|
+
## 📄 License
|
223
|
+
|
224
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
225
|
+
|
226
|
+
## 🤝 Contributing
|
227
|
+
|
228
|
+
Contributions welcome! Help us improve the Python ↔ Node.js IPC communication experience.
|