queen-mq 0.6.4 → 0.12.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.
- package/README.md +1 -1
- package/client-v2/Queen.js +31 -4
- package/client-v2/README.md +53 -2
- package/client-v2/admin/Admin.js +414 -0
- package/client-v2/admin/index.js +6 -0
- package/client-v2/builders/QueueBuilder.js +24 -1
- package/client-v2/consumer/ConsumerManager.js +25 -4
- package/client-v2/http/HttpClient.js +36 -15
- package/client-v2/http/LoadBalancer.js +227 -6
- package/client-v2/index.js +1 -0
- package/client-v2/utils/defaults.js +5 -2
- package/client-v2/utils/logger.js +13 -2
- package/package.json +3 -2
- package/test-v2/consume.js +6 -57
- package/test-v2/load.js +22 -20
- package/test-v2/maintenance.js +3 -1
- package/test-v2/push.js +0 -29
- package/test-v2/run.js +24 -3
package/test-v2/maintenance.js
CHANGED
|
@@ -63,7 +63,7 @@ export async function test_maintenance_mode(client = null) {
|
|
|
63
63
|
const consumePromise = (async () => {
|
|
64
64
|
while (consumerActive) {
|
|
65
65
|
try {
|
|
66
|
-
const messages = await queen.queue(QUEUE_NAME).batch(10).wait(
|
|
66
|
+
const messages = await queen.queue(QUEUE_NAME).batch(10).wait(false).limit(1).each().pop();
|
|
67
67
|
|
|
68
68
|
if (messages && messages.length > 0) {
|
|
69
69
|
receivedCount += messages.length;
|
|
@@ -71,12 +71,14 @@ export async function test_maintenance_mode(client = null) {
|
|
|
71
71
|
|
|
72
72
|
// Acknowledge messages
|
|
73
73
|
await queen.ack(messages);
|
|
74
|
+
|
|
74
75
|
}
|
|
75
76
|
} catch (err) {
|
|
76
77
|
if (consumerActive) {
|
|
77
78
|
console.error(' ❌ Consumer error:', err.message);
|
|
78
79
|
}
|
|
79
80
|
}
|
|
81
|
+
await sleep(10);
|
|
80
82
|
}
|
|
81
83
|
})();
|
|
82
84
|
|
package/test-v2/push.js
CHANGED
|
@@ -115,35 +115,6 @@ export async function pushBufferedMessage(client) {
|
|
|
115
115
|
return { success: true }
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
export async function pushMaxQueueSize(client) {
|
|
119
|
-
const queue = await client.queue('test-queue-max-size').config({ maxSize: 10 }).create()
|
|
120
|
-
if (!queue.configured) {
|
|
121
|
-
return { success: false, message: 'Queue not created' }
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// Necessary to create a partition consumer to trigger the capacity check
|
|
125
|
-
const popToCreateParititonConsumer = await client
|
|
126
|
-
.queue('test-queue-max-size')
|
|
127
|
-
.batch(1)
|
|
128
|
-
.wait(false)
|
|
129
|
-
.pop()
|
|
130
|
-
|
|
131
|
-
try {
|
|
132
|
-
for (let i = 0; i < 20; i++) {
|
|
133
|
-
const result = await client
|
|
134
|
-
.queue('test-queue-max-size')
|
|
135
|
-
.push([{ data: { message: i } }])
|
|
136
|
-
}
|
|
137
|
-
} catch (error) {
|
|
138
|
-
if (!error.message.includes(' Queue "test-queue-max-size" would exceed max capacity (10).')) {
|
|
139
|
-
return { success: true, message: 'Correct error message' }
|
|
140
|
-
} else {
|
|
141
|
-
return { success: false, message: 'Incorrect error message' }
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return { success: false }
|
|
145
|
-
}
|
|
146
|
-
|
|
147
118
|
export async function pushDelayedMessage(client) {
|
|
148
119
|
const queue = await client.queue('test-queue-delayed')
|
|
149
120
|
.config({ delayedProcessing: 2 })
|
package/test-v2/run.js
CHANGED
|
@@ -18,11 +18,26 @@ import * as bufferingTests from './ai_buffering.js'
|
|
|
18
18
|
import * as priorityTests from './ai_priority.js'
|
|
19
19
|
import * as ttlRetentionTests from './ai_ttl_retention.js'
|
|
20
20
|
import * as mixedScenariosTests from './ai_mixed_scenarios.js'
|
|
21
|
+
import { LoadBalancer } from '../client-v2/http/LoadBalancer.js';
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
// Test configuration
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
|
|
26
|
+
export const TEST_CONFIG_SINGLE = {
|
|
27
|
+
baseUrls: ['http://localhost:6632'],
|
|
28
|
+
loadBalancingStrategy: 'affinity',
|
|
29
|
+
dbConfig: {
|
|
30
|
+
host: process.env.PG_HOST || 'localhost',
|
|
31
|
+
port: process.env.PG_PORT || 5432,
|
|
32
|
+
database: process.env.PG_DB || 'postgres',
|
|
33
|
+
user: process.env.PG_USER || 'postgres',
|
|
34
|
+
password: process.env.PG_PASSWORD || 'postgres'
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const TEST_CONFIG_MULTIPLE = {
|
|
39
|
+
baseUrls: ['http://localhost:6632','http://localhost:6633'],
|
|
40
|
+
loadBalancingStrategy: 'round-robin',
|
|
26
41
|
dbConfig: {
|
|
27
42
|
host: process.env.PG_HOST || 'localhost',
|
|
28
43
|
port: process.env.PG_PORT || 5432,
|
|
@@ -32,6 +47,9 @@ export const TEST_CONFIG = {
|
|
|
32
47
|
}
|
|
33
48
|
};
|
|
34
49
|
|
|
50
|
+
export const TEST_CONFIG = process.env.TEST_CONFIG === 'multiple' ? TEST_CONFIG_MULTIPLE : TEST_CONFIG_SINGLE;
|
|
51
|
+
console.log('TEST_CONFIG:', TEST_CONFIG);
|
|
52
|
+
|
|
35
53
|
// Global test state
|
|
36
54
|
export let dbPool;
|
|
37
55
|
|
|
@@ -82,7 +100,10 @@ export const cleanupTestData = async () => {
|
|
|
82
100
|
};
|
|
83
101
|
|
|
84
102
|
async function main() {
|
|
85
|
-
const client = new Queen(
|
|
103
|
+
const client = new Queen({
|
|
104
|
+
urls: TEST_CONFIG.baseUrls,
|
|
105
|
+
loadBalancingStrategy: TEST_CONFIG.loadBalancingStrategy
|
|
106
|
+
})
|
|
86
107
|
await initDb()
|
|
87
108
|
|
|
88
109
|
// Separate human and AI tests
|