@fedify/amqp 2.1.0-dev.405 → 2.1.0-dev.406
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/deno.json +1 -1
- package/dist/mq.d.cts +110 -110
- package/dist/mq.d.ts +110 -110
- package/package.json +3 -3
- package/tsdown.config.ts +1 -1
package/deno.json
CHANGED
package/dist/mq.d.cts
CHANGED
|
@@ -4,146 +4,146 @@ import { ChannelModel } from "amqplib";
|
|
|
4
4
|
//#region src/mq.d.ts
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
* Options for ordering key support in {@link AmqpMessageQueue}.
|
|
8
|
+
*
|
|
9
|
+
* Ordering key support requires the `rabbitmq_consistent_hash_exchange`
|
|
10
|
+
* plugin to be enabled on the RabbitMQ server. You can enable it by running:
|
|
11
|
+
*
|
|
12
|
+
* ```sh
|
|
13
|
+
* rabbitmq-plugins enable rabbitmq_consistent_hash_exchange
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @since 2.0.0
|
|
17
|
+
*/
|
|
18
18
|
interface AmqpOrderingOptions {
|
|
19
19
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
* The name of the consistent hash exchange to use for ordering.
|
|
21
|
+
* Defaults to `"fedify_ordering"`.
|
|
22
|
+
* @default `"fedify_ordering"`
|
|
23
|
+
*/
|
|
24
24
|
readonly exchange?: string;
|
|
25
25
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
* The prefix to use for ordering queues.
|
|
27
|
+
* Defaults to `"fedify_ordering_"`.
|
|
28
|
+
* @default `"fedify_ordering_"`
|
|
29
|
+
*/
|
|
30
30
|
readonly queuePrefix?: string;
|
|
31
31
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
* The number of partitions (queues) to use for ordering.
|
|
33
|
+
* More partitions allow better parallelism for different ordering keys.
|
|
34
|
+
* Defaults to `4`.
|
|
35
|
+
* @default `4`
|
|
36
|
+
*/
|
|
37
37
|
readonly partitions?: number;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
* Options for {@link AmqpMessageQueue}.
|
|
41
|
+
*/
|
|
42
42
|
interface AmqpMessageQueueOptions {
|
|
43
43
|
/**
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
* The name of the queue to use. Defaults to `"fedify_queue"`.
|
|
45
|
+
* @default `"fedify_queue"`
|
|
46
|
+
*/
|
|
47
47
|
readonly queue?: string;
|
|
48
48
|
/**
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
* The prefix to use for the delayed queue. Defaults to `"fedify_delayed_"`.
|
|
50
|
+
* Defaults to `"fedify_delayed_"`.
|
|
51
|
+
* @default `"fedify_delayed_"`
|
|
52
|
+
*/
|
|
53
53
|
readonly delayedQueuePrefix?: string;
|
|
54
54
|
/**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
* Whether the queue will survive a broker restart. Defaults to `true`.
|
|
56
|
+
* @default `true`
|
|
57
|
+
*/
|
|
58
58
|
readonly durable?: boolean;
|
|
59
59
|
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
60
|
+
* Whether to use native retrial mechanism. If set to `true`, the queue will
|
|
61
|
+
* not acknowledge messages that are not processed successfully, allowing
|
|
62
|
+
* them to be retried later. If set to `false`, messages will be acknowledged
|
|
63
|
+
* whether they are processed successfully or not.
|
|
64
|
+
*
|
|
65
|
+
* Both approaches have their own advantages and disadvantages. With native
|
|
66
|
+
* retrials, much less chance of losing messages, but timing of retrials is
|
|
67
|
+
* less predictable. With non-native retrials, retrials are handled by Fedify
|
|
68
|
+
* itself, which allows for more control over the timing and behavior of
|
|
69
|
+
* retrials, but may result in lost messages if the process crashes before
|
|
70
|
+
* acknowledging the message.
|
|
71
|
+
* @default `false`
|
|
72
|
+
* @since 0.3.0
|
|
73
|
+
*/
|
|
74
74
|
readonly nativeRetrial?: boolean;
|
|
75
75
|
/**
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
76
|
+
* Options for ordering key support. If provided, the message queue will
|
|
77
|
+
* support the `orderingKey` option in {@link MessageQueueEnqueueOptions}.
|
|
78
|
+
* Messages with the same ordering key will be processed in order,
|
|
79
|
+
* while messages with different ordering keys can be processed in parallel.
|
|
80
|
+
*
|
|
81
|
+
* This feature requires the `rabbitmq_consistent_hash_exchange` plugin
|
|
82
|
+
* to be enabled on the RabbitMQ server. See {@link AmqpOrderingOptions}
|
|
83
|
+
* for more details.
|
|
84
|
+
*
|
|
85
|
+
* If not provided, ordering key support is disabled and any `orderingKey`
|
|
86
|
+
* option passed to `enqueue()` will be ignored.
|
|
87
|
+
*
|
|
88
|
+
* @since 0.4.0
|
|
89
|
+
*/
|
|
90
90
|
readonly ordering?: AmqpOrderingOptions;
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
93
|
+
* A message queue that uses AMQP.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ``` typescript
|
|
97
|
+
* import { createFederation } from "@fedify/fedify";
|
|
98
|
+
* import { AmqpMessageQueue } from "@fedify/amqp";
|
|
99
|
+
* import { connect } from "amqplib";
|
|
100
|
+
*
|
|
101
|
+
* const federation = createFederation({
|
|
102
|
+
* queue: new AmqpMessageQueue(await connect("amqp://localhost")),
|
|
103
|
+
* // ... other configurations
|
|
104
|
+
* });
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
107
|
declare class AmqpMessageQueue implements MessageQueue {
|
|
108
108
|
#private;
|
|
109
109
|
readonly nativeRetrial: boolean;
|
|
110
110
|
/**
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
* Creates a new `AmqpMessageQueue`.
|
|
112
|
+
* @param connection A connection to the AMQP server.
|
|
113
|
+
* @param options Options for the message queue.
|
|
114
|
+
*/
|
|
115
115
|
constructor(connection: ChannelModel, options?: AmqpMessageQueueOptions);
|
|
116
116
|
/**
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
117
|
+
* Enqueues a message to be processed.
|
|
118
|
+
*
|
|
119
|
+
* When an `orderingKey` is provided without a `delay`, the message is routed
|
|
120
|
+
* through the consistent hash exchange, ensuring messages with the same
|
|
121
|
+
* ordering key are processed by the same consumer in FIFO order.
|
|
122
|
+
*
|
|
123
|
+
* When both `orderingKey` and `delay` are provided, the message is first
|
|
124
|
+
* placed in a delay queue, then routed to the consistent hash exchange
|
|
125
|
+
* after the delay expires. This ensures ordering is preserved even for
|
|
126
|
+
* delayed messages.
|
|
127
|
+
*
|
|
128
|
+
* @param message The message to enqueue.
|
|
129
|
+
* @param options The options for enqueueing the message.
|
|
130
|
+
*/
|
|
131
131
|
enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
132
132
|
/**
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
133
|
+
* Enqueues multiple messages to be processed.
|
|
134
|
+
*
|
|
135
|
+
* When an `orderingKey` is provided without a `delay`, the messages are
|
|
136
|
+
* routed through the consistent hash exchange, ensuring messages with the
|
|
137
|
+
* same ordering key are processed by the same consumer in FIFO order.
|
|
138
|
+
*
|
|
139
|
+
* When both `orderingKey` and `delay` are provided, the messages are first
|
|
140
|
+
* placed in a delay queue, then routed to the consistent hash exchange
|
|
141
|
+
* after the delay expires. This ensures ordering is preserved even for
|
|
142
|
+
* delayed messages.
|
|
143
|
+
*
|
|
144
|
+
* @param messages The messages to enqueue.
|
|
145
|
+
* @param options The options for enqueueing the messages.
|
|
146
|
+
*/
|
|
147
147
|
enqueueMany(messages: readonly any[], options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
148
148
|
listen(handler: (message: any) => void | Promise<void>, options?: MessageQueueListenOptions): Promise<void>;
|
|
149
149
|
}
|
package/dist/mq.d.ts
CHANGED
|
@@ -4,146 +4,146 @@ import { ChannelModel } from "amqplib";
|
|
|
4
4
|
//#region src/mq.d.ts
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
* Options for ordering key support in {@link AmqpMessageQueue}.
|
|
8
|
+
*
|
|
9
|
+
* Ordering key support requires the `rabbitmq_consistent_hash_exchange`
|
|
10
|
+
* plugin to be enabled on the RabbitMQ server. You can enable it by running:
|
|
11
|
+
*
|
|
12
|
+
* ```sh
|
|
13
|
+
* rabbitmq-plugins enable rabbitmq_consistent_hash_exchange
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @since 2.0.0
|
|
17
|
+
*/
|
|
18
18
|
interface AmqpOrderingOptions {
|
|
19
19
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
* The name of the consistent hash exchange to use for ordering.
|
|
21
|
+
* Defaults to `"fedify_ordering"`.
|
|
22
|
+
* @default `"fedify_ordering"`
|
|
23
|
+
*/
|
|
24
24
|
readonly exchange?: string;
|
|
25
25
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
* The prefix to use for ordering queues.
|
|
27
|
+
* Defaults to `"fedify_ordering_"`.
|
|
28
|
+
* @default `"fedify_ordering_"`
|
|
29
|
+
*/
|
|
30
30
|
readonly queuePrefix?: string;
|
|
31
31
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
* The number of partitions (queues) to use for ordering.
|
|
33
|
+
* More partitions allow better parallelism for different ordering keys.
|
|
34
|
+
* Defaults to `4`.
|
|
35
|
+
* @default `4`
|
|
36
|
+
*/
|
|
37
37
|
readonly partitions?: number;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
* Options for {@link AmqpMessageQueue}.
|
|
41
|
+
*/
|
|
42
42
|
interface AmqpMessageQueueOptions {
|
|
43
43
|
/**
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
* The name of the queue to use. Defaults to `"fedify_queue"`.
|
|
45
|
+
* @default `"fedify_queue"`
|
|
46
|
+
*/
|
|
47
47
|
readonly queue?: string;
|
|
48
48
|
/**
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
* The prefix to use for the delayed queue. Defaults to `"fedify_delayed_"`.
|
|
50
|
+
* Defaults to `"fedify_delayed_"`.
|
|
51
|
+
* @default `"fedify_delayed_"`
|
|
52
|
+
*/
|
|
53
53
|
readonly delayedQueuePrefix?: string;
|
|
54
54
|
/**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
* Whether the queue will survive a broker restart. Defaults to `true`.
|
|
56
|
+
* @default `true`
|
|
57
|
+
*/
|
|
58
58
|
readonly durable?: boolean;
|
|
59
59
|
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
60
|
+
* Whether to use native retrial mechanism. If set to `true`, the queue will
|
|
61
|
+
* not acknowledge messages that are not processed successfully, allowing
|
|
62
|
+
* them to be retried later. If set to `false`, messages will be acknowledged
|
|
63
|
+
* whether they are processed successfully or not.
|
|
64
|
+
*
|
|
65
|
+
* Both approaches have their own advantages and disadvantages. With native
|
|
66
|
+
* retrials, much less chance of losing messages, but timing of retrials is
|
|
67
|
+
* less predictable. With non-native retrials, retrials are handled by Fedify
|
|
68
|
+
* itself, which allows for more control over the timing and behavior of
|
|
69
|
+
* retrials, but may result in lost messages if the process crashes before
|
|
70
|
+
* acknowledging the message.
|
|
71
|
+
* @default `false`
|
|
72
|
+
* @since 0.3.0
|
|
73
|
+
*/
|
|
74
74
|
readonly nativeRetrial?: boolean;
|
|
75
75
|
/**
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
76
|
+
* Options for ordering key support. If provided, the message queue will
|
|
77
|
+
* support the `orderingKey` option in {@link MessageQueueEnqueueOptions}.
|
|
78
|
+
* Messages with the same ordering key will be processed in order,
|
|
79
|
+
* while messages with different ordering keys can be processed in parallel.
|
|
80
|
+
*
|
|
81
|
+
* This feature requires the `rabbitmq_consistent_hash_exchange` plugin
|
|
82
|
+
* to be enabled on the RabbitMQ server. See {@link AmqpOrderingOptions}
|
|
83
|
+
* for more details.
|
|
84
|
+
*
|
|
85
|
+
* If not provided, ordering key support is disabled and any `orderingKey`
|
|
86
|
+
* option passed to `enqueue()` will be ignored.
|
|
87
|
+
*
|
|
88
|
+
* @since 0.4.0
|
|
89
|
+
*/
|
|
90
90
|
readonly ordering?: AmqpOrderingOptions;
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
93
|
+
* A message queue that uses AMQP.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ``` typescript
|
|
97
|
+
* import { createFederation } from "@fedify/fedify";
|
|
98
|
+
* import { AmqpMessageQueue } from "@fedify/amqp";
|
|
99
|
+
* import { connect } from "amqplib";
|
|
100
|
+
*
|
|
101
|
+
* const federation = createFederation({
|
|
102
|
+
* queue: new AmqpMessageQueue(await connect("amqp://localhost")),
|
|
103
|
+
* // ... other configurations
|
|
104
|
+
* });
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
107
|
declare class AmqpMessageQueue implements MessageQueue {
|
|
108
108
|
#private;
|
|
109
109
|
readonly nativeRetrial: boolean;
|
|
110
110
|
/**
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
* Creates a new `AmqpMessageQueue`.
|
|
112
|
+
* @param connection A connection to the AMQP server.
|
|
113
|
+
* @param options Options for the message queue.
|
|
114
|
+
*/
|
|
115
115
|
constructor(connection: ChannelModel, options?: AmqpMessageQueueOptions);
|
|
116
116
|
/**
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
117
|
+
* Enqueues a message to be processed.
|
|
118
|
+
*
|
|
119
|
+
* When an `orderingKey` is provided without a `delay`, the message is routed
|
|
120
|
+
* through the consistent hash exchange, ensuring messages with the same
|
|
121
|
+
* ordering key are processed by the same consumer in FIFO order.
|
|
122
|
+
*
|
|
123
|
+
* When both `orderingKey` and `delay` are provided, the message is first
|
|
124
|
+
* placed in a delay queue, then routed to the consistent hash exchange
|
|
125
|
+
* after the delay expires. This ensures ordering is preserved even for
|
|
126
|
+
* delayed messages.
|
|
127
|
+
*
|
|
128
|
+
* @param message The message to enqueue.
|
|
129
|
+
* @param options The options for enqueueing the message.
|
|
130
|
+
*/
|
|
131
131
|
enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
132
132
|
/**
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
133
|
+
* Enqueues multiple messages to be processed.
|
|
134
|
+
*
|
|
135
|
+
* When an `orderingKey` is provided without a `delay`, the messages are
|
|
136
|
+
* routed through the consistent hash exchange, ensuring messages with the
|
|
137
|
+
* same ordering key are processed by the same consumer in FIFO order.
|
|
138
|
+
*
|
|
139
|
+
* When both `orderingKey` and `delay` are provided, the messages are first
|
|
140
|
+
* placed in a delay queue, then routed to the consistent hash exchange
|
|
141
|
+
* after the delay expires. This ensures ordering is preserved even for
|
|
142
|
+
* delayed messages.
|
|
143
|
+
*
|
|
144
|
+
* @param messages The messages to enqueue.
|
|
145
|
+
* @param options The options for enqueueing the messages.
|
|
146
|
+
*/
|
|
147
147
|
enqueueMany(messages: readonly any[], options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
148
148
|
listen(handler: (message: any) => void | Promise<void>, options?: MessageQueueListenOptions): Promise<void>;
|
|
149
149
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/amqp",
|
|
3
|
-
"version": "2.1.0-dev.
|
|
3
|
+
"version": "2.1.0-dev.406+61a21e4e",
|
|
4
4
|
"description": "AMQP/RabbitMQ driver for Fedify",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fedify",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"amqplib": "^0.10.9",
|
|
58
|
-
"@fedify/fedify": "^2.1.0-dev.
|
|
58
|
+
"@fedify/fedify": "^2.1.0-dev.406+61a21e4e"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@alinea/suite": "^0.6.3",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@types/amqplib": "^0.10.7",
|
|
66
66
|
"tsdown": "^0.12.9",
|
|
67
67
|
"typescript": "^5.9.3",
|
|
68
|
-
"@fedify/testing": "^2.1.0-dev.
|
|
68
|
+
"@fedify/testing": "^2.1.0-dev.406+61a21e4e"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"build:self": "tsdown",
|
package/tsdown.config.ts
CHANGED