@autofleet/rabbit 3.3.0 → 3.3.22-connection-test-beta

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/src/lib/types.ts CHANGED
@@ -31,8 +31,6 @@ export interface ConsumeOptions {
31
31
  useConsumeWithLock?: boolean;
32
32
  auditContext?: any;
33
33
  enableRabbitTrace?: boolean;
34
- // TODO: [QUORUM-PHASE-3] Redundant because all the queues are quorum queues
35
- isQuorumQueue?: boolean;
36
34
  }
37
35
 
38
36
  export type CallbackFunction = (msg: ConsumeMessage, ack: any, nack: any) => Promise<any>
@@ -1,9 +0,0 @@
1
- interface TaskData {
2
- [key: string]: any;
3
- }
4
- interface SendTaskOptions {
5
- taskName: string;
6
- queueName: string;
7
- }
8
- declare function sendCeleryTaskViaHttp(data: TaskData, { taskName, queueName }: SendTaskOptions): Promise<void>;
9
- export { sendCeleryTaskViaHttp, TaskData, SendTaskOptions };
@@ -1,54 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.sendCeleryTaskViaHttp = void 0;
7
- const node_crypto_1 = require("node:crypto");
8
- const logger_1 = __importDefault(require("../logger"));
9
- // Environment configuration
10
- const config = {
11
- host: process.env.RABBITMQ_SERVICE_HOST || 'localhost',
12
- username: process.env.RABBITMQ_USERNAME || 'guest',
13
- password: process.env.RABBITMQ_PASSWORD || 'guest',
14
- };
15
- async function sendCeleryTaskViaHttp(data, { taskName, queueName }) {
16
- const apiUrl = `http://${config.host}:15672/api/exchanges/%2f/amq.default/publish`;
17
- const message = {
18
- task: taskName,
19
- id: (0, node_crypto_1.randomUUID)(),
20
- args: [data],
21
- };
22
- const payload = {
23
- properties: {
24
- delivery_mode: 2,
25
- content_type: 'application/json',
26
- },
27
- routing_key: queueName,
28
- payload: JSON.stringify(message),
29
- payload_encoding: 'string',
30
- };
31
- try {
32
- const response = await fetch(apiUrl, {
33
- method: 'POST',
34
- headers: {
35
- 'Content-Type': 'application/json',
36
- Authorization: `Basic ${Buffer.from(`${config.username}:${config.password}`).toString('base64')}`,
37
- },
38
- body: JSON.stringify(payload),
39
- });
40
- if (response.ok) {
41
- const result = await response.json();
42
- logger_1.default.info('Successfully published message:', result);
43
- }
44
- else {
45
- logger_1.default.error(`Failed to publish message. Status code: ${response.status}`);
46
- logger_1.default.error(`Response: ${await response.text()}`);
47
- }
48
- }
49
- catch (error) {
50
- logger_1.default.error('Error sending request:', error instanceof Error ? error.message : String(error));
51
- throw error;
52
- }
53
- }
54
- exports.sendCeleryTaskViaHttp = sendCeleryTaskViaHttp;
package/src/lib/celery.ts DELETED
@@ -1,89 +0,0 @@
1
- import { randomUUID } from 'node:crypto';
2
- import logger from '../logger';
3
- // Environment configuration
4
- const config = {
5
- host: process.env.RABBITMQ_SERVICE_HOST || 'localhost',
6
- username: process.env.RABBITMQ_USERNAME || 'guest',
7
- password: process.env.RABBITMQ_PASSWORD || 'guest',
8
- } as const;
9
-
10
- // Type definitions
11
- interface TaskData {
12
- [key: string]: any;
13
- }
14
-
15
- interface TaskMessage {
16
- task: string;
17
- id: string;
18
- args: TaskData[];
19
- }
20
-
21
- interface PublishPayload {
22
- properties: {
23
- // eslint-disable-next-line camelcase
24
- delivery_mode: number;
25
- // eslint-disable-next-line camelcase
26
- content_type: string;
27
- };
28
- // eslint-disable-next-line camelcase
29
- routing_key: string;
30
- payload: string;
31
- // eslint-disable-next-line camelcase
32
- payload_encoding: string;
33
- }
34
-
35
- interface PublishResponse {
36
- routed: boolean;
37
- }
38
-
39
- interface SendTaskOptions {
40
- taskName: string;
41
- queueName: string;
42
- }
43
-
44
- async function sendCeleryTaskViaHttp(
45
- data: TaskData,
46
- { taskName, queueName }: SendTaskOptions,
47
- ): Promise<void> {
48
- const apiUrl = `http://${config.host}:15672/api/exchanges/%2f/amq.default/publish`;
49
-
50
- const message: TaskMessage = {
51
- task: taskName,
52
- id: randomUUID(),
53
- args: [data],
54
- };
55
-
56
- const payload: PublishPayload = {
57
- properties: {
58
- delivery_mode: 2,
59
- content_type: 'application/json',
60
- },
61
- routing_key: queueName,
62
- payload: JSON.stringify(message),
63
- payload_encoding: 'string',
64
- };
65
-
66
- try {
67
- const response = await fetch(apiUrl, {
68
- method: 'POST',
69
- headers: {
70
- 'Content-Type': 'application/json',
71
- Authorization: `Basic ${Buffer.from(`${config.username}:${config.password}`).toString('base64')}`,
72
- },
73
- body: JSON.stringify(payload),
74
- });
75
-
76
- if (response.ok) {
77
- const result: PublishResponse = await response.json();
78
- logger.info('Successfully published message:', result);
79
- } else {
80
- logger.error(`Failed to publish message. Status code: ${response.status}`);
81
- logger.error(`Response: ${await response.text()}`);
82
- }
83
- } catch (error) {
84
- logger.error('Error sending request:', error instanceof Error ? error.message : String(error));
85
- throw error;
86
- }
87
- }
88
-
89
- export { sendCeleryTaskViaHttp, TaskData, SendTaskOptions };