queen-mq 0.1.0

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.
Files changed (90) hide show
  1. package/API.md +1116 -0
  2. package/CACHE.md +519 -0
  3. package/DASHBOARD-V3.md +478 -0
  4. package/DASHBOARD.md +382 -0
  5. package/MOD_QUEUE.md +453 -0
  6. package/PARTITION_LOCKING_DESIGN.md +989 -0
  7. package/PLAN.md +707 -0
  8. package/QUERY_ANALSYS.md +72 -0
  9. package/QUEUE_BUS.md +334 -0
  10. package/README.md +1495 -0
  11. package/V2-PLAN.md +236 -0
  12. package/assets/dashboard.png +0 -0
  13. package/dashboard/.vscode/extensions.json +3 -0
  14. package/dashboard/README.md +5 -0
  15. package/dashboard/index.html +14 -0
  16. package/dashboard/package-lock.json +1458 -0
  17. package/dashboard/package.json +25 -0
  18. package/dashboard/public/vite.svg +1 -0
  19. package/dashboard/src/App.vue +29 -0
  20. package/dashboard/src/assets/styles/main.css +908 -0
  21. package/dashboard/src/assets/vue.svg +1 -0
  22. package/dashboard/src/components/cards/MetricCard.vue +298 -0
  23. package/dashboard/src/components/charts/QueueDepthChart.vue +276 -0
  24. package/dashboard/src/components/charts/QueueLagChart.vue +436 -0
  25. package/dashboard/src/components/charts/ThroughputChart.vue +302 -0
  26. package/dashboard/src/components/common/ActivityFeed.vue +251 -0
  27. package/dashboard/src/components/layout/AppHeader.vue +208 -0
  28. package/dashboard/src/components/layout/AppLayout.vue +88 -0
  29. package/dashboard/src/components/layout/AppSidebar.vue +261 -0
  30. package/dashboard/src/main.js +44 -0
  31. package/dashboard/src/router.js +54 -0
  32. package/dashboard/src/services/api.js +187 -0
  33. package/dashboard/src/services/websocket.js +167 -0
  34. package/dashboard/src/utils/constants.js +56 -0
  35. package/dashboard/src/utils/helpers.js +118 -0
  36. package/dashboard/src/views/Analytics.vue +912 -0
  37. package/dashboard/src/views/Dashboard.vue +906 -0
  38. package/dashboard/src/views/Messages.vue +437 -0
  39. package/dashboard/src/views/QueueDetail.vue +501 -0
  40. package/dashboard/src/views/Queues.vue +333 -0
  41. package/dashboard/vite.config.js +30 -0
  42. package/debug-namespace.js +110 -0
  43. package/docs/long-polling.md +159 -0
  44. package/docs/multi-server-cache-solutions.md +185 -0
  45. package/docs/performance-tuning.md +222 -0
  46. package/examples/bus-mode.js +239 -0
  47. package/examples/continuous-consumer-optimized.js +215 -0
  48. package/examples/continuous-consumer.js +159 -0
  49. package/examples/continuous-producer.js +343 -0
  50. package/examples/mixed-mode.js +277 -0
  51. package/examples/multi-server-test.js +305 -0
  52. package/examples/single.js +64 -0
  53. package/examples/smartchat-dealyed.js +42 -0
  54. package/examples/smartchat.js +52 -0
  55. package/examples/test-cache-invalidation.js +119 -0
  56. package/examples/test-cache-multi-server.js +245 -0
  57. package/examples/test-minimal-client.js +112 -0
  58. package/examples/test-queue-creation-policy.js +137 -0
  59. package/init-db.js +20 -0
  60. package/package.json +36 -0
  61. package/src/client/client.js +291 -0
  62. package/src/client/index.js +6 -0
  63. package/src/client/queenClient.js +513 -0
  64. package/src/client/utils/http.js +172 -0
  65. package/src/client/utils/loadBalancer.js +152 -0
  66. package/src/client/utils/retry.js +35 -0
  67. package/src/config.js +215 -0
  68. package/src/database/connection.js +103 -0
  69. package/src/database/poolManager.js +192 -0
  70. package/src/database/schema-v2.sql +214 -0
  71. package/src/managers/eventManager.js +59 -0
  72. package/src/managers/queueManagerOptimized.js +1512 -0
  73. package/src/managers/resourceCache.js +96 -0
  74. package/src/managers/systemEventManager.js +127 -0
  75. package/src/routes/ack.js +26 -0
  76. package/src/routes/analytics.js +812 -0
  77. package/src/routes/configure.js +46 -0
  78. package/src/routes/messages.js +298 -0
  79. package/src/routes/pop.js +85 -0
  80. package/src/routes/push.js +28 -0
  81. package/src/routes/resources.js +296 -0
  82. package/src/server.js +1286 -0
  83. package/src/services/encryptionService.js +82 -0
  84. package/src/services/evictionService.js +131 -0
  85. package/src/services/retentionService.js +129 -0
  86. package/src/services/startupSync.js +35 -0
  87. package/src/test/test.js +4521 -0
  88. package/src/utils/logger.js +44 -0
  89. package/src/utils/uuid.js +5 -0
  90. package/src/websocket/wsServer.js +221 -0
