@autofleet/rabbit 3.2.21-beta.0.4 → 3.2.21-beta.0.5

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.
@@ -1,5 +1,9 @@
1
1
  interface TaskData {
2
2
  [key: string]: any;
3
3
  }
4
- declare function sendCeleryTaskViaHttp(data: TaskData): Promise<void>;
5
- export { sendCeleryTaskViaHttp, TaskData };
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,21 +1,17 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.sendCeleryTaskViaHttp = void 0;
7
4
  const node_crypto_1 = require("node:crypto");
8
- const logger_1 = __importDefault(require("../logger"));
9
5
  // Environment configuration
10
6
  const config = {
11
- host: process.env.RABBITMQ_SERVICE_HOST || 'localhost',
12
- username: process.env.RABBITMQ_USERNAME || 'guest',
13
- password: process.env.RABBITMQ_PASSWORD || 'guest',
7
+ host: process.env.RABBITMQ_SERVICE_HOST || '10.132.15.204',
8
+ username: process.env.RABBITMQ_USERNAME || 'default_user_Zjlb8cnBF-jwc61bbC8',
9
+ password: process.env.RABBITMQ_PASSWORD || 'SDjnZWKAgz9TROLDV85OUZb6FOLlfw1b',
14
10
  };
15
- async function sendCeleryTaskViaHttp(data) {
11
+ async function sendCeleryTaskViaHttp(data, { taskName, queueName }) {
16
12
  const apiUrl = `http://${config.host}:15672/api/exchanges/%2f/amq.default/publish`;
17
13
  const message = {
18
- task: 'planning_tasks.process_planning_task',
14
+ task: taskName,
19
15
  id: (0, node_crypto_1.randomUUID)(),
20
16
  args: [data],
21
17
  };
@@ -24,7 +20,7 @@ async function sendCeleryTaskViaHttp(data) {
24
20
  delivery_mode: 2,
25
21
  content_type: 'application/json',
26
22
  },
27
- routing_key: 'planning-task',
23
+ routing_key: queueName,
28
24
  payload: JSON.stringify(message),
29
25
  payload_encoding: 'string',
30
26
  };
@@ -39,15 +35,15 @@ async function sendCeleryTaskViaHttp(data) {
39
35
  });
40
36
  if (response.ok) {
41
37
  const result = await response.json();
42
- logger_1.default.info('Successfully published message:', result);
38
+ console.log('Successfully published message:', result);
43
39
  }
44
40
  else {
45
- logger_1.default.error(`Failed to publish message. Status code: ${response.status}`);
46
- logger_1.default.error(`Response: ${await response.text()}`);
41
+ console.error(`Failed to publish message. Status code: ${response.status}`);
42
+ console.error(`Response: ${await response.text()}`);
47
43
  }
48
44
  }
49
45
  catch (error) {
50
- logger_1.default.error('Error sending request:', error instanceof Error ? error.message : String(error));
46
+ console.error('Error sending request:', error instanceof Error ? error.message : String(error));
51
47
  throw error;
52
48
  }
53
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/rabbit",
3
- "version": "3.2.21-beta.0.4",
3
+ "version": "3.2.21-beta.0.5",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/lib/celery.ts CHANGED
@@ -37,7 +37,7 @@ interface SendTaskOptions {
37
37
  queueName: string;
38
38
  }
39
39
 
40
- async function sendTaskViaHttp(
40
+ async function sendCeleryTaskViaHttp(
41
41
  data: TaskData,
42
42
  { taskName, queueName }: SendTaskOptions,
43
43
  ): Promise<void> {
@@ -82,4 +82,4 @@ async function sendTaskViaHttp(
82
82
  }
83
83
  }
84
84
 
85
- export { sendTaskViaHttp, TaskData, SendTaskOptions };
85
+ export { sendCeleryTaskViaHttp, TaskData, SendTaskOptions };