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.
@@ -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(true).limit(1).each().pop();
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
- export const TEST_CONFIG = {
25
- baseUrls: ['http://localhost:6632'],
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(TEST_CONFIG.baseUrls)
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