@@ -0,0 +1,501 @@
1
+ <template>
2
+ <div class="queue-detail">
3
+ <div class="detail-header">
4
+ <div class="header-info">
5
+ <Button
6
+ icon="pi pi-arrow-left"
7
+ class="p-button-text back-btn"
8
+ @click="$router.push('/queues')"
9
+ v-tooltip="'Back to Queues'"
10
+ />
11
+ <h1>{{ queueName }}</h1>
12
+ </div>
13
+ <div class="header-actions">
14
+ <Select
15
+ v-model="selectedTimeRange"
16
+ :options="timeRangeOptions || []"
17
+ optionLabel="label"
18
+ optionValue="value"
19
+ placeholder="Time range"
20
+ @change="onTimeRangeChange"
21
+ class="time-filter"
22
+ />
23
+ <Button
24
+ label="Refresh"
25
+ icon="pi pi-refresh"
26
+ class="btn-primary"
27
+ @click="fetchQueueDetails"
28
+ :loading="loading"
29
+ />
30
+ </div>
31
+ </div>
32
+
33
+ <!-- Queue Information Card -->
34
+ <div class="card-v3 info-card">
35
+ <h3 class="card-title">Queue Information</h3>
36
+ <div class="info-grid">
37
+ <div class="info-item">
38
+ <span class="info-label">Namespace:</span>
39
+ <span class="info-value">{{ queueInfo.namespace || '-' }}</span>
40
+ </div>
41
+ <div class="info-item">
42
+ <span class="info-label">Task:</span>
43
+ <span class="info-value">{{ queueInfo.task || '-' }}</span>
44
+ </div>
45
+ <div class="info-item">
46
+ <span class="info-label">Created:</span>
47
+ <span class="info-value">{{ formatDate(queueInfo.created) }}</span>
48
+ </div>
49
+ <div class="info-item">
50
+ <span class="info-label">Total Messages:</span>
51
+ <span class="info-value highlight">{{ queueInfo.totalMessages || 0 }}</span>
52
+ </div>
53
+ </div>
54
+ </div>
55
+
56
+ <!-- Partitions Table -->
57
+ <div class="card-v3">
58
+ <h3 class="card-title">Partitions</h3>
59
+ <DataTable
60
+ :value="partitions"
61
+ :loading="loading"
62
+ class="dark-table-v3"
63
+ >
64
+ <Column field="name" header="PARTITION NAME">
65
+ <template #body="{ data }">
66
+ <span class="partition-name">{{ data.name }}</span>
67
+ </template>
68
+ </Column>
69
+ <Column field="priority" header="PRIORITY">
70
+ <template #body="{ data }">
71
+ <span class="priority-value">{{ data.priority }}</span>
72
+ </template>
73
+ </Column>
74
+ <Column header="STATS">
75
+ <template #body="{ data }">
76
+ <div class="stats-badges">
77
+ <span class="status-pending">{{ data.pending || 0 }} pending</span>
78
+ <span class="status-processing">{{ data.processing || 0 }} processing</span>
79
+ <span class="status-completed">{{ data.completed || 0 }} completed</span>
80
+ </div>
81
+ </template>
82
+ </Column>
83
+ </DataTable>
84
+ </div>
85
+
86
+ <!-- Message Activity Chart -->
87
+ <div class="chart-container" style="margin-top: 1.5rem;">
88
+ <div class="chart-header">
89
+ <h3 class="chart-title">Message Activity</h3>
90
+ <Button
91
+ icon="pi pi-refresh"
92
+ class="p-button-text p-button-sm"
93
+ @click="fetchQueueDetails"
94
+ v-tooltip="'Refresh'"
95
+ />
96
+ </div>
97
+ <ThroughputChart :data="activityData" :loading="loading" />
98
+ </div>
99
+ </div>
100
+ </template>
101
+
102
+ <script setup>
103
+ import { ref, onMounted, computed, watch } from 'vue'
104
+ import { useRoute } from 'vue-router'
105
+ import { useToast } from 'primevue/usetoast'
106
+ import DataTable from 'primevue/datatable'
107
+ import Column from 'primevue/column'
108
+ import Button from 'primevue/button'
109
+ import Select from 'primevue/select'
110
+ import ThroughputChart from '../components/charts/ThroughputChart.vue'
111
+ import api from '../services/api.js'
112
+
113
+ const route = useRoute()
114
+ const toast = useToast()
115
+ const loading = ref(false)
116
+
117
+ const queueName = computed(() => route.params.name || 'Unknown Queue')
118
+
119
+ // Time range filter
120
+ const selectedTimeRange = ref('1h')
121
+ const timeRangeOptions = ref([
122
+ { label: 'Last Hour', value: '1h' },
123
+ { label: 'Last 6 Hours', value: '6h' },
124
+ { label: 'Last 24 Hours', value: '24h' },
125
+ { label: 'Last 7 Days', value: '7d' },
126
+ { label: 'Last 30 Days', value: '30d' }
127
+ ])
128
+
129
+ const queueInfo = ref({
130
+ namespace: null,
131
+ task: null,
132
+ created: null,
133
+ totalMessages: 0
134
+ })
135
+
136
+ const partitions = ref([])
137
+
138
+ const activityData = ref({
139
+ labels: [],
140
+ datasets: []
141
+ })
142
+
143
+ const fetchQueueDetails = async () => {
144
+ try {
145
+ loading.value = true
146
+
147
+ // Build time range filter
148
+ const filters = {}
149
+ const now = new Date()
150
+ const from = new Date()
151
+
152
+ switch (selectedTimeRange.value) {
153
+ case '1h':
154
+ from.setHours(from.getHours() - 1)
155
+ break
156
+ case '6h':
157
+ from.setHours(from.getHours() - 6)
158
+ break
159
+ case '24h':
160
+ from.setDate(from.getDate() - 1)
161
+ break
162
+ case '7d':
163
+ from.setDate(from.getDate() - 7)
164
+ break
165
+ case '30d':
166
+ from.setDate(from.getDate() - 30)
167
+ break
168
+ }
169
+
170
+ filters.fromDateTime = from.toISOString()
171
+ filters.toDateTime = now.toISOString()
172
+
173
+ // Fetch real queue data from API with filters
174
+ const [queueData, analyticsData, partitionData] = await Promise.all([
175
+ api.getQueueDetail(queueName.value).catch(() => null),
176
+ api.getQueueAnalytics(queueName.value, filters).catch(() => null),
177
+ api.getPartitions({ queue: queueName.value }).catch(() => null)
178
+ ])
179
+
180
+ // Update queue info
181
+ if (queueData) {
182
+ queueInfo.value = {
183
+ namespace: queueData.namespace || null,
184
+ task: queueData.task || null,
185
+ created: queueData.created || new Date().toISOString(),
186
+ totalMessages: queueData.stats?.total ||
187
+ (queueData.stats?.pending || 0) +
188
+ (queueData.stats?.processing || 0) +
189
+ (queueData.stats?.completed || 0) +
190
+ (queueData.stats?.failed || 0)
191
+ }
192
+ }
193
+
194
+ // Process partition data
195
+ if (partitionData && partitionData.partitions) {
196
+ partitions.value = partitionData.partitions.map(p => ({
197
+ name: p.name || p.id || 'Unknown',
198
+ priority: p.priority || 0,
199
+ pending: p.stats?.pending || 0,
200
+ processing: p.stats?.processing || 0,
201
+ completed: p.stats?.completed || 0
202
+ }))
203
+ } else {
204
+ // Default partitions if no data
205
+ partitions.value = [
206
+ { name: 'Default', priority: 0, pending: 0, processing: 0, completed: 0 }
207
+ ]
208
+ }
209
+
210
+ // Process throughput data for activity chart
211
+ if (analyticsData && analyticsData.throughput && analyticsData.throughput.length > 0) {
212
+ const recentData = analyticsData.throughput.slice(-12)
213
+
214
+ activityData.value = {
215
+ labels: recentData.map(item => {
216
+ const date = new Date(item.timestamp)
217
+ return date.toLocaleTimeString('en-US', {
218
+ hour: 'numeric',
219
+ minute: '2-digit'
220
+ })
221
+ }),
222
+ datasets: [
223
+ {
224
+ label: 'Incoming Messages',
225
+ data: recentData.map(item => item.incoming || 0)
226
+ },
227
+ {
228
+ label: 'Completed Messages',
229
+ data: recentData.map(item => item.completed || 0)
230
+ },
231
+ {
232
+ label: 'Failed Messages',
233
+ data: recentData.map(item => item.failed || 0)
234
+ }
235
+ ]
236
+ }
237
+ } else {
238
+ // Generate placeholder data if no real data available
239
+ const now = new Date()
240
+ const placeholderData = []
241
+ for (let i = 11; i >= 0; i--) {
242
+ const time = new Date(now.getTime() - i * 5 * 60 * 1000)
243
+ placeholderData.push({
244
+ timestamp: time.toISOString(),
245
+ incoming: 0,
246
+ completed: 0,
247
+ failed: 0
248
+ })
249
+ }
250
+
251
+ activityData.value = {
252
+ labels: placeholderData.map(item => {
253
+ const date = new Date(item.timestamp)
254
+ return date.toLocaleTimeString('en-US', {
255
+ hour: 'numeric',
256
+ minute: '2-digit'
257
+ })
258
+ }),
259
+ datasets: [
260
+ {
261
+ label: 'Incoming Messages',
262
+ data: placeholderData.map(() => 0)
263
+ },
264
+ {
265
+ label: 'Completed Messages',
266
+ data: placeholderData.map(() => 0)
267
+ },
268
+ {
269
+ label: 'Failed Messages',
270
+ data: placeholderData.map(() => 0)
271
+ }
272
+ ]
273
+ }
274
+ }
275
+
276
+ } catch (error) {
277
+ console.error('Failed to fetch queue details:', error)
278
+ toast.add({
279
+ severity: 'error',
280
+ summary: 'Error',
281
+ detail: 'Failed to load queue details',
282
+ life: 3000
283
+ })
284
+ } finally {
285
+ loading.value = false
286
+ }
287
+ }
288
+
289
+ const formatDate = (dateString) => {
290
+ if (!dateString) return '-'
291
+ const date = new Date(dateString)
292
+ return date.toLocaleString()
293
+ }
294
+
295
+ // Handle time range change
296
+ const onTimeRangeChange = () => {
297
+ fetchQueueDetails()
298
+ }
299
+
300
+ // Watch for queue name changes
301
+ watch(() => route.params.name, (newName) => {
302
+ if (newName) {
303
+ fetchQueueDetails()
304
+ }
305
+ })
306
+
307
+ onMounted(() => {
308
+ fetchQueueDetails()
309
+ })
310
+ </script>
311
+
312
+ <style scoped>
313
+ .queue-detail {
314
+ padding: 0;
315
+ }
316
+
317
+ .detail-header {
318
+ display: flex;
319
+ justify-content: space-between;
320
+ align-items: center;
321
+ margin-bottom: 1.5rem;
322
+ }
323
+
324
+ .header-actions {
325
+ display: flex;
326
+ gap: 1rem;
327
+ align-items: center;
328
+ }
329
+
330
+ .time-filter {
331
+ min-width: 150px;
332
+ }
333
+
334
+ .time-filter :deep(.p-select) {
335
+ background: rgba(255, 255, 255, 0.05);
336
+ border: 1px solid rgba(255, 255, 255, 0.1);
337
+ border-radius: 8px;
338
+ }
339
+
340
+ .time-filter :deep(.p-select:hover) {
341
+ border-color: rgba(236, 72, 153, 0.5);
342
+ }
343
+
344
+ .time-filter :deep(.p-select-label) {
345
+ color: #ffffff;
346
+ }
347
+
348
+ .header-info {
349
+ display: flex;
350
+ align-items: center;
351
+ gap: 1rem;
352
+ }
353
+
354
+ .header-info h1 {
355
+ font-size: 1.5rem;
356
+ font-weight: 600;
357
+ color: var(--surface-700);
358
+ margin: 0;
359
+ }
360
+
361
+ .back-btn {
362
+ color: var(--surface-500) !important;
363
+ }
364
+
365
+ .back-btn:hover {
366
+ background: rgba(236, 72, 153, 0.1) !important;
367
+ color: var(--primary-500) !important;
368
+ }
369
+
370
+ .card-v3 {
371
+ background: transparent;
372
+ border: 1px solid rgba(255, 255, 255, 0.1);
373
+ border-radius: 16px;
374
+ padding: 1.5rem;
375
+ position: relative;
376
+ overflow: hidden;
377
+ margin-bottom: 1.5rem;
378
+ }
379
+
380
+ .card-title {
381
+ font-size: 1.125rem;
382
+ font-weight: 600;
383
+ color: var(--surface-700);
384
+ margin: 0 0 1.5rem 0;
385
+ }
386
+
387
+ .info-card {
388
+ margin-bottom: 1.5rem;
389
+ }
390
+
391
+ .info-grid {
392
+ display: grid;
393
+ grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
394
+ gap: 1.5rem;
395
+ }
396
+
397
+ .info-item {
398
+ display: flex;
399
+ flex-direction: column;
400
+ gap: 0.5rem;
401
+ }
402
+
403
+ .info-label {
404
+ font-size: 0.75rem;
405
+ color: var(--surface-400);
406
+ text-transform: uppercase;
407
+ letter-spacing: 0.05em;
408
+ font-weight: 500;
409
+ }
410
+
411
+ .info-value {
412
+ font-size: 1rem;
413
+ color: var(--surface-600);
414
+ font-weight: 500;
415
+ }
416
+
417
+ .info-value.highlight {
418
+ color: var(--primary-500);
419
+ font-size: 1.25rem;
420
+ font-weight: 600;
421
+ }
422
+
423
+ .partition-name {
424
+ color: var(--surface-600);
425
+ font-weight: 500;
426
+ }
427
+
428
+ .priority-value {
429
+ color: var(--surface-500);
430
+ }
431
+
432
+ .stats-badges {
433
+ display: flex;
434
+ gap: 0.75rem;
435
+ }
436
+
437
+ .chart-container {
438
+ background: transparent;
439
+ border: 1px solid rgba(255, 255, 255, 0.1);
440
+ border-radius: 16px;
441
+ padding: 1.5rem;
442
+ height: 400px;
443
+ display: flex;
444
+ flex-direction: column;
445
+ }
446
+
447
+ .chart-header {
448
+ display: flex;
449
+ justify-content: space-between;
450
+ align-items: center;
451
+ margin-bottom: 1.5rem;
452
+ }
453
+
454
+ .chart-title {
455
+ font-size: 1.125rem;
456
+ font-weight: 600;
457
+ color: var(--surface-700);
458
+ margin: 0;
459
+ }
460
+
461
+ /* DataTable dark theme overrides */
462
+ :deep(.dark-table-v3) {
463
+ background: transparent !important;
464
+ border: none !important;
465
+ }
466
+
467
+ :deep(.dark-table-v3 .p-datatable-thead > tr > th) {
468
+ background: transparent !important;
469
+ color: var(--surface-400) !important;
470
+ border-color: rgba(255, 255, 255, 0.1) !important;
471
+ text-transform: uppercase;
472
+ font-size: 0.75rem;
473
+ letter-spacing: 0.05em;
474
+ }
475
+
476
+ :deep(.dark-table-v3 .p-datatable-tbody > tr) {
477
+ background: transparent !important;
478
+ }
479
+
480
+ :deep(.dark-table-v3 .p-datatable-tbody > tr:hover) {
481
+ background: rgba(236, 72, 153, 0.05) !important;
482
+ }
483
+
484
+ :deep(.dark-table-v3 .p-datatable-tbody > tr > td) {
485
+ color: var(--surface-600) !important;
486
+ border-color: rgba(255, 255, 255, 0.05) !important;
487
+ }
488
+
489
+ /* Responsive */
490
+ @media (max-width: 768px) {
491
+ .info-grid {
492
+ grid-template-columns: repeat(2, 1fr);
493
+ }
494
+ }
495
+
496
+ @media (max-width: 480px) {
497
+ .info-grid {
498
+ grid-template-columns: 1fr;
499
+ }
500
+ }
501
+ </style>