django-cfg 1.4.61__py3-none-any.whl → 1.4.63__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.
Potentially problematic release.
This version of django-cfg might be problematic. Click here for more details.
- django_cfg/__init__.py +1 -1
- django_cfg/apps/accounts/services/otp_service.py +3 -14
- django_cfg/apps/centrifugo/__init__.py +57 -0
- django_cfg/apps/centrifugo/admin/__init__.py +13 -0
- django_cfg/apps/centrifugo/admin/centrifugo_log.py +249 -0
- django_cfg/apps/centrifugo/admin/config.py +82 -0
- django_cfg/apps/centrifugo/apps.py +31 -0
- django_cfg/apps/centrifugo/codegen/IMPLEMENTATION_SUMMARY.md +475 -0
- django_cfg/apps/centrifugo/codegen/README.md +242 -0
- django_cfg/apps/centrifugo/codegen/USAGE.md +616 -0
- django_cfg/apps/centrifugo/codegen/__init__.py +19 -0
- django_cfg/apps/centrifugo/codegen/discovery.py +246 -0
- django_cfg/apps/centrifugo/codegen/generators/go_thin/__init__.py +5 -0
- django_cfg/apps/centrifugo/codegen/generators/go_thin/generator.py +174 -0
- django_cfg/apps/centrifugo/codegen/generators/go_thin/templates/README.md.j2 +182 -0
- django_cfg/apps/centrifugo/codegen/generators/go_thin/templates/client.go.j2 +64 -0
- django_cfg/apps/centrifugo/codegen/generators/go_thin/templates/go.mod.j2 +10 -0
- django_cfg/apps/centrifugo/codegen/generators/go_thin/templates/rpc_client.go.j2 +300 -0
- django_cfg/apps/centrifugo/codegen/generators/go_thin/templates/rpc_client.go.j2.old +267 -0
- django_cfg/apps/centrifugo/codegen/generators/go_thin/templates/types.go.j2 +16 -0
- django_cfg/apps/centrifugo/codegen/generators/python_thin/__init__.py +7 -0
- django_cfg/apps/centrifugo/codegen/generators/python_thin/generator.py +241 -0
- django_cfg/apps/centrifugo/codegen/generators/python_thin/templates/README.md.j2 +128 -0
- django_cfg/apps/centrifugo/codegen/generators/python_thin/templates/__init__.py.j2 +22 -0
- django_cfg/apps/centrifugo/codegen/generators/python_thin/templates/client.py.j2 +73 -0
- django_cfg/apps/centrifugo/codegen/generators/python_thin/templates/models.py.j2 +19 -0
- django_cfg/apps/centrifugo/codegen/generators/python_thin/templates/requirements.txt.j2 +8 -0
- django_cfg/apps/centrifugo/codegen/generators/python_thin/templates/rpc_client.py.j2 +193 -0
- django_cfg/apps/centrifugo/codegen/generators/typescript_thin/__init__.py +5 -0
- django_cfg/apps/centrifugo/codegen/generators/typescript_thin/generator.py +124 -0
- django_cfg/apps/centrifugo/codegen/generators/typescript_thin/templates/README.md.j2 +38 -0
- django_cfg/apps/centrifugo/codegen/generators/typescript_thin/templates/client.ts.j2 +25 -0
- django_cfg/apps/centrifugo/codegen/generators/typescript_thin/templates/index.ts.j2 +12 -0
- django_cfg/apps/centrifugo/codegen/generators/typescript_thin/templates/package.json.j2 +13 -0
- django_cfg/apps/centrifugo/codegen/generators/typescript_thin/templates/rpc-client.ts.j2 +137 -0
- django_cfg/apps/centrifugo/codegen/generators/typescript_thin/templates/tsconfig.json.j2 +14 -0
- django_cfg/apps/centrifugo/codegen/generators/typescript_thin/templates/types.ts.j2 +9 -0
- django_cfg/apps/centrifugo/codegen/utils/__init__.py +37 -0
- django_cfg/apps/centrifugo/codegen/utils/naming.py +155 -0
- django_cfg/apps/centrifugo/codegen/utils/type_converter.py +349 -0
- django_cfg/apps/centrifugo/decorators.py +137 -0
- django_cfg/apps/centrifugo/management/__init__.py +1 -0
- django_cfg/apps/centrifugo/management/commands/__init__.py +1 -0
- django_cfg/apps/centrifugo/management/commands/generate_centrifugo_clients.py +254 -0
- django_cfg/apps/centrifugo/managers/__init__.py +12 -0
- django_cfg/apps/centrifugo/managers/centrifugo_log.py +264 -0
- django_cfg/apps/centrifugo/migrations/0001_initial.py +164 -0
- django_cfg/apps/centrifugo/migrations/__init__.py +3 -0
- django_cfg/apps/centrifugo/models/__init__.py +11 -0
- django_cfg/apps/centrifugo/models/centrifugo_log.py +210 -0
- django_cfg/apps/centrifugo/registry.py +106 -0
- django_cfg/apps/centrifugo/router.py +125 -0
- django_cfg/apps/centrifugo/serializers/__init__.py +40 -0
- django_cfg/apps/centrifugo/serializers/admin_api.py +264 -0
- django_cfg/apps/centrifugo/serializers/channels.py +26 -0
- django_cfg/apps/centrifugo/serializers/health.py +17 -0
- django_cfg/apps/centrifugo/serializers/publishes.py +16 -0
- django_cfg/apps/centrifugo/serializers/stats.py +21 -0
- django_cfg/apps/centrifugo/services/__init__.py +12 -0
- django_cfg/apps/centrifugo/services/client/__init__.py +29 -0
- django_cfg/apps/centrifugo/services/client/client.py +577 -0
- django_cfg/apps/centrifugo/services/client/config.py +228 -0
- django_cfg/apps/centrifugo/services/client/exceptions.py +212 -0
- django_cfg/apps/centrifugo/services/config_helper.py +63 -0
- django_cfg/apps/centrifugo/services/dashboard_notifier.py +157 -0
- django_cfg/apps/centrifugo/services/logging.py +677 -0
- django_cfg/apps/centrifugo/static/django_cfg_centrifugo/css/dashboard.css +260 -0
- django_cfg/apps/centrifugo/static/django_cfg_centrifugo/js/dashboard/live_channels.mjs +313 -0
- django_cfg/apps/centrifugo/static/django_cfg_centrifugo/js/dashboard/live_testing.mjs +803 -0
- django_cfg/apps/centrifugo/static/django_cfg_centrifugo/js/dashboard/main.mjs +333 -0
- django_cfg/apps/centrifugo/static/django_cfg_centrifugo/js/dashboard/overview.mjs +432 -0
- django_cfg/apps/centrifugo/static/django_cfg_centrifugo/js/dashboard/testing.mjs +33 -0
- django_cfg/apps/centrifugo/static/django_cfg_centrifugo/js/dashboard/websocket.mjs +210 -0
- django_cfg/apps/centrifugo/templates/django_cfg_centrifugo/components/channels_content.html +46 -0
- django_cfg/apps/centrifugo/templates/django_cfg_centrifugo/components/live_channels_content.html +123 -0
- django_cfg/apps/centrifugo/templates/django_cfg_centrifugo/components/overview_content.html +45 -0
- django_cfg/apps/centrifugo/templates/django_cfg_centrifugo/components/publishes_content.html +84 -0
- django_cfg/apps/{ipc/templates/django_cfg_ipc → centrifugo/templates/django_cfg_centrifugo}/components/stat_cards.html +23 -20
- django_cfg/apps/centrifugo/templates/django_cfg_centrifugo/components/system_status.html +91 -0
- django_cfg/apps/{ipc/templates/django_cfg_ipc → centrifugo/templates/django_cfg_centrifugo}/components/tab_navigation.html +15 -15
- django_cfg/apps/centrifugo/templates/django_cfg_centrifugo/components/testing_tools.html +415 -0
- django_cfg/apps/centrifugo/templates/django_cfg_centrifugo/layout/base.html +61 -0
- django_cfg/apps/centrifugo/templates/django_cfg_centrifugo/pages/dashboard.html +58 -0
- django_cfg/apps/centrifugo/templates/django_cfg_centrifugo/tags/connection_script.html +48 -0
- django_cfg/apps/centrifugo/templatetags/__init__.py +1 -0
- django_cfg/apps/centrifugo/templatetags/centrifugo_tags.py +81 -0
- django_cfg/apps/centrifugo/urls.py +31 -0
- django_cfg/apps/{ipc → centrifugo}/urls_admin.py +4 -4
- django_cfg/apps/centrifugo/views/__init__.py +15 -0
- django_cfg/apps/centrifugo/views/admin_api.py +374 -0
- django_cfg/apps/centrifugo/views/dashboard.py +15 -0
- django_cfg/apps/centrifugo/views/monitoring.py +286 -0
- django_cfg/apps/centrifugo/views/testing_api.py +422 -0
- django_cfg/apps/support/utils/support_email_service.py +5 -18
- django_cfg/apps/tasks/templates/tasks/layout/base.html +0 -2
- django_cfg/apps/urls.py +5 -5
- django_cfg/core/base/config_model.py +4 -44
- django_cfg/core/builders/apps_builder.py +2 -2
- django_cfg/core/generation/integration_generators/third_party.py +8 -8
- django_cfg/core/utils/__init__.py +5 -0
- django_cfg/core/utils/url_helpers.py +73 -0
- django_cfg/modules/base.py +7 -7
- django_cfg/modules/django_client/core/__init__.py +2 -1
- django_cfg/modules/django_client/core/config/config.py +8 -0
- django_cfg/modules/django_client/core/generator/__init__.py +42 -2
- django_cfg/modules/django_client/core/generator/go/__init__.py +14 -0
- django_cfg/modules/django_client/core/generator/go/client_generator.py +124 -0
- django_cfg/modules/django_client/core/generator/go/files_generator.py +133 -0
- django_cfg/modules/django_client/core/generator/go/generator.py +203 -0
- django_cfg/modules/django_client/core/generator/go/models_generator.py +304 -0
- django_cfg/modules/django_client/core/generator/go/naming.py +193 -0
- django_cfg/modules/django_client/core/generator/go/operations_generator.py +134 -0
- django_cfg/modules/django_client/core/generator/go/templates/Makefile.j2 +38 -0
- django_cfg/modules/django_client/core/generator/go/templates/README.md.j2 +55 -0
- django_cfg/modules/django_client/core/generator/go/templates/client.go.j2 +122 -0
- django_cfg/modules/django_client/core/generator/go/templates/enums.go.j2 +49 -0
- django_cfg/modules/django_client/core/generator/go/templates/errors.go.j2 +182 -0
- django_cfg/modules/django_client/core/generator/go/templates/go.mod.j2 +6 -0
- django_cfg/modules/django_client/core/generator/go/templates/main_client.go.j2 +60 -0
- django_cfg/modules/django_client/core/generator/go/templates/middleware.go.j2 +388 -0
- django_cfg/modules/django_client/core/generator/go/templates/models.go.j2 +28 -0
- django_cfg/modules/django_client/core/generator/go/templates/operations_client.go.j2 +142 -0
- django_cfg/modules/django_client/core/generator/go/templates/validation.go.j2 +217 -0
- django_cfg/modules/django_client/core/generator/go/type_mapper.py +380 -0
- django_cfg/modules/django_client/management/commands/generate_client.py +53 -3
- django_cfg/modules/django_client/system/generate_mjs_clients.py +3 -1
- django_cfg/modules/django_client/system/schema_parser.py +5 -1
- django_cfg/modules/django_tailwind/templates/django_tailwind/base.html +1 -0
- django_cfg/modules/django_twilio/sendgrid_service.py +7 -4
- django_cfg/modules/django_unfold/dashboard.py +25 -19
- django_cfg/pyproject.toml +1 -1
- django_cfg/registry/core.py +2 -0
- django_cfg/registry/modules.py +2 -2
- django_cfg/static/js/api/centrifugo/client.mjs +164 -0
- django_cfg/static/js/api/centrifugo/index.mjs +13 -0
- django_cfg/static/js/api/index.mjs +5 -5
- django_cfg/static/js/api/types.mjs +89 -26
- {django_cfg-1.4.61.dist-info → django_cfg-1.4.63.dist-info}/METADATA +1 -1
- {django_cfg-1.4.61.dist-info → django_cfg-1.4.63.dist-info}/RECORD +142 -68
- django_cfg/apps/ipc/README.md +0 -346
- django_cfg/apps/ipc/RPC_LOGGING.md +0 -321
- django_cfg/apps/ipc/TESTING.md +0 -539
- django_cfg/apps/ipc/__init__.py +0 -60
- django_cfg/apps/ipc/admin.py +0 -212
- django_cfg/apps/ipc/apps.py +0 -28
- django_cfg/apps/ipc/migrations/0001_initial.py +0 -137
- django_cfg/apps/ipc/migrations/__init__.py +0 -0
- django_cfg/apps/ipc/models.py +0 -221
- django_cfg/apps/ipc/serializers/__init__.py +0 -29
- django_cfg/apps/ipc/serializers/serializers.py +0 -343
- django_cfg/apps/ipc/services/__init__.py +0 -7
- django_cfg/apps/ipc/services/client/__init__.py +0 -23
- django_cfg/apps/ipc/services/client/client.py +0 -621
- django_cfg/apps/ipc/services/client/config.py +0 -214
- django_cfg/apps/ipc/services/client/exceptions.py +0 -201
- django_cfg/apps/ipc/services/logging.py +0 -239
- django_cfg/apps/ipc/services/monitor.py +0 -466
- django_cfg/apps/ipc/static/django_cfg_ipc/js/dashboard/main.mjs +0 -269
- django_cfg/apps/ipc/static/django_cfg_ipc/js/dashboard/overview.mjs +0 -259
- django_cfg/apps/ipc/static/django_cfg_ipc/js/dashboard/testing.mjs +0 -375
- django_cfg/apps/ipc/static/django_cfg_ipc/js/dashboard.mjs.old +0 -441
- django_cfg/apps/ipc/templates/django_cfg_ipc/components/methods_content.html +0 -22
- django_cfg/apps/ipc/templates/django_cfg_ipc/components/notifications_content.html +0 -9
- django_cfg/apps/ipc/templates/django_cfg_ipc/components/overview_content.html +0 -9
- django_cfg/apps/ipc/templates/django_cfg_ipc/components/requests_content.html +0 -23
- django_cfg/apps/ipc/templates/django_cfg_ipc/components/system_status.html +0 -47
- django_cfg/apps/ipc/templates/django_cfg_ipc/components/testing_tools.html +0 -184
- django_cfg/apps/ipc/templates/django_cfg_ipc/layout/base.html +0 -71
- django_cfg/apps/ipc/templates/django_cfg_ipc/pages/dashboard.html +0 -56
- django_cfg/apps/ipc/urls.py +0 -23
- django_cfg/apps/ipc/views/__init__.py +0 -13
- django_cfg/apps/ipc/views/dashboard.py +0 -15
- django_cfg/apps/ipc/views/monitoring.py +0 -251
- django_cfg/apps/ipc/views/testing.py +0 -285
- django_cfg/static/js/api/ipc/client.mjs +0 -114
- django_cfg/static/js/api/ipc/index.mjs +0 -13
- {django_cfg-1.4.61.dist-info → django_cfg-1.4.63.dist-info}/WHEEL +0 -0
- {django_cfg-1.4.61.dist-info → django_cfg-1.4.63.dist-info}/entry_points.txt +0 -0
- {django_cfg-1.4.61.dist-info → django_cfg-1.4.63.dist-info}/licenses/LICENSE +0 -0
django_cfg/apps/ipc/TESTING.md
DELETED
|
@@ -1,539 +0,0 @@
|
|
|
1
|
-
# IPC/RPC Testing Tools
|
|
2
|
-
|
|
3
|
-
**Production-grade load testing and debugging tools for Django-CFG RPC system.**
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## 🎯 Overview
|
|
8
|
-
|
|
9
|
-
The IPC app now includes comprehensive testing tools for validating RPC communication between Django and WebSocket servers:
|
|
10
|
-
|
|
11
|
-
- **Test RPC Client** - Send individual RPC requests with response inspection
|
|
12
|
-
- **Load Testing Tool** - Emulate production load with concurrent requests
|
|
13
|
-
- **Real-time Monitoring** - Track test progress and performance metrics
|
|
14
|
-
- **Beautiful UI** - Tab-based interface with Material Design
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
## 📁 Architecture
|
|
19
|
-
|
|
20
|
-
### Template Structure
|
|
21
|
-
|
|
22
|
-
```
|
|
23
|
-
templates/django_cfg_ipc/
|
|
24
|
-
├── layout/
|
|
25
|
-
│ └── base.html # Base template with navbar
|
|
26
|
-
├── pages/
|
|
27
|
-
│ └── dashboard.html # Main dashboard page
|
|
28
|
-
├── components/
|
|
29
|
-
│ ├── stat_cards.html # Statistics overview cards
|
|
30
|
-
│ ├── system_status.html # Redis/Stream health indicators
|
|
31
|
-
│ ├── tab_navigation.html # Tab switcher with badges
|
|
32
|
-
│ ├── overview_content.html # Overview tab content
|
|
33
|
-
│ ├── requests_content.html # Recent requests table
|
|
34
|
-
│ ├── notifications_content.html # Notification statistics
|
|
35
|
-
│ ├── methods_content.html # Method statistics table
|
|
36
|
-
│ └── testing_tools.html # Testing tools tab
|
|
37
|
-
├── widgets/
|
|
38
|
-
└── partials/
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### Backend Structure
|
|
42
|
-
|
|
43
|
-
```
|
|
44
|
-
views/
|
|
45
|
-
├── __init__.py # Exports all viewsets
|
|
46
|
-
├── dashboard.py # Dashboard view
|
|
47
|
-
├── monitoring.py # RPCMonitorViewSet
|
|
48
|
-
└── testing.py # RPCTestingViewSet
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
---
|
|
52
|
-
|
|
53
|
-
## 🧪 Test RPC Client
|
|
54
|
-
|
|
55
|
-
### Purpose
|
|
56
|
-
|
|
57
|
-
Send individual RPC requests for:
|
|
58
|
-
- Debugging method implementations
|
|
59
|
-
- Validating parameter schemas
|
|
60
|
-
- Measuring response times
|
|
61
|
-
- Inspecting response payloads
|
|
62
|
-
|
|
63
|
-
### Features
|
|
64
|
-
|
|
65
|
-
- **Method Selection**: Dropdown with available RPC methods
|
|
66
|
-
- **Timeout Configuration**: 1-60 seconds
|
|
67
|
-
- **JSON Parameter Editor**: Syntax-highlighted textarea
|
|
68
|
-
- **Response Inspection**: Formatted JSON output
|
|
69
|
-
- **Error Handling**: Clear error messages with stack traces
|
|
70
|
-
|
|
71
|
-
### Usage Example
|
|
72
|
-
|
|
73
|
-
1. Navigate to **Testing** tab
|
|
74
|
-
2. Select RPC method (e.g., `notification.send`)
|
|
75
|
-
3. Edit parameters JSON:
|
|
76
|
-
```json
|
|
77
|
-
{
|
|
78
|
-
"user_id": "test-123",
|
|
79
|
-
"type": "test",
|
|
80
|
-
"title": "Test Notification",
|
|
81
|
-
"message": "This is a test message"
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
4. Set timeout (default: 10s)
|
|
85
|
-
5. Click **Send Request**
|
|
86
|
-
6. Inspect response:
|
|
87
|
-
- Success: Green badge + response JSON
|
|
88
|
-
- Failed: Red badge + error message
|
|
89
|
-
- Duration: Response time in milliseconds
|
|
90
|
-
|
|
91
|
-
### API Endpoint
|
|
92
|
-
|
|
93
|
-
```http
|
|
94
|
-
POST /cfg/ipc/test/send
|
|
95
|
-
Content-Type: application/json
|
|
96
|
-
|
|
97
|
-
{
|
|
98
|
-
"method": "notification.send",
|
|
99
|
-
"params": {
|
|
100
|
-
"user_id": "test-123",
|
|
101
|
-
"type": "test",
|
|
102
|
-
"title": "Test Notification",
|
|
103
|
-
"message": "Hello"
|
|
104
|
-
},
|
|
105
|
-
"timeout": 10
|
|
106
|
-
}
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
**Response:**
|
|
110
|
-
|
|
111
|
-
```json
|
|
112
|
-
{
|
|
113
|
-
"success": true,
|
|
114
|
-
"duration_ms": 45.23,
|
|
115
|
-
"response": {
|
|
116
|
-
"sent": true,
|
|
117
|
-
"message_id": "abc-123"
|
|
118
|
-
},
|
|
119
|
-
"error": null,
|
|
120
|
-
"correlation_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
|
|
121
|
-
}
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
---
|
|
125
|
-
|
|
126
|
-
## 🔥 Load Testing Tool
|
|
127
|
-
|
|
128
|
-
### Purpose
|
|
129
|
-
|
|
130
|
-
Emulate production traffic to:
|
|
131
|
-
- Validate system performance under load
|
|
132
|
-
- Identify bottlenecks
|
|
133
|
-
- Test concurrent request handling
|
|
134
|
-
- Measure throughput (RPS)
|
|
135
|
-
|
|
136
|
-
### Features
|
|
137
|
-
|
|
138
|
-
- **Configurable Volume**: 1-10,000 requests
|
|
139
|
-
- **Concurrency Control**: 1-100 concurrent requests
|
|
140
|
-
- **Method Selection**: Test any RPC method
|
|
141
|
-
- **Real-time Progress**: Progress bar + statistics
|
|
142
|
-
- **Live Metrics**:
|
|
143
|
-
- Success/Failed counts
|
|
144
|
-
- Average response time
|
|
145
|
-
- Requests per second (RPS)
|
|
146
|
-
- Elapsed time
|
|
147
|
-
|
|
148
|
-
### Usage Example
|
|
149
|
-
|
|
150
|
-
1. Navigate to **Testing** tab → **Load Testing Tool**
|
|
151
|
-
2. Configure test parameters:
|
|
152
|
-
- **Total Requests**: 100
|
|
153
|
-
- **Concurrent Requests**: 10
|
|
154
|
-
- **Test Method**: `notification.send`
|
|
155
|
-
3. Click **Start Load Test**
|
|
156
|
-
4. Monitor progress:
|
|
157
|
-
- Progress bar (0/100 → 100/100)
|
|
158
|
-
- Success: Green counter
|
|
159
|
-
- Failed: Red counter
|
|
160
|
-
- Avg Time: Purple badge (ms)
|
|
161
|
-
- RPS: Purple badge (requests/sec)
|
|
162
|
-
5. Click **Stop Test** to abort early (optional)
|
|
163
|
-
|
|
164
|
-
### API Endpoints
|
|
165
|
-
|
|
166
|
-
#### Start Load Test
|
|
167
|
-
|
|
168
|
-
```http
|
|
169
|
-
POST /cfg/ipc/test/load/start
|
|
170
|
-
Content-Type: application/json
|
|
171
|
-
|
|
172
|
-
{
|
|
173
|
-
"method": "notification.send",
|
|
174
|
-
"total_requests": 100,
|
|
175
|
-
"concurrency": 10,
|
|
176
|
-
"params": {
|
|
177
|
-
"user_id": "load-test",
|
|
178
|
-
"type": "test"
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
**Response:**
|
|
184
|
-
|
|
185
|
-
```json
|
|
186
|
-
{
|
|
187
|
-
"test_id": "abc123ef",
|
|
188
|
-
"started": true,
|
|
189
|
-
"message": "Load test started with 100 requests at 10 concurrency"
|
|
190
|
-
}
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
#### Get Load Test Status
|
|
194
|
-
|
|
195
|
-
```http
|
|
196
|
-
GET /cfg/ipc/test/load/status
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
**Response:**
|
|
200
|
-
|
|
201
|
-
```json
|
|
202
|
-
{
|
|
203
|
-
"test_id": "abc123ef",
|
|
204
|
-
"running": true,
|
|
205
|
-
"progress": 45,
|
|
206
|
-
"total": 100,
|
|
207
|
-
"success_count": 43,
|
|
208
|
-
"failed_count": 2,
|
|
209
|
-
"avg_duration_ms": 52.34,
|
|
210
|
-
"elapsed_time": 4.56,
|
|
211
|
-
"rps": 9.87
|
|
212
|
-
}
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
#### Stop Load Test
|
|
216
|
-
|
|
217
|
-
```http
|
|
218
|
-
POST /cfg/ipc/test/load/stop
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
**Response:**
|
|
222
|
-
|
|
223
|
-
```json
|
|
224
|
-
{
|
|
225
|
-
"message": "Load test stopped",
|
|
226
|
-
"progress": 45,
|
|
227
|
-
"total": 100
|
|
228
|
-
}
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
---
|
|
232
|
-
|
|
233
|
-
## 📊 Metrics & Statistics
|
|
234
|
-
|
|
235
|
-
### Real-time Stats
|
|
236
|
-
|
|
237
|
-
The load testing tool provides 4 live metrics:
|
|
238
|
-
|
|
239
|
-
| Metric | Description | Color |
|
|
240
|
-
|--------|-------------|-------|
|
|
241
|
-
| **Success** | Successful RPC calls | Blue |
|
|
242
|
-
| **Failed** | Failed RPC calls | Red |
|
|
243
|
-
| **Avg Time** | Average response time (ms) | Green |
|
|
244
|
-
| **RPS** | Requests per second | Purple |
|
|
245
|
-
|
|
246
|
-
### Performance Benchmarks
|
|
247
|
-
|
|
248
|
-
Typical performance on standard hardware:
|
|
249
|
-
|
|
250
|
-
- **Single Request**: 20-50ms
|
|
251
|
-
- **10 Concurrent**: ~30-60ms avg
|
|
252
|
-
- **100 Concurrent**: ~50-100ms avg
|
|
253
|
-
- **Throughput**: 50-200 RPS (depends on method)
|
|
254
|
-
|
|
255
|
-
### Error Tracking
|
|
256
|
-
|
|
257
|
-
Failed requests log:
|
|
258
|
-
- Error type (timeout, connection, remote error)
|
|
259
|
-
- Error message
|
|
260
|
-
- Duration until failure
|
|
261
|
-
- Stack trace (in Django logs)
|
|
262
|
-
|
|
263
|
-
---
|
|
264
|
-
|
|
265
|
-
## 🔒 Security & Permissions
|
|
266
|
-
|
|
267
|
-
### Authentication
|
|
268
|
-
|
|
269
|
-
All testing endpoints require:
|
|
270
|
-
- **Django Admin Access**: `IsAdminUser` permission
|
|
271
|
-
- **Staff Status**: `request.user.is_staff = True`
|
|
272
|
-
|
|
273
|
-
### Rate Limiting
|
|
274
|
-
|
|
275
|
-
To prevent abuse:
|
|
276
|
-
- **Max Total Requests**: 10,000 per test
|
|
277
|
-
- **Max Concurrency**: 100 simultaneous requests
|
|
278
|
-
- **Global Limit**: One active load test at a time
|
|
279
|
-
|
|
280
|
-
### Safety Features
|
|
281
|
-
|
|
282
|
-
1. **Thread Isolation**: Load tests run in background threads
|
|
283
|
-
2. **Graceful Shutdown**: Stop button terminates test safely
|
|
284
|
-
3. **Resource Cleanup**: Daemon threads auto-cleanup on exit
|
|
285
|
-
4. **Error Boundaries**: Exceptions don't crash test runner
|
|
286
|
-
|
|
287
|
-
---
|
|
288
|
-
|
|
289
|
-
## 🧩 Integration with RPC Logging
|
|
290
|
-
|
|
291
|
-
All test requests are logged to `RPCLog` model if logging is enabled:
|
|
292
|
-
|
|
293
|
-
```python
|
|
294
|
-
# View logs in Django Admin
|
|
295
|
-
/admin/django_cfg_ipc/rpclog/
|
|
296
|
-
|
|
297
|
-
# Filter by test runs
|
|
298
|
-
RPCLog.objects.filter(params___test_id='abc123ef')
|
|
299
|
-
|
|
300
|
-
# Analyze performance
|
|
301
|
-
stats = RPCLog.objects.stats_by_method()
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
Benefits:
|
|
305
|
-
- Full request/response history
|
|
306
|
-
- Performance metrics per method
|
|
307
|
-
- Error analysis
|
|
308
|
-
- User attribution
|
|
309
|
-
|
|
310
|
-
---
|
|
311
|
-
|
|
312
|
-
## 🎨 UI Components
|
|
313
|
-
|
|
314
|
-
### Tab Navigation
|
|
315
|
-
|
|
316
|
-
5 tabs with badge counters:
|
|
317
|
-
- **Overview**: System summary
|
|
318
|
-
- **Recent Requests**: Last 50 RPC calls
|
|
319
|
-
- **Notifications**: Notification statistics
|
|
320
|
-
- **Methods**: Method-level stats
|
|
321
|
-
- **Testing**: Test tools (new!)
|
|
322
|
-
|
|
323
|
-
### Testing Tools Tab
|
|
324
|
-
|
|
325
|
-
Two sections:
|
|
326
|
-
1. **RPC Test Client** (top)
|
|
327
|
-
2. **Load Testing Tool** (bottom)
|
|
328
|
-
|
|
329
|
-
### Material Icons
|
|
330
|
-
|
|
331
|
-
Icons used:
|
|
332
|
-
- `send` - Send request
|
|
333
|
-
- `science` - Testing tools
|
|
334
|
-
- `speed` - Load testing
|
|
335
|
-
- `play_arrow` - Start test
|
|
336
|
-
- `stop` - Stop test
|
|
337
|
-
- `check_circle` - Success
|
|
338
|
-
- `error` - Failed
|
|
339
|
-
|
|
340
|
-
---
|
|
341
|
-
|
|
342
|
-
## 📝 JavaScript Integration
|
|
343
|
-
|
|
344
|
-
### API Client Usage
|
|
345
|
-
|
|
346
|
-
```javascript
|
|
347
|
-
// Import generated API client
|
|
348
|
-
import { api } from '/static/js/api/index.mjs';
|
|
349
|
-
|
|
350
|
-
// Send test RPC request
|
|
351
|
-
const result = await api.ipcTestSendCreate({
|
|
352
|
-
method: 'notification.send',
|
|
353
|
-
params: { user_id: '123' },
|
|
354
|
-
timeout: 10
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
// Start load test
|
|
358
|
-
const test = await api.ipcTestLoadStartCreate({
|
|
359
|
-
method: 'notification.send',
|
|
360
|
-
total_requests: 100,
|
|
361
|
-
concurrency: 10,
|
|
362
|
-
params: {}
|
|
363
|
-
});
|
|
364
|
-
|
|
365
|
-
// Poll status
|
|
366
|
-
setInterval(async () => {
|
|
367
|
-
const status = await api.ipcTestLoadStatusRetrieve();
|
|
368
|
-
updateUI(status);
|
|
369
|
-
}, 500);
|
|
370
|
-
|
|
371
|
-
// Stop test
|
|
372
|
-
await api.ipcTestLoadStopCreate();
|
|
373
|
-
```
|
|
374
|
-
|
|
375
|
-
### Event Handlers
|
|
376
|
-
|
|
377
|
-
```javascript
|
|
378
|
-
// Send Test Request
|
|
379
|
-
document.getElementById('send-test-rpc').addEventListener('click', async () => {
|
|
380
|
-
const method = document.getElementById('test-method').value;
|
|
381
|
-
const params = JSON.parse(document.getElementById('test-params').value);
|
|
382
|
-
const timeout = parseInt(document.getElementById('test-timeout').value);
|
|
383
|
-
|
|
384
|
-
const result = await api.ipcTestSendCreate({ method, params, timeout });
|
|
385
|
-
|
|
386
|
-
displayResult(result);
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
// Start Load Test
|
|
390
|
-
document.getElementById('start-load-test').addEventListener('click', async () => {
|
|
391
|
-
const method = document.getElementById('load-method').value;
|
|
392
|
-
const total_requests = parseInt(document.getElementById('load-total-requests').value);
|
|
393
|
-
const concurrency = parseInt(document.getElementById('load-concurrency').value);
|
|
394
|
-
|
|
395
|
-
await api.ipcTestLoadStartCreate({
|
|
396
|
-
method,
|
|
397
|
-
total_requests,
|
|
398
|
-
concurrency,
|
|
399
|
-
params: {}
|
|
400
|
-
});
|
|
401
|
-
|
|
402
|
-
startPolling();
|
|
403
|
-
});
|
|
404
|
-
```
|
|
405
|
-
|
|
406
|
-
---
|
|
407
|
-
|
|
408
|
-
## 🚀 Best Practices
|
|
409
|
-
|
|
410
|
-
### 1. Start Small
|
|
411
|
-
|
|
412
|
-
Begin with:
|
|
413
|
-
- 10 total requests
|
|
414
|
-
- 2-5 concurrency
|
|
415
|
-
- Simple methods (e.g., `notification.send`)
|
|
416
|
-
|
|
417
|
-
Gradually increase load.
|
|
418
|
-
|
|
419
|
-
### 2. Monitor System Resources
|
|
420
|
-
|
|
421
|
-
Watch for:
|
|
422
|
-
- Redis memory usage
|
|
423
|
-
- WebSocket server CPU
|
|
424
|
-
- Django process count
|
|
425
|
-
- Network bandwidth
|
|
426
|
-
|
|
427
|
-
Use `htop`, `redis-cli INFO`, Docker stats.
|
|
428
|
-
|
|
429
|
-
### 3. Test in Isolation
|
|
430
|
-
|
|
431
|
-
Avoid load testing in production during:
|
|
432
|
-
- Peak traffic hours
|
|
433
|
-
- Active user sessions
|
|
434
|
-
- Critical operations
|
|
435
|
-
|
|
436
|
-
### 4. Analyze Results
|
|
437
|
-
|
|
438
|
-
After each test:
|
|
439
|
-
1. Review RPC logs in admin
|
|
440
|
-
2. Check error messages
|
|
441
|
-
3. Identify bottlenecks
|
|
442
|
-
4. Optimize slow methods
|
|
443
|
-
|
|
444
|
-
### 5. Cleanup
|
|
445
|
-
|
|
446
|
-
After testing:
|
|
447
|
-
```python
|
|
448
|
-
# Delete test logs
|
|
449
|
-
RPCLog.objects.filter(params___test_id__isnull=False).delete()
|
|
450
|
-
|
|
451
|
-
# Clear Redis stream (optional)
|
|
452
|
-
# WARNING: Deletes all pending requests!
|
|
453
|
-
```
|
|
454
|
-
|
|
455
|
-
---
|
|
456
|
-
|
|
457
|
-
## 🐛 Troubleshooting
|
|
458
|
-
|
|
459
|
-
### Load Test Not Starting
|
|
460
|
-
|
|
461
|
-
**Symptoms**: 409 Conflict error
|
|
462
|
-
|
|
463
|
-
**Cause**: Previous test still running
|
|
464
|
-
|
|
465
|
-
**Fix**:
|
|
466
|
-
```http
|
|
467
|
-
POST /cfg/ipc/test/load/stop
|
|
468
|
-
```
|
|
469
|
-
|
|
470
|
-
### Timeout Errors
|
|
471
|
-
|
|
472
|
-
**Symptoms**: All requests timeout
|
|
473
|
-
|
|
474
|
-
**Causes**:
|
|
475
|
-
- WebSocket server not running
|
|
476
|
-
- Redis connection issues
|
|
477
|
-
- Network problems
|
|
478
|
-
|
|
479
|
-
**Fix**:
|
|
480
|
-
1. Check WebSocket server logs
|
|
481
|
-
2. Verify Redis connectivity
|
|
482
|
-
3. Test with single request first
|
|
483
|
-
|
|
484
|
-
### High Failure Rate
|
|
485
|
-
|
|
486
|
-
**Symptoms**: >50% failed requests
|
|
487
|
-
|
|
488
|
-
**Causes**:
|
|
489
|
-
- Method not implemented
|
|
490
|
-
- Invalid parameters
|
|
491
|
-
- Server overload
|
|
492
|
-
|
|
493
|
-
**Fix**:
|
|
494
|
-
1. Test method with single request
|
|
495
|
-
2. Validate parameter schema
|
|
496
|
-
3. Reduce concurrency
|
|
497
|
-
|
|
498
|
-
---
|
|
499
|
-
|
|
500
|
-
## 📚 Reference
|
|
501
|
-
|
|
502
|
-
### Available RPC Methods
|
|
503
|
-
|
|
504
|
-
| Method | Purpose | Avg Duration |
|
|
505
|
-
|--------|---------|--------------|
|
|
506
|
-
| `notification.send` | Send notification to user | 20-50ms |
|
|
507
|
-
| `notification.broadcast` | Broadcast to all users | 30-80ms |
|
|
508
|
-
| `workspace.file_changed` | Notify file change | 15-40ms |
|
|
509
|
-
| `session.message` | Send session message | 20-45ms |
|
|
510
|
-
|
|
511
|
-
### HTTP Status Codes
|
|
512
|
-
|
|
513
|
-
| Code | Meaning | Action |
|
|
514
|
-
|------|---------|--------|
|
|
515
|
-
| 200 | Success | Request processed |
|
|
516
|
-
| 400 | Bad Request | Check parameters |
|
|
517
|
-
| 409 | Conflict | Stop existing test |
|
|
518
|
-
| 500 | Server Error | Check server logs |
|
|
519
|
-
| 503 | Service Unavailable | Check Redis/WebSocket |
|
|
520
|
-
|
|
521
|
-
---
|
|
522
|
-
|
|
523
|
-
## 🔮 Future Enhancements
|
|
524
|
-
|
|
525
|
-
Planned features:
|
|
526
|
-
- [ ] Test result history
|
|
527
|
-
- [ ] Export test reports (CSV/JSON)
|
|
528
|
-
- [ ] Custom parameter templates
|
|
529
|
-
- [ ] Scheduled load tests
|
|
530
|
-
- [ ] Performance regression alerts
|
|
531
|
-
- [ ] WebSocket connection testing
|
|
532
|
-
- [ ] Stress testing mode (max load)
|
|
533
|
-
|
|
534
|
-
---
|
|
535
|
-
|
|
536
|
-
**Status**: ✅ Production Ready
|
|
537
|
-
**Django-CFG Version**: 2.0+
|
|
538
|
-
**Python Version**: 3.10+
|
|
539
|
-
**Last Updated**: 2025-10-23
|
django_cfg/apps/ipc/__init__.py
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Django-CFG IPC/RPC Module.
|
|
3
|
-
|
|
4
|
-
Lightweight synchronous RPC client for Django applications to communicate
|
|
5
|
-
with django-cfg-rpc WebSocket servers via Redis.
|
|
6
|
-
|
|
7
|
-
Key Features:
|
|
8
|
-
- ✅ 100% synchronous (no async/await in Django)
|
|
9
|
-
- ✅ Type-safe with Pydantic 2 models from django-cfg-rpc
|
|
10
|
-
- ✅ Automatic connection pooling
|
|
11
|
-
- ✅ Optional dependency on django-cfg-rpc
|
|
12
|
-
- ✅ Graceful fallback if django-cfg-rpc not installed
|
|
13
|
-
- ✅ Automatic RPC logging to database
|
|
14
|
-
- ✅ Beautiful admin interface with Unfold
|
|
15
|
-
|
|
16
|
-
Example:
|
|
17
|
-
>>> from django_cfg.apps.ipc import get_rpc_client
|
|
18
|
-
>>> from django_ipc.models import NotificationRequest, NotificationResponse
|
|
19
|
-
>>>
|
|
20
|
-
>>> rpc = get_rpc_client()
|
|
21
|
-
>>> result: NotificationResponse = rpc.call(
|
|
22
|
-
... method="send_notification",
|
|
23
|
-
... params=NotificationRequest(
|
|
24
|
-
... user_id="123",
|
|
25
|
-
... type="order_update",
|
|
26
|
-
... title="Order Confirmed",
|
|
27
|
-
... message="Your order has been confirmed"
|
|
28
|
-
... ),
|
|
29
|
-
... result_model=NotificationResponse,
|
|
30
|
-
... user=request.user # For logging
|
|
31
|
-
... )
|
|
32
|
-
"""
|
|
33
|
-
|
|
34
|
-
from .services.client.client import DjangoCfgRPCClient, get_rpc_client
|
|
35
|
-
from .services.client.config import DjangoCfgRPCConfig
|
|
36
|
-
from .services.client.exceptions import (
|
|
37
|
-
RPCConfigurationError,
|
|
38
|
-
RPCConnectionError,
|
|
39
|
-
RPCRemoteError,
|
|
40
|
-
RPCTimeoutError,
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
# Logging utilities
|
|
44
|
-
from .services.logging import RPCLogger, RPCLogContext
|
|
45
|
-
|
|
46
|
-
__all__ = [
|
|
47
|
-
# Client
|
|
48
|
-
"DjangoCfgRPCClient",
|
|
49
|
-
"get_rpc_client",
|
|
50
|
-
# Configuration
|
|
51
|
-
"DjangoCfgRPCConfig",
|
|
52
|
-
# Exceptions
|
|
53
|
-
"RPCTimeoutError",
|
|
54
|
-
"RPCRemoteError",
|
|
55
|
-
"RPCConnectionError",
|
|
56
|
-
"RPCConfigurationError",
|
|
57
|
-
# Logging
|
|
58
|
-
"RPCLogger",
|
|
59
|
-
"RPCLogContext",
|
|
60
|
-
]
|