@fedify/amqp 0.1.0 → 0.2.0-dev.12

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 CHANGED
@@ -34,8 +34,8 @@ const federation = createFederation({
34
34
  [JSR badge]: https://jsr.io/badges/@fedify/amqp
35
35
  [npm]: https://www.npmjs.com/package/@fedify/amqp
36
36
  [npm badge]: https://img.shields.io/npm/v/@fedify/amqp?logo=npm
37
- [GitHub Actions]: https://github.com/dahlia/fedify-amqp/actions/workflows/main.yaml
38
- [GitHub Actions badge]: https://github.com/dahlia/fedify-amqp/actions/workflows/main.yaml/badge.svg
37
+ [GitHub Actions]: https://github.com/fedify-dev/amqp/actions/workflows/main.yaml
38
+ [GitHub Actions badge]: https://github.com/fedify-dev/amqp/actions/workflows/main.yaml/badge.svg
39
39
  [RabbitMQ]: https://www.rabbitmq.com/
40
40
  [Fedify]: https://fedify.dev/
41
41
  [`KvStore`]: https://jsr.io/@fedify/fedify/doc/federation/~/KvStore
@@ -68,6 +68,16 @@ bun add @fedify/amqp
68
68
  Changelog
69
69
  ---------
70
70
 
71
+ ### Version 0.2.0
72
+
73
+ To be released.
74
+
75
+ - Added `AmqpMessageQueue.enqueueMany()` method for efficiently enqueuing
76
+ multiple messages at once.
77
+
78
+ - Updated *@js-temporal/polyfill* to 0.5.0 for Node.js and Bun. On Deno,
79
+ there is no change because the polyfill is not used.
80
+
71
81
  ### Version 0.1.0
72
82
 
73
83
  Initial release. Released on October 14, 2024.
package/esm/src/mq.js CHANGED
@@ -69,6 +69,33 @@ export class AmqpMessageQueue {
69
69
  contentType: "application/json",
70
70
  });
71
71
  }
72
+ async enqueueMany(
73
+ // deno-lint-ignore no-explicit-any
74
+ messages, options) {
75
+ const channel = await __classPrivateFieldGet(this, _AmqpMessageQueue_instances, "m", _AmqpMessageQueue_getSenderChannel).call(this);
76
+ const delay = options?.delay?.total("millisecond");
77
+ let queue;
78
+ if (delay == null || delay <= 0) {
79
+ queue = __classPrivateFieldGet(this, _AmqpMessageQueue_queue, "f");
80
+ }
81
+ else {
82
+ const delayStr = delay.toLocaleString("en", { useGrouping: false });
83
+ queue = __classPrivateFieldGet(this, _AmqpMessageQueue_delayedQueuePrefix, "f") + delayStr;
84
+ await channel.assertQueue(queue, {
85
+ autoDelete: true,
86
+ durable: __classPrivateFieldGet(this, _AmqpMessageQueue_durable, "f"),
87
+ deadLetterExchange: "",
88
+ deadLetterRoutingKey: __classPrivateFieldGet(this, _AmqpMessageQueue_queue, "f"),
89
+ messageTtl: delay,
90
+ });
91
+ }
92
+ for (const message of messages) {
93
+ channel.sendToQueue(queue, Buffer.from(JSON.stringify(message), "utf-8"), {
94
+ persistent: __classPrivateFieldGet(this, _AmqpMessageQueue_durable, "f"),
95
+ contentType: "application/json",
96
+ });
97
+ }
98
+ }
72
99
  async listen(
73
100
  // deno-lint-ignore no-explicit-any
74
101
  handler, options = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/amqp",
3
- "version": "0.1.0",
3
+ "version": "0.2.0-dev.12+5b5e643a",
4
4
  "description": "AMQP/RabbitMQ driver for Fedify",
5
5
  "keywords": [
6
6
  "fedify",
@@ -12,14 +12,14 @@
12
12
  "email": "hong@minhee.org",
13
13
  "url": "https://hongminhee.org/"
14
14
  },
15
- "homepage": "https://github.com/dahlia/fedify-amqp",
15
+ "homepage": "https://github.com/fedify-dev/amqp",
16
16
  "repository": {
17
17
  "type": "git",
18
- "url": "git+https://github.com/dahlia/fedify-amqp.git"
18
+ "url": "git+https://github.com/fedify-dev/amqp.git"
19
19
  },
20
20
  "license": "MIT",
21
21
  "bugs": {
22
- "url": "https://github.com/dahlia/fedify-amqp/issues"
22
+ "url": "https://github.com/fedify-dev/amqp/issues"
23
23
  },
24
24
  "main": "./script/mod.js",
25
25
  "module": "./esm/mod.js",
@@ -50,12 +50,12 @@
50
50
  "https://github.com/sponsors/dahlia"
51
51
  ],
