django-cfg 1.4.0__py3-none-any.whl → 1.4.4__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.
- django_cfg/__init__.py +1 -1
- django_cfg/apps/agents/examples/__init__.py +3 -0
- django_cfg/apps/agents/examples/simple_example.py +161 -0
- django_cfg/apps/knowbase/examples/__init__.py +3 -0
- django_cfg/apps/knowbase/examples/external_data_usage.py +191 -0
- django_cfg/apps/knowbase/mixins/examples/vehicle_model_example.py +199 -0
- django_cfg/apps/urls.py +1 -1
- django_cfg/core/base/config_model.py +2 -2
- django_cfg/core/builders/apps_builder.py +2 -2
- django_cfg/core/generation/integration_generators/third_party.py +3 -3
- django_cfg/modules/base.py +1 -1
- django_cfg/modules/django_currency/examples/__init__.py +3 -0
- django_cfg/modules/django_currency/examples/example_database_usage.py +144 -0
- django_cfg/modules/{django_cfg_rpc_client → django_ipc_client}/README.md +20 -20
- django_cfg/modules/{django_cfg_rpc_client → django_ipc_client}/__init__.py +2 -2
- django_cfg/modules/{django_cfg_rpc_client → django_ipc_client}/client.py +5 -5
- django_cfg/modules/{django_cfg_rpc_client → django_ipc_client}/config.py +3 -3
- django_cfg/modules/{django_cfg_rpc_client → django_ipc_client}/dashboard/README.md +12 -12
- django_cfg/modules/{django_cfg_rpc_client → django_ipc_client}/dashboard/__init__.py +1 -1
- django_cfg/modules/{django_cfg_rpc_client → django_ipc_client}/dashboard/apps.py +4 -4
- django_cfg/modules/{django_cfg_rpc_client/dashboard/templates/django_cfg_rpc_dashboard → django_ipc_client/dashboard/templates/django_ipc_dashboard}/base.html +1 -1
- django_cfg/modules/{django_cfg_rpc_client/dashboard/templates/django_cfg_rpc_dashboard → django_ipc_client/dashboard/templates/django_ipc_dashboard}/dashboard.html +2 -2
- django_cfg/modules/{django_cfg_rpc_client → django_ipc_client}/dashboard/urls.py +1 -1
- django_cfg/modules/{django_cfg_rpc_client → django_ipc_client}/dashboard/urls_admin.py +1 -1
- django_cfg/modules/{django_cfg_rpc_client → django_ipc_client}/dashboard/views.py +2 -2
- django_cfg/modules/{django_cfg_rpc_client → django_ipc_client}/exceptions.py +1 -1
- django_cfg/registry/modules.py +1 -1
- django_cfg/templates/admin/examples/component_class_example.html +156 -0
- django_cfg-1.4.4.dist-info/METADATA +533 -0
- {django_cfg-1.4.0.dist-info → django_cfg-1.4.4.dist-info}/RECORD +36 -28
- django_cfg-1.4.0.dist-info/METADATA +0 -920
- /django_cfg/modules/{django_cfg_rpc_client → django_ipc_client}/dashboard/UNFOLD_INTEGRATION.md +0 -0
- /django_cfg/modules/{django_cfg_rpc_client → django_ipc_client}/dashboard/monitor.py +0 -0
- /django_cfg/modules/{django_cfg_rpc_client/dashboard/static/django_cfg_rpc_dashboard → django_ipc_client/dashboard/static/django_ipc_dashboard}/js/dashboard.js +0 -0
- {django_cfg-1.4.0.dist-info → django_cfg-1.4.4.dist-info}/WHEEL +0 -0
- {django_cfg-1.4.0.dist-info → django_cfg-1.4.4.dist-info}/entry_points.txt +0 -0
- {django_cfg-1.4.0.dist-info → django_cfg-1.4.4.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,144 @@
|
|
1
|
+
"""
|
2
|
+
Example usage of the database loader for populating currency data.
|
3
|
+
"""
|
4
|
+
|
5
|
+
import logging
|
6
|
+
from .database_loader import (
|
7
|
+
CurrencyDatabaseLoader,
|
8
|
+
DatabaseLoaderConfig,
|
9
|
+
create_database_loader,
|
10
|
+
load_currencies_to_database_format
|
11
|
+
)
|
12
|
+
|
13
|
+
# Configure logging
|
14
|
+
logging.basicConfig(level=logging.INFO, format='%(name)s:%(levelname)s: %(message)s')
|
15
|
+
|
16
|
+
|
17
|
+
def example_basic_usage():
|
18
|
+
"""Basic example of using the database loader."""
|
19
|
+
print("🔄 Creating database loader...")
|
20
|
+
|
21
|
+
# Create loader with default settings
|
22
|
+
loader = create_database_loader(
|
23
|
+
max_cryptocurrencies=100, # Limit to top 100 cryptos
|
24
|
+
max_fiat_currencies=30, # Top 30 fiat currencies
|
25
|
+
min_market_cap_usd=10_000_000, # 10M USD minimum
|
26
|
+
coingecko_delay=2.0 # 2 second delay between requests
|
27
|
+
)
|
28
|
+
|
29
|
+
# Get statistics
|
30
|
+
print("📊 Statistics:")
|
31
|
+
stats = loader.get_statistics()
|
32
|
+
for key, value in stats.items():
|
33
|
+
print(f" {key}: {value}")
|
34
|
+
|
35
|
+
print("\n🪙 Building currency database data...")
|
36
|
+
|
37
|
+
# Build complete currency data
|
38
|
+
currencies = loader.build_currency_database_data()
|
39
|
+
|
40
|
+
print(f"\n✅ Successfully loaded {len(currencies)} currencies")
|
41
|
+
|
42
|
+
# Show sample data
|
43
|
+
print("\n📋 Sample currencies:")
|
44
|
+
for i, currency in enumerate(currencies[:10]):
|
45
|
+
print(f" {i+1}. {currency.code} ({currency.currency_type}): "
|
46
|
+
f"{currency.name} = ${currency.usd_rate:.6f}")
|
47
|
+
|
48
|
+
return currencies
|
49
|
+
|
50
|
+
|
51
|
+
def example_django_integration():
|
52
|
+
"""Example of how to integrate with Django ORM."""
|
53
|
+
print("🔄 Loading currencies in Django format...")
|
54
|
+
|
55
|
+
# Get currencies in Django-ready format
|
56
|
+
currency_dicts = load_currencies_to_database_format()
|
57
|
+
|
58
|
+
print(f"✅ Ready to insert {len(currency_dicts)} currencies into Django ORM")
|
59
|
+
|
60
|
+
# This is how you would use it in Django:
|
61
|
+
print("\n💡 Django integration example:")
|
62
|
+
print("""
|
63
|
+
# In your Django management command or view:
|
64
|
+
from django_cfg.modules.django_currency.database_loader import load_currencies_to_database_format
|
65
|
+
from django_cfg.apps.payments.models import Currency
|
66
|
+
|
67
|
+
# Load currency data
|
68
|
+
currency_data = load_currencies_to_database_format()
|
69
|
+
|
70
|
+
# Bulk create currencies
|
71
|
+
currencies_to_create = []
|
72
|
+
for data in currency_data:
|
73
|
+
currency = Currency(**data)
|
74
|
+
currencies_to_create.append(currency)
|
75
|
+
|
76
|
+
# Insert into database
|
77
|
+
Currency.objects.bulk_create(currencies_to_create, ignore_conflicts=True)
|
78
|
+
print(f"Inserted {len(currencies_to_create)} currencies")
|
79
|
+
""")
|
80
|
+
|
81
|
+
return currency_dicts
|
82
|
+
|
83
|
+
|
84
|
+
def example_advanced_config():
|
85
|
+
"""Example with advanced configuration."""
|
86
|
+
print("🔧 Advanced configuration example...")
|
87
|
+
|
88
|
+
# Custom configuration
|
89
|
+
config = DatabaseLoaderConfig(
|
90
|
+
# Rate limiting
|
91
|
+
coingecko_delay=3.0, # Slower requests for stability
|
92
|
+
yfinance_delay=1.0,
|
93
|
+
max_requests_per_minute=20, # Conservative rate limit
|
94
|
+
|
95
|
+
# Limits
|
96
|
+
max_cryptocurrencies=50, # Smaller set
|
97
|
+
max_fiat_currencies=20,
|
98
|
+
|
99
|
+
# Filtering
|
100
|
+
min_market_cap_usd=50_000_000, # Higher threshold - 50M USD
|
101
|
+
exclude_stablecoins=True, # Skip stablecoins
|
102
|
+
|
103
|
+
# Cache
|
104
|
+
cache_ttl_hours=12 # Cache for 12 hours
|
105
|
+
)
|
106
|
+
|
107
|
+
loader = CurrencyDatabaseLoader(config)
|
108
|
+
|
109
|
+
print(f"📊 Configuration:")
|
110
|
+
print(f" Max cryptocurrencies: {config.max_cryptocurrencies}")
|
111
|
+
print(f" Min market cap: ${config.min_market_cap_usd:,.0f}")
|
112
|
+
print(f" Exclude stablecoins: {config.exclude_stablecoins}")
|
113
|
+
print(f" CoinGecko delay: {config.coingecko_delay}s")
|
114
|
+
|
115
|
+
return loader
|
116
|
+
|
117
|
+
|
118
|
+
if __name__ == "__main__":
|
119
|
+
print("🧪 CURRENCY DATABASE LOADER EXAMPLES")
|
120
|
+
print("=" * 50)
|
121
|
+
|
122
|
+
try:
|
123
|
+
# Basic usage
|
124
|
+
print("\n1️⃣ BASIC USAGE:")
|
125
|
+
currencies = example_basic_usage()
|
126
|
+
|
127
|
+
print("\n" + "=" * 50)
|
128
|
+
|
129
|
+
# Django integration
|
130
|
+
print("\n2️⃣ DJANGO INTEGRATION:")
|
131
|
+
django_data = example_django_integration()
|
132
|
+
|
133
|
+
print("\n" + "=" * 50)
|
134
|
+
|
135
|
+
# Advanced config
|
136
|
+
print("\n3️⃣ ADVANCED CONFIGURATION:")
|
137
|
+
advanced_loader = example_advanced_config()
|
138
|
+
|
139
|
+
print("\n🎉 All examples completed successfully!")
|
140
|
+
|
141
|
+
except Exception as e:
|
142
|
+
print(f"❌ Error: {e}")
|
143
|
+
import traceback
|
144
|
+
traceback.print_exc()
|
@@ -1,14 +1,14 @@
|
|
1
1
|
# Django-CFG RPC Client 📡
|
2
2
|
|
3
|
-
Lightweight synchronous RPC client for Django applications to communicate with **django-
|
3
|
+
Lightweight synchronous RPC client for Django applications to communicate with **django-ipc** WebSocket servers via Redis.
|
4
4
|
|
5
5
|
**NEW**: ✨ Built-in RPC Dashboard for real-time monitoring! See [Dashboard README](./dashboard/README.md)
|
6
6
|
|
7
7
|
## 🎯 Key Features
|
8
8
|
|
9
9
|
- ✅ **100% Synchronous** - No async/await in Django, works with WSGI
|
10
|
-
- ✅ **Type-Safe** - Full Pydantic 2 support when django-
|
11
|
-
- ✅ **Optional Dependency** - Works without django-
|
10
|
+
- ✅ **Type-Safe** - Full Pydantic 2 support when django-ipc installed
|
11
|
+
- ✅ **Optional Dependency** - Works without django-ipc (dict-based fallback)
|
12
12
|
- ✅ **Redis IPC** - Reliable communication via Streams + Lists
|
13
13
|
- ✅ **Connection Pooling** - Automatic Redis connection management
|
14
14
|
- ✅ **Singleton Pattern** - Single client instance across Django app
|
@@ -17,10 +17,10 @@ Lightweight synchronous RPC client for Django applications to communicate with *
|
|
17
17
|
|
18
18
|
## 📦 Installation
|
19
19
|
|
20
|
-
### Option 1: With django-
|
20
|
+
### Option 1: With django-ipc (Recommended)
|
21
21
|
|
22
22
|
```bash
|
23
|
-
pip install django-cfg django-
|
23
|
+
pip install django-cfg django-ipc
|
24
24
|
```
|
25
25
|
|
26
26
|
### Option 2: Standalone (Basic)
|
@@ -38,13 +38,13 @@ pip install django-cfg redis
|
|
38
38
|
```python
|
39
39
|
# config.py
|
40
40
|
from django_cfg import DjangoConfig
|
41
|
-
from django_cfg.modules.
|
41
|
+
from django_cfg.modules.django_ipc_client.config import DjangoCfgRPCConfig
|
42
42
|
|
43
43
|
class MyProjectConfig(DjangoConfig):
|
44
44
|
project_name = "My Project"
|
45
45
|
|
46
46
|
# RPC Client Configuration
|
47
|
-
|
47
|
+
django_ipc = DjangoCfgRPCConfig(
|
48
48
|
enabled=True,
|
49
49
|
redis_url="redis://localhost:6379/2",
|
50
50
|
rpc_timeout=30,
|
@@ -78,12 +78,12 @@ DJANGO_CFG_RPC__RPC_TIMEOUT=30
|
|
78
78
|
|
79
79
|
## 🚀 Usage
|
80
80
|
|
81
|
-
### With django-
|
81
|
+
### With django-ipc Models (Type-Safe)
|
82
82
|
|
83
83
|
```python
|
84
84
|
# views.py
|
85
|
-
from django_cfg.modules.
|
86
|
-
from
|
85
|
+
from django_cfg.modules.django_ipc_client import get_rpc_client
|
86
|
+
from django_ipc.models import NotificationRequest, NotificationResponse
|
87
87
|
|
88
88
|
rpc = get_rpc_client()
|
89
89
|
|
@@ -109,10 +109,10 @@ def notify_user(request, user_id):
|
|
109
109
|
})
|
110
110
|
```
|
111
111
|
|
112
|
-
### Without django-
|
112
|
+
### Without django-ipc (Dict-Based)
|
113
113
|
|
114
114
|
```python
|
115
|
-
from django_cfg.modules.
|
115
|
+
from django_cfg.modules.django_ipc_client import get_rpc_client
|
116
116
|
|
117
117
|
rpc = get_rpc_client()
|
118
118
|
|
@@ -224,7 +224,7 @@ Check if RPC system is healthy.
|
|
224
224
|
### Timeout Handling
|
225
225
|
|
226
226
|
```python
|
227
|
-
from django_cfg.modules.
|
227
|
+
from django_cfg.modules.django_ipc_client import get_rpc_client, RPCTimeoutError
|
228
228
|
|
229
229
|
rpc = get_rpc_client()
|
230
230
|
|
@@ -238,7 +238,7 @@ except RPCTimeoutError as e:
|
|
238
238
|
### Remote Error Handling
|
239
239
|
|
240
240
|
```python
|
241
|
-
from django_cfg.modules.
|
241
|
+
from django_cfg.modules.django_ipc_client import RPCRemoteError
|
242
242
|
|
243
243
|
try:
|
244
244
|
result = rpc.call(method="...", params={...})
|
@@ -263,7 +263,7 @@ except RPCRemoteError as e:
|
|
263
263
|
┌─────────────────────────────────────────────┐
|
264
264
|
│ Django Application (WSGI/Sync) │
|
265
265
|
│ ┌───────────────────────────────────────┐ │
|
266
|
-
│ │
|
266
|
+
│ │ django_ipc_client │ │
|
267
267
|
│ │ - DjangoCfgRPCClient (sync) │ │
|
268
268
|
│ │ - Redis Streams (requests) │ │
|
269
269
|
│ │ - Redis Lists (responses) │ │
|
@@ -274,7 +274,7 @@ except RPCRemoteError as e:
|
|
274
274
|
│ (stream:requests → list:response:{cid})
|
275
275
|
▼
|
276
276
|
┌─────────────────────────────────────────────┐
|
277
|
-
│ django-
|
277
|
+
│ django-ipc Server (Async) │
|
278
278
|
│ - WebSocket Server │
|
279
279
|
│ - Connection Manager │
|
280
280
|
│ - RPC Handlers │
|
@@ -286,7 +286,7 @@ except RPCRemoteError as e:
|
|
286
286
|
|
287
287
|
## 🔗 Related
|
288
288
|
|
289
|
-
- **django-
|
289
|
+
- **django-ipc** - WebSocket RPC server package
|
290
290
|
- **Old Module** - `django_rpc_old` (deprecated, kept for reference)
|
291
291
|
|
292
292
|
---
|
@@ -298,12 +298,12 @@ except RPCRemoteError as e:
|
|
298
298
|
from django_cfg.modules.django_rpc import get_rpc_client
|
299
299
|
|
300
300
|
# New (current)
|
301
|
-
from django_cfg.modules.
|
301
|
+
from django_cfg.modules.django_ipc_client import get_rpc_client
|
302
302
|
```
|
303
303
|
|
304
304
|
API remains mostly compatible. Main changes:
|
305
305
|
- Configuration key: `WEBSOCKET_RPC` → `DJANGO_CFG_RPC`
|
306
|
-
- Models now live in `django-
|
306
|
+
- Models now live in `django-ipc` package (optional dependency)
|
307
307
|
- Better error handling with specific exception types
|
308
308
|
|
309
309
|
---
|
@@ -327,7 +327,7 @@ from django.urls import path, include
|
|
327
327
|
|
328
328
|
urlpatterns = [
|
329
329
|
# ... other URLs
|
330
|
-
path('admin/rpc/', include('django_cfg.modules.
|
330
|
+
path('admin/rpc/', include('django_cfg.modules.django_ipc_client.dashboard.urls')),
|
331
331
|
]
|
332
332
|
```
|
333
333
|
|
@@ -12,8 +12,8 @@ Key Features:
|
|
12
12
|
- ✅ Graceful fallback if django-cfg-rpc not installed
|
13
13
|
|
14
14
|
Example:
|
15
|
-
>>> from django_cfg.modules.
|
16
|
-
>>> from
|
15
|
+
>>> from django_cfg.modules.django_ipc_client import get_rpc_client
|
16
|
+
>>> from django_ipc.models import NotificationRequest, NotificationResponse
|
17
17
|
>>>
|
18
18
|
>>> rpc = get_rpc_client()
|
19
19
|
>>> result: NotificationResponse = rpc.call(
|
@@ -56,10 +56,10 @@ class DjangoCfgRPCClient:
|
|
56
56
|
- Automatic cleanup of ephemeral keys
|
57
57
|
|
58
58
|
Example:
|
59
|
-
>>> from django_cfg.modules.
|
59
|
+
>>> from django_cfg.modules.django_ipc_client import get_rpc_client
|
60
60
|
>>>
|
61
61
|
>>> # With django-cfg-rpc models
|
62
|
-
>>> from
|
62
|
+
>>> from django_ipc.models import NotificationRequest, NotificationResponse
|
63
63
|
>>> rpc = get_rpc_client()
|
64
64
|
>>> result: NotificationResponse = rpc.call(
|
65
65
|
... method="send_notification",
|
@@ -196,7 +196,7 @@ class DjangoCfgRPCClient:
|
|
196
196
|
ValidationError: If response doesn't match result_model
|
197
197
|
|
198
198
|
Example:
|
199
|
-
>>> from
|
199
|
+
>>> from django_ipc.models import NotificationRequest, NotificationResponse
|
200
200
|
>>> result = rpc.call(
|
201
201
|
... method="send_notification",
|
202
202
|
... params=NotificationRequest(user_id="123", type="info",
|
@@ -428,7 +428,7 @@ class DjangoCfgRPCClient:
|
|
428
428
|
"request_stream": self.request_stream,
|
429
429
|
"consumer_group": self.consumer_group,
|
430
430
|
"default_timeout": self.default_timeout,
|
431
|
-
"
|
431
|
+
"has_django_ipc": HAS_DJANGO_CFG_RPC,
|
432
432
|
}
|
433
433
|
|
434
434
|
def close(self):
|
@@ -473,7 +473,7 @@ def get_rpc_client(force_new: bool = False) -> DjangoCfgRPCClient:
|
|
473
473
|
DjangoCfgRPCClient instance
|
474
474
|
|
475
475
|
Example:
|
476
|
-
>>> from django_cfg.modules.
|
476
|
+
>>> from django_cfg.modules.django_ipc_client import get_rpc_client
|
477
477
|
>>> rpc = get_rpc_client()
|
478
478
|
>>> result = rpc.call(...)
|
479
479
|
"""
|
@@ -17,10 +17,10 @@ class DjangoCfgRPCConfig(BaseModel):
|
|
17
17
|
|
18
18
|
Example:
|
19
19
|
>>> from django_cfg import DjangoConfig
|
20
|
-
>>> from django_cfg.modules.
|
20
|
+
>>> from django_cfg.modules.django_ipc_client import DjangoCfgRPCConfig
|
21
21
|
>>>
|
22
22
|
>>> config = DjangoConfig(
|
23
|
-
...
|
23
|
+
... django_ipc=DjangoCfgRPCConfig(
|
24
24
|
... enabled=True,
|
25
25
|
... redis_url="redis://localhost:6379/2",
|
26
26
|
... rpc_timeout=30
|
@@ -30,7 +30,7 @@ class DjangoCfgRPCConfig(BaseModel):
|
|
30
30
|
|
31
31
|
# Module metadata
|
32
32
|
module_name: str = Field(
|
33
|
-
default="
|
33
|
+
default="django_ipc_client",
|
34
34
|
frozen=True,
|
35
35
|
description="Module name for django-cfg integration",
|
36
36
|
)
|
@@ -31,11 +31,11 @@ Simply enable RPC in your django-cfg configuration:
|
|
31
31
|
```python
|
32
32
|
# config.py
|
33
33
|
from django_cfg import DjangoConfig
|
34
|
-
from django_cfg.modules.
|
34
|
+
from django_cfg.modules.django_ipc_client.config import DjangoCfgRPCConfig
|
35
35
|
|
36
36
|
class MyProjectConfig(DjangoConfig):
|
37
37
|
# Enable RPC Client
|
38
|
-
|
38
|
+
django_ipc = DjangoCfgRPCConfig(
|
39
39
|
enabled=True,
|
40
40
|
redis_url="redis://localhost:6379/2",
|
41
41
|
)
|
@@ -67,7 +67,7 @@ from django.urls import path, include
|
|
67
67
|
|
68
68
|
urlpatterns = [
|
69
69
|
# RPC Dashboard (requires staff login)
|
70
|
-
path('admin/rpc/', include('django_cfg.modules.
|
70
|
+
path('admin/rpc/', include('django_cfg.modules.django_ipc_client.dashboard.urls')),
|
71
71
|
]
|
72
72
|
```
|
73
73
|
|
@@ -129,7 +129,7 @@ Mount at custom path:
|
|
129
129
|
|
130
130
|
```python
|
131
131
|
urlpatterns = [
|
132
|
-
path('my/custom/path/', include('django_cfg.modules.
|
132
|
+
path('my/custom/path/', include('django_cfg.modules.django_ipc_client.dashboard.urls')),
|
133
133
|
]
|
134
134
|
```
|
135
135
|
|
@@ -141,13 +141,13 @@ urlpatterns = [
|
|
141
141
|
|
142
142
|
```bash
|
143
143
|
# Run all dashboard tests
|
144
|
-
pytest django_cfg/modules/
|
144
|
+
pytest django_cfg/modules/django_ipc_client/tests/
|
145
145
|
|
146
146
|
# Run monitor tests
|
147
|
-
pytest django_cfg/modules/
|
147
|
+
pytest django_cfg/modules/django_ipc_client/tests/test_monitor.py -v
|
148
148
|
|
149
149
|
# Run view tests
|
150
|
-
pytest django_cfg/modules/
|
150
|
+
pytest django_cfg/modules/django_ipc_client/tests/test_dashboard.py -v
|
151
151
|
```
|
152
152
|
|
153
153
|
### Test Coverage
|
@@ -189,11 +189,11 @@ dashboard/
|
|
189
189
|
├── views.py # Django views + JSON API
|
190
190
|
├── urls.py # URL routing
|
191
191
|
├── templates/ # Tailwind CSS templates
|
192
|
-
│ └──
|
192
|
+
│ └── django_ipc_dashboard/
|
193
193
|
│ ├── base.html
|
194
194
|
│ └── dashboard.html
|
195
195
|
└── static/ # JavaScript
|
196
|
-
└──
|
196
|
+
└── django_ipc_dashboard/
|
197
197
|
└── js/
|
198
198
|
└── dashboard.js
|
199
199
|
```
|
@@ -367,7 +367,7 @@ Find slow RPC methods:
|
|
367
367
|
|
368
368
|
## ✅ Summary
|
369
369
|
|
370
|
-
- **Location**: `django_cfg/modules/
|
370
|
+
- **Location**: `django_cfg/modules/django_ipc_client/dashboard/`
|
371
371
|
- **URL**: `/admin/rpc/` (customizable)
|
372
372
|
- **Requirements**: Staff login, Redis DB 2
|
373
373
|
- **Tech Stack**: Django, Tailwind CSS, Vanilla JS
|
@@ -445,7 +445,7 @@ redis-cli -n 2 XTRIM stream:requests MAXLEN 10000
|
|
445
445
|
# settings.py - Enhanced logging
|
446
446
|
LOGGING = {
|
447
447
|
'loggers': {
|
448
|
-
'django_cfg.modules.
|
448
|
+
'django_cfg.modules.django_ipc_client.dashboard': {
|
449
449
|
'level': 'INFO',
|
450
450
|
'handlers': ['file', 'sentry'], # Add Sentry for production
|
451
451
|
},
|
@@ -454,7 +454,7 @@ LOGGING = {
|
|
454
454
|
```
|
455
455
|
|
456
456
|
### 7. Testing
|
457
|
-
- [ ] Run all tests: `pytest django_cfg/modules/
|
457
|
+
- [ ] Run all tests: `pytest django_cfg/modules/django_ipc_client/tests/`
|
458
458
|
- [ ] Load test API endpoints
|
459
459
|
- [ ] Verify dashboard loads with production data
|
460
460
|
- [ ] Test with Redis connection failures
|
@@ -4,7 +4,7 @@ RPC Dashboard for django-cfg-rpc-client.
|
|
4
4
|
Provides real-time monitoring and visualization of RPC activity.
|
5
5
|
"""
|
6
6
|
|
7
|
-
default_app_config = 'django_cfg.modules.
|
7
|
+
default_app_config = 'django_cfg.modules.django_ipc_client.dashboard.apps.RPCDashboardConfig'
|
8
8
|
|
9
9
|
from .monitor import RPCMonitor
|
10
10
|
|
@@ -12,11 +12,11 @@ class RPCDashboardConfig(AppConfig):
|
|
12
12
|
RPC Dashboard application configuration.
|
13
13
|
|
14
14
|
Enables:
|
15
|
-
- Template discovery from templates/
|
16
|
-
- Static file discovery from static/
|
15
|
+
- Template discovery from templates/django_ipc_dashboard/
|
16
|
+
- Static file discovery from static/django_ipc_dashboard/
|
17
17
|
"""
|
18
18
|
|
19
19
|
default_auto_field = 'django.db.models.BigAutoField'
|
20
|
-
name = 'django_cfg.modules.
|
21
|
-
label = '
|
20
|
+
name = 'django_cfg.modules.django_ipc_client.dashboard'
|
21
|
+
label = 'django_ipc_dashboard'
|
22
22
|
verbose_name = 'Django-CFG RPC Dashboard'
|
@@ -71,6 +71,6 @@
|
|
71
71
|
<script>
|
72
72
|
// Set API base URL for dashboard.js
|
73
73
|
// Must run before dashboard.js initializes
|
74
|
-
document.body.setAttribute('data-api-base', "{% url '
|
74
|
+
document.body.setAttribute('data-api-base', "{% url 'django_ipc_dashboard:api_overview' %}/..");
|
75
75
|
</script>
|
76
76
|
{% endblock %}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
{% extends '
|
1
|
+
{% extends 'django_ipc_dashboard/base.html' %}
|
2
2
|
{% load static %}
|
3
3
|
|
4
4
|
{% block title %}Dashboard{% endblock %}
|
@@ -196,5 +196,5 @@
|
|
196
196
|
{% endblock %}
|
197
197
|
|
198
198
|
{% block extra_js %}
|
199
|
-
<script src="{% static '
|
199
|
+
<script src="{% static 'django_ipc_dashboard/js/dashboard.js' %}"></script>
|
200
200
|
{% endblock %}
|
@@ -40,7 +40,7 @@ def dashboard_view(request):
|
|
40
40
|
'rpc_nav_items': rpc_nav_items,
|
41
41
|
}
|
42
42
|
|
43
|
-
return render(request, '
|
43
|
+
return render(request, 'django_ipc_dashboard/dashboard.html', context)
|
44
44
|
|
45
45
|
except Exception as e:
|
46
46
|
logger.error(f"Dashboard view error: {e}", exc_info=True)
|
@@ -62,7 +62,7 @@ def dashboard_view(request):
|
|
62
62
|
'rpc_nav_items': rpc_nav_items,
|
63
63
|
}
|
64
64
|
|
65
|
-
return render(request, '
|
65
|
+
return render(request, 'django_ipc_dashboard/dashboard.html', context)
|
66
66
|
|
67
67
|
|
68
68
|
# === JSON API Endpoints ===
|
@@ -9,7 +9,7 @@ from typing import Optional, Any
|
|
9
9
|
|
10
10
|
# Try to import RPCError from django-cfg-rpc if available
|
11
11
|
try:
|
12
|
-
from
|
12
|
+
from django_ipc.models.errors import RPCError
|
13
13
|
HAS_DJANGO_CFG_RPC = True
|
14
14
|
except ImportError:
|
15
15
|
# Fallback: simple RPCError for basic error handling
|
django_cfg/registry/modules.py
CHANGED
@@ -11,7 +11,7 @@ MODULES_REGISTRY = {
|
|
11
11
|
"set_current_config": ("django_cfg.core.config", "set_current_config"),
|
12
12
|
|
13
13
|
# RPC Client module
|
14
|
-
"DjangoCfgRPCConfig": ("django_cfg.modules.
|
14
|
+
"DjangoCfgRPCConfig": ("django_cfg.modules.django_ipc_client.config", "DjangoCfgRPCConfig"),
|
15
15
|
|
16
16
|
# Import/Export integration (simple re-exports)
|
17
17
|
"ImportForm": ("django_cfg.modules.django_import_export", "ImportForm"),
|