52
52
  "dependencies": {
53
- "@fedify/fedify": "^1.0.0",
53
+ "@fedify/fedify": "1.5.0-dev.750",
54
54
  "amqplib": "^0.10.4"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@types/node": "^20.9.0",
58
- "@types/amqplib": "^0.10.5"
58
+ "@types/amqplib": "0.10.6"
59
59
  },
60
60
  "_generatedBy": "dnt@dev"
61
61
  }
package/script/src/mq.js CHANGED
@@ -72,6 +72,33 @@ class AmqpMessageQueue {
72
72
  contentType: "application/json",
73
73
  });
74
74
  }
75
+ async enqueueMany(
76
+ // deno-lint-ignore no-explicit-any
77
+ messages, options) {
78
+ const channel = await __classPrivateFieldGet(this, _AmqpMessageQueue_instances, "m", _AmqpMessageQueue_getSenderChannel).call(this);
79
+ const delay = options?.delay?.total("millisecond");
80
+ let queue;
81
+ if (delay == null || delay <= 0) {
82
+ queue = __classPrivateFieldGet(this, _AmqpMessageQueue_queue, "f");
83
+ }
84
+ else {
85
+ const delayStr = delay.toLocaleString("en", { useGrouping: false });
86
+ queue = __classPrivateFieldGet(this, _AmqpMessageQueue_delayedQueuePrefix, "f") + delayStr;
87
+ await channel.assertQueue(queue, {
88
+ autoDelete: true,
89
+ durable: __classPrivateFieldGet(this, _AmqpMessageQueue_durable, "f"),
90
+ deadLetterExchange: "",
91
+ deadLetterRoutingKey: __classPrivateFieldGet(this, _AmqpMessageQueue_queue, "f"),
92
+ messageTtl: delay,
93
+ });
94
+ }
95
+ for (const message of messages) {
96
+ channel.sendToQueue(queue, node_buffer_1.Buffer.from(JSON.stringify(message), "utf-8"), {
97
+ persistent: __classPrivateFieldGet(this, _AmqpMessageQueue_durable, "f"),
98
+ contentType: "application/json",
99
+ });
100
+ }
101
+ }
75
102
  async listen(
76
103
  // deno-lint-ignore no-explicit-any
77
104
  handler, options = {}) {
package/types/src/mq.d.ts CHANGED
@@ -45,6 +45,7 @@ export declare class AmqpMessageQueue implements MessageQueue {
45
45
  */
46
46
  constructor(connection: Connection, options?: AmqpMessageQueueOptions);
47
47
  enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
48
+ enqueueMany(messages: any[], options?: MessageQueueEnqueueOptions): Promise<void>;
48
49
  listen(handler: (message: any) => void | Promise<void>, options?: MessageQueueListenOptions): Promise<void>;
49
50
  }
50
51
  //# sourceMappingURL=mq.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mq.d.ts","sourceRoot":"","sources":["../../src/src/mq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,0BAA0B,EAC1B,yBAAyB,EAC1B,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAW,UAAU,EAAE,MAAM,SAAS,CAAC;AAGnD;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,gBAAiB,YAAW,YAAY;;IAOnD;;;;OAIG;gBAED,UAAU,EAAE,UAAU,EACtB,OAAO,GAAE,uBAA4B;IAsBjC,OAAO,CAEX,OAAO,EAAE,GAAG,EACZ,OAAO,CAAC,EAAE,0BAA0B,GACnC,OAAO,CAAC,IAAI,CAAC;IA2BV,MAAM,CAEV,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAC/C,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,IAAI,CAAC;CAwBjB"}
1
+ {"version":3,"file":"mq.d.ts","sourceRoot":"","sources":["../../src/src/mq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,0BAA0B,EAC1B,yBAAyB,EAC1B,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAW,UAAU,EAAE,MAAM,SAAS,CAAC;AAGnD;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