@encore.dev/sdk 2.0.0-beta.15 → 2.0.0-beta.16
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 +111 -101
- package/app_meta.ts +56 -54
- package/config/config.ts +60 -57
- package/config/secrets.ts +45 -52
- package/config/value.ts +23 -26
- package/cron/mod.ts +28 -29
- package/dist/app_meta.d.ts +52 -50
- package/dist/app_meta.d.ts.map +1 -1
- package/dist/app_meta.js +2 -2
- package/dist/app_meta.js.map +1 -1
- package/dist/config/config.d.ts +58 -55
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +8 -9
- package/dist/config/config.js.map +1 -1
- package/dist/config/secrets.d.ts +45 -52
- package/dist/config/secrets.d.ts.map +1 -1
- package/dist/config/secrets.js +8 -9
- package/dist/config/secrets.js.map +1 -1
- package/dist/config/value.d.ts +20 -23
- package/dist/config/value.d.ts.map +1 -1
- package/dist/config/value.js +20 -23
- package/dist/config/value.js.map +1 -1
- package/dist/cron/mod.d.ts +26 -27
- package/dist/cron/mod.d.ts.map +1 -1
- package/dist/cron/mod.js +13 -14
- package/dist/cron/mod.js.map +1 -1
- package/dist/frontends/mod.d.ts +20 -19
- package/dist/frontends/mod.d.ts.map +1 -1
- package/dist/frontends/mod.js +20 -19
- package/dist/frontends/mod.js.map +1 -1
- package/dist/gateway/errors.d.ts +28 -30
- package/dist/gateway/errors.d.ts.map +1 -1
- package/dist/gateway/errors.js +29 -31
- package/dist/gateway/errors.js.map +1 -1
- package/dist/gateway/match.d.ts +54 -54
- package/dist/gateway/match.d.ts.map +1 -1
- package/dist/gateway/match.js +56 -56
- package/dist/gateway/match.js.map +1 -1
- package/dist/gateway/middleware.d.ts +62 -64
- package/dist/gateway/middleware.d.ts.map +1 -1
- package/dist/gateway/middleware.js +1 -1
- package/dist/gateway/middleware.js.map +1 -1
- package/dist/gateway/mod.d.ts +64 -67
- package/dist/gateway/mod.d.ts.map +1 -1
- package/dist/gateway/mod.js +72 -76
- package/dist/gateway/mod.js.map +1 -1
- package/dist/gateway/request.d.ts +138 -134
- package/dist/gateway/request.d.ts.map +1 -1
- package/dist/gateway/request.js +117 -108
- package/dist/gateway/request.js.map +1 -1
- package/dist/gateway/serve.d.ts +29 -34
- package/dist/gateway/serve.d.ts.map +1 -1
- package/dist/gateway/serve.js +51 -56
- package/dist/gateway/serve.js.map +1 -1
- package/dist/gateways/mod.d.ts +23 -21
- package/dist/gateways/mod.d.ts.map +1 -1
- package/dist/gateways/mod.js +25 -23
- package/dist/gateways/mod.js.map +1 -1
- package/dist/internal/runtime/napi/napi.cjs +1 -1
- package/dist/internal/runtime/napi/napi.d.cts +10 -3
- package/dist/internal/runtime/shutdown.d.ts +75 -57
- package/dist/internal/runtime/shutdown.d.ts.map +1 -1
- package/dist/internal/runtime/shutdown.js +88 -84
- package/dist/internal/runtime/shutdown.js.map +1 -1
- package/dist/log/logger.d.ts +43 -37
- package/dist/log/logger.d.ts.map +1 -1
- package/dist/log/logger.js +26 -25
- package/dist/log/logger.js.map +1 -1
- package/dist/metrics/mod.d.ts +133 -114
- package/dist/metrics/mod.d.ts.map +1 -1
- package/dist/metrics/mod.js +109 -101
- package/dist/metrics/mod.js.map +1 -1
- package/dist/otel.d.ts +6 -3
- package/dist/otel.d.ts.map +1 -1
- package/dist/otel.js +6 -3
- package/dist/otel.js.map +1 -1
- package/dist/pubsub/subscription.d.ts +88 -116
- package/dist/pubsub/subscription.d.ts.map +1 -1
- package/dist/pubsub/subscription.js +14 -17
- package/dist/pubsub/subscription.js.map +1 -1
- package/dist/pubsub/topic.d.ts +86 -113
- package/dist/pubsub/topic.d.ts.map +1 -1
- package/dist/pubsub/topic.js +68 -82
- package/dist/pubsub/topic.js.map +1 -1
- package/dist/reqctx/mod.d.ts +83 -86
- package/dist/reqctx/mod.d.ts.map +1 -1
- package/dist/reqctx/mod.js +39 -41
- package/dist/reqctx/mod.js.map +1 -1
- package/dist/services/index.d.ts +76 -75
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +73 -71
- package/dist/services/index.js.map +1 -1
- package/dist/shutdown/mod.d.ts +26 -25
- package/dist/shutdown/mod.d.ts.map +1 -1
- package/dist/shutdown/mod.js +26 -25
- package/dist/shutdown/mod.js.map +1 -1
- package/dist/storage/clickhouse/database.d.ts +113 -115
- package/dist/storage/clickhouse/database.d.ts.map +1 -1
- package/dist/storage/clickhouse/database.js +65 -79
- package/dist/storage/clickhouse/database.js.map +1 -1
- package/dist/storage/clickhouse/errors.d.ts +25 -26
- package/dist/storage/clickhouse/errors.d.ts.map +1 -1
- package/dist/storage/clickhouse/errors.js +15 -17
- package/dist/storage/clickhouse/errors.js.map +1 -1
- package/dist/storage/clickhouse/mod.d.ts +10 -10
- package/dist/storage/clickhouse/mod.js +10 -10
- package/dist/storage/objects/bucket.d.ts +196 -225
- package/dist/storage/objects/bucket.d.ts.map +1 -1
- package/dist/storage/objects/bucket.js +71 -84
- package/dist/storage/objects/bucket.js.map +1 -1
- package/dist/storage/objects/error.d.ts +4 -4
- package/dist/storage/objects/error.js +4 -4
- package/dist/storage/postgres/database.d.ts +124 -149
- package/dist/storage/postgres/database.d.ts.map +1 -1
- package/dist/storage/postgres/database.js +98 -135
- package/dist/storage/postgres/database.js.map +1 -1
- package/dist/storage/postgres/errors.d.ts +42 -48
- package/dist/storage/postgres/errors.d.ts.map +1 -1
- package/dist/storage/postgres/errors.js +44 -51
- package/dist/storage/postgres/errors.js.map +1 -1
- package/dist/storage/postgres/interval.d.ts +19 -19
- package/dist/storage/postgres/interval.d.ts.map +1 -1
- package/dist/storage/postgres/interval.js +21 -21
- package/dist/storage/postgres/interval.js.map +1 -1
- package/dist/storage/redis/bitfield.d.ts +48 -23
- package/dist/storage/redis/bitfield.d.ts.map +1 -1
- package/dist/storage/redis/bitfield.js +38 -19
- package/dist/storage/redis/bitfield.js.map +1 -1
- package/dist/storage/redis/command.d.ts +16 -12
- package/dist/storage/redis/command.d.ts.map +1 -1
- package/dist/storage/redis/command.js +16 -12
- package/dist/storage/redis/command.js.map +1 -1
- package/dist/storage/redis/commands.d.ts +99 -100
- package/dist/storage/redis/commands.d.ts.map +1 -1
- package/dist/storage/redis/commands.js +84 -85
- package/dist/storage/redis/commands.js.map +1 -1
- package/dist/storage/redis/database.d.ts +138 -122
- package/dist/storage/redis/database.d.ts.map +1 -1
- package/dist/storage/redis/database.js +120 -101
- package/dist/storage/redis/database.js.map +1 -1
- package/dist/storage/redis/mod.d.ts +52 -48
- package/dist/storage/redis/mod.d.ts.map +1 -1
- package/dist/storage/redis/mod.js +52 -48
- package/dist/storage/redis/mod.js.map +1 -1
- package/dist/storage/redis/options.d.ts +26 -24
- package/dist/storage/redis/options.d.ts.map +1 -1
- package/dist/storage/redis/options.js.map +1 -1
- package/dist/storage/redis/pubsub.d.ts +16 -16
- package/dist/storage/redis/pubsub.d.ts.map +1 -1
- package/dist/storage/redis/pubsub.js +14 -14
- package/dist/storage/redis/pubsub.js.map +1 -1
- package/dist/storage/redis/reply.d.ts +80 -72
- package/dist/storage/redis/reply.d.ts.map +1 -1
- package/dist/storage/redis/reply.js +53 -46
- package/dist/storage/redis/reply.js.map +1 -1
- package/dist/storage/redis/scan.d.ts +4 -4
- package/dist/storage/redis/scan.d.ts.map +1 -1
- package/dist/storage/redis/scan.js +6 -6
- package/dist/storage/redis/scan.js.map +1 -1
- package/dist/storage/redis/script.d.ts +28 -21
- package/dist/storage/redis/script.d.ts.map +1 -1
- package/dist/storage/redis/script.js +29 -22
- package/dist/storage/redis/script.js.map +1 -1
- package/dist/storage/redis/target.d.ts +17 -1
- package/dist/storage/redis/target.d.ts.map +1 -1
- package/dist/storage/redis/target.js +30 -1
- package/dist/storage/redis/target.js.map +1 -1
- package/dist/storage/redis/wire.d.ts +6 -6
- package/dist/storage/redis/wire.d.ts.map +1 -1
- package/dist/storage/redis/wire.js +6 -6
- package/dist/storage/redis/wire.js.map +1 -1
- package/dist/testing/mod.d.ts +83 -88
- package/dist/testing/mod.d.ts.map +1 -1
- package/dist/testing/mod.js +75 -81
- package/dist/testing/mod.js.map +1 -1
- package/dist/testing/playwright.d.ts +28 -32
- package/dist/testing/playwright.d.ts.map +1 -1
- package/dist/testing/playwright.js +22 -27
- package/dist/testing/playwright.js.map +1 -1
- package/dist/testing/puppeteer.d.ts +11 -12
- package/dist/testing/puppeteer.d.ts.map +1 -1
- package/dist/testing/puppeteer.js +17 -18
- package/dist/testing/puppeteer.js.map +1 -1
- package/dist/testing/system.d.ts +72 -90
- package/dist/testing/system.d.ts.map +1 -1
- package/dist/testing/system.js +90 -107
- package/dist/testing/system.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/frontends/mod.test.ts +6 -2
- package/frontends/mod.ts +20 -19
- package/gateway/errors.ts +30 -32
- package/gateway/match.ts +61 -57
- package/gateway/middleware.ts +62 -64
- package/gateway/mod.ts +73 -76
- package/gateway/request.ts +143 -140
- package/gateway/serve.ts +58 -63
- package/gateways/mod.ts +25 -23
- package/internal/runtime/napi/napi.cjs +1 -1
- package/internal/runtime/napi/napi.d.cts +10 -3
- package/internal/runtime/shutdown.ts +113 -101
- package/log/logger.test.ts +8 -0
- package/log/logger.ts +48 -45
- package/metrics/mod.ts +138 -122
- package/otel.ts +6 -3
- package/package.json +1 -1
- package/pubsub/subscription.ts +93 -123
- package/pubsub/topic.ts +96 -130
- package/reqctx/mod.ts +83 -86
- package/services/index.ts +78 -78
- package/shutdown/mod.ts +26 -25
- package/storage/clickhouse/database.ts +115 -129
- package/storage/clickhouse/errors.ts +27 -29
- package/storage/clickhouse/mod.ts +10 -10
- package/storage/objects/bucket.ts +209 -239
- package/storage/objects/error.ts +4 -4
- package/storage/postgres/database.ts +131 -164
- package/storage/postgres/errors.ts +45 -52
- package/storage/postgres/interval.ts +21 -21
- package/storage/redis/bitfield.ts +51 -26
- package/storage/redis/command.ts +16 -12
- package/storage/redis/commands.ts +99 -100
- package/storage/redis/database.ts +145 -123
- package/storage/redis/mod.ts +52 -48
- package/storage/redis/options.ts +26 -24
- package/storage/redis/pubsub.ts +14 -14
- package/storage/redis/redis.test.ts +17 -2
- package/storage/redis/reply.ts +85 -77
- package/storage/redis/scan.ts +6 -6
- package/storage/redis/script.ts +29 -22
- package/storage/redis/target.ts +34 -1
- package/storage/redis/wire.ts +8 -8
- package/testing/mod.ts +99 -105
- package/testing/playwright.ts +32 -37
- package/testing/puppeteer.ts +22 -23
- package/testing/system.ts +117 -133
package/pubsub/subscription.ts
CHANGED
|
@@ -13,43 +13,38 @@ import * as runtime from '../internal/runtime/mod';
|
|
|
13
13
|
import {testMode, type Scope} from '../internal/testing/scope';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* A delivered
|
|
16
|
+
* A delivered Pub/Sub message along with its raw bytes and broker metadata.
|
|
17
17
|
*
|
|
18
|
-
* The handler runs
|
|
19
|
-
*
|
|
20
|
-
*
|
|
18
|
+
* The subscription handler runs inside the message's context: any spans or
|
|
19
|
+
* downstream calls continue the publisher's trace, and propagated Request
|
|
20
|
+
* Context fields (`@encore.dev/sdk/reqctx`) are available via `field.get()`.
|
|
21
21
|
*/
|
|
22
22
|
export interface Message<T = unknown> {
|
|
23
|
-
/**
|
|
23
|
+
/** Decoded payload according to the subscription's `encoding` and `decode` options. */
|
|
24
24
|
data: T;
|
|
25
|
-
/**
|
|
25
|
+
/** Original payload bytes as published. */
|
|
26
26
|
rawData: Buffer;
|
|
27
|
-
/**
|
|
28
|
-
* The unique id of the message: the one `publish` returned. It stays the
|
|
29
|
-
* same across delivery attempts.
|
|
30
|
-
*/
|
|
27
|
+
/** Unique message ID returned by `publish`; remains stable across redelivery attempts. */
|
|
31
28
|
id: string;
|
|
32
29
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* context.
|
|
30
|
+
* Message attributes set by the publisher, excluding internal `encore-ctx-*`
|
|
31
|
+
* attributes used to propagate Request Context fields.
|
|
36
32
|
*/
|
|
37
33
|
attributes: Record<string, string>;
|
|
38
|
-
/**
|
|
34
|
+
/** 1-based delivery attempt counter. */
|
|
39
35
|
deliveryAttempt: number;
|
|
40
|
-
/**
|
|
36
|
+
/** Timestamp when the message was published. */
|
|
41
37
|
publishTime: Date;
|
|
42
|
-
/**
|
|
43
|
-
* unordered one. */
|
|
38
|
+
/** Ordering key for ordered topics, or `null` for unordered topics. */
|
|
44
39
|
orderingKey: string | null;
|
|
45
40
|
}
|
|
46
41
|
|
|
47
42
|
export class Subscription<Msg> {
|
|
48
43
|
private readonly topic: Topic<Msg> | OrderedTopic<Msg>;
|
|
49
|
-
/**
|
|
44
|
+
/** Subscription name, unique within its topic. */
|
|
50
45
|
readonly name: string;
|
|
51
46
|
private readonly impl?: runtime.PubSubSubscription;
|
|
52
|
-
/**
|
|
47
|
+
/** Dispatches a delivered message to the configured handler. */
|
|
53
48
|
private readonly dispatch: (msg: Delivered) => Promise<void>;
|
|
54
49
|
|
|
55
50
|
constructor(
|
|
@@ -105,11 +100,9 @@ export class Subscription<Msg> {
|
|
|
105
100
|
}
|
|
106
101
|
|
|
107
102
|
/**
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
* fails, rejecting with its error: that message is handed over again next
|
|
112
|
-
* time, as its next attempt.
|
|
103
|
+
* Delivers pending matching messages from `scope` to this subscription in
|
|
104
|
+
* order and returns the number of messages handled. Rejects on the first
|
|
105
|
+
* handler error so that message remains pending for the next attempt.
|
|
113
106
|
*
|
|
114
107
|
* @internal
|
|
115
108
|
*/
|
|
@@ -125,9 +118,9 @@ export class Subscription<Msg> {
|
|
|
125
118
|
if (delivery === null) return handled;
|
|
126
119
|
if (handled === maxDeliveries) {
|
|
127
120
|
throw new Error(
|
|
128
|
-
`subscription ${JSON.stringify(sub.name)} handled ${maxDeliveries} messages in
|
|
129
|
-
`
|
|
130
|
-
|
|
121
|
+
`subscription ${JSON.stringify(sub.name)} handled ${maxDeliveries} messages in a ` +
|
|
122
|
+
`single deliver() call and still has more pending — check whether its handler ` +
|
|
123
|
+
`unconditionally publishes back to topic ${JSON.stringify(topic)}`,
|
|
131
124
|
);
|
|
132
125
|
}
|
|
133
126
|
const msg = delivery.message;
|
|
@@ -150,8 +143,7 @@ export class Subscription<Msg> {
|
|
|
150
143
|
}
|
|
151
144
|
}
|
|
152
145
|
|
|
153
|
-
/**
|
|
154
|
-
* published. */
|
|
146
|
+
/** Internal representation of a message delivered from the runtime or a test scope. */
|
|
155
147
|
type Delivered = Pick<
|
|
156
148
|
runtime.PubSubMessage,
|
|
157
149
|
'id' | 'data' | 'attributes' | 'deliveryAttempt' | 'publishTime'
|
|
@@ -161,9 +153,8 @@ type Delivered = Pick<
|
|
|
161
153
|
};
|
|
162
154
|
|
|
163
155
|
/**
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
* mark, with the Request Context fields the message carries.
|
|
156
|
+
* Builds the OpenTelemetry context for a subscription handler, attaching the
|
|
157
|
+
* delivery span context and any propagated Request Context fields.
|
|
167
158
|
*/
|
|
168
159
|
function handlerContext(
|
|
169
160
|
msg: Delivered,
|
|
@@ -184,15 +175,15 @@ function handlerContext(
|
|
|
184
175
|
}
|
|
185
176
|
|
|
186
177
|
/**
|
|
187
|
-
*
|
|
188
|
-
* {@link SubscriptionOptions}
|
|
178
|
+
* Configuration for creating a {@link Subscription}, combining
|
|
179
|
+
* {@link SubscriptionOptions} with payload decoding settings.
|
|
189
180
|
*
|
|
190
|
-
*
|
|
191
|
-
* `decode`
|
|
181
|
+
* Messages are JSON-decoded by default; byte subscriptions must specify
|
|
182
|
+
* `encoding: "raw"`. Provide `decode` to validate or transform parsed JSON, or
|
|
183
|
+
* to decode a custom binary format.
|
|
192
184
|
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
* by the target cloud pubsub implementation).
|
|
185
|
+
* Cloud providers may clamp configuration values (such as `ackDeadline`) to
|
|
186
|
+
* their supported ranges.
|
|
196
187
|
*/
|
|
197
188
|
export type SubscriptionConfig<Msg> = SubscriptionOptions<Msg> &
|
|
198
189
|
([Msg] extends [Uint8Array]
|
|
@@ -200,160 +191,139 @@ export type SubscriptionConfig<Msg> = SubscriptionOptions<Msg> &
|
|
|
200
191
|
: | {encoding?: 'json'; decode?: (data: unknown) => Msg}
|
|
201
192
|
| {encoding: 'raw'; decode: (data: unknown) => Msg});
|
|
202
193
|
|
|
203
|
-
/**
|
|
194
|
+
/** Subscription options other than payload decoding. */
|
|
204
195
|
export interface SubscriptionOptions<Msg> {
|
|
205
196
|
/**
|
|
206
|
-
*
|
|
207
|
-
* sent on the topic.
|
|
197
|
+
* Function invoked to process each message published to the topic.
|
|
208
198
|
*
|
|
209
|
-
*
|
|
210
|
-
* TypeScript types
|
|
199
|
+
* Receives a {@link Message} containing the decoded `data` and raw bytes in
|
|
200
|
+
* `rawData`. TypeScript types are not checked at runtime; use `decode` for
|
|
201
|
+
* runtime validation.
|
|
211
202
|
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
* attempt to be made (unless the retry policy's MaxRetries has been reached).
|
|
203
|
+
* Throwing or rejecting negatively acknowledges (nacks) the message,
|
|
204
|
+
* triggering redelivery until {@link RetryPolicy.maxRetries} is exhausted.
|
|
215
205
|
*/
|
|
216
206
|
handler: (msg: Message<Msg>) => Promise<unknown>;
|
|
217
207
|
|
|
218
208
|
/**
|
|
219
|
-
*
|
|
220
|
-
* simultaneously per instance of the service for this subscription.
|
|
221
|
-
*
|
|
222
|
-
* Note that this is per instance of the service, so if your service has
|
|
223
|
-
* scaled to 10 instances and this is set to 10, then 100 messages could be
|
|
224
|
-
* processed simultaneously.
|
|
225
|
-
*
|
|
226
|
-
* If the value is negative, then there will be no limit on the number
|
|
227
|
-
* of messages processed simultaneously.
|
|
209
|
+
* Maximum number of messages processed concurrently per service instance.
|
|
228
210
|
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
* be configured as a Push Subscription and will have an adaptive concurrency
|
|
232
|
-
* See [GCP Push Delivery Rate](https://cloud.google.com/pubsub/docs/push#push_delivery_rate).
|
|
211
|
+
* For example, setting `maxConcurrency: 10` across 10 service instances
|
|
212
|
+
* allows up to 100 concurrent messages. Negative values disable the limit.
|
|
233
213
|
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
214
|
+
* Note: Not supported on all providers — on GCP Cloud Run with unordered
|
|
215
|
+
* topics, subscriptions use Push Delivery with adaptive concurrency (see
|
|
216
|
+
* [GCP Push Delivery Rate](https://cloud.google.com/pubsub/docs/push#push_delivery_rate)).
|
|
217
|
+
* Also has no effect in Encore Cloud environments. Defaults to a
|
|
218
|
+
* provider-specific value when omitted.
|
|
236
219
|
*/
|
|
237
220
|
maxConcurrency?: number;
|
|
238
221
|
|
|
239
222
|
/**
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
* has the ack deadline.
|
|
223
|
+
* Maximum time the broker waits for acknowledgment before redelivering a
|
|
224
|
+
* message. For pulled subscriptions, Encore automatically extends the lease
|
|
225
|
+
* while the handler runs (up to 1 hour, or `ackDeadline` if longer); GCP push
|
|
226
|
+
* subscriptions are bounded by `ackDeadline`.
|
|
245
227
|
*
|
|
246
|
-
*
|
|
247
|
-
* 1 second.
|
|
228
|
+
* Defaults to 30 seconds; must be at least 1 second.
|
|
248
229
|
*/
|
|
249
230
|
ackDeadline?: DurationString;
|
|
250
231
|
|
|
251
232
|
/**
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
* Default is 7 days.
|
|
233
|
+
* How long undelivered messages are retained before being purged.
|
|
234
|
+
* Defaults to 7 days.
|
|
256
235
|
*/
|
|
257
236
|
messageRetention?: DurationString;
|
|
258
237
|
|
|
259
238
|
/**
|
|
260
|
-
*
|
|
261
|
-
*
|
|
239
|
+
* Retry policy controlling redelivery backoff and dead-lettering when the
|
|
240
|
+
* handler fails.
|
|
262
241
|
*/
|
|
263
242
|
retryPolicy?: RetryPolicy;
|
|
264
243
|
|
|
265
244
|
/**
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
*
|
|
245
|
+
* Optional attribute filter expression selecting which messages this
|
|
246
|
+
* subscription receives. Unmatched messages are never delivered. Receives all
|
|
247
|
+
* messages when omitted.
|
|
269
248
|
*
|
|
270
|
-
*
|
|
271
|
-
* which every cloud Encore deploys to can filter on:
|
|
249
|
+
* Written in a cloud-portable subset of [expr](https://expr-lang.org):
|
|
272
250
|
*
|
|
273
251
|
* ```ts
|
|
274
252
|
* filter: `attrs.region in ["eu-west-1", "eu-north-1"] and not (attrs.kind startsWith "test-")`
|
|
275
253
|
* ```
|
|
276
254
|
*
|
|
255
|
+
* Supported operators:
|
|
277
256
|
* - `attrs.region == "eu"`, `!=`, `in [...]`, `not in [...]`, and
|
|
278
|
-
* `startsWith "eu-"
|
|
279
|
-
* characters
|
|
280
|
-
* - `"region" in attrs` and `"region" not in attrs
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
* - `and` (`&&`), `or` (`||`), `not (...)` (`!(...)`) and parentheses.
|
|
257
|
+
* `startsWith "eu-"` (use `attrs["iana.org-lang"]` for attribute names
|
|
258
|
+
* containing characters outside letters, digits, and `_`).
|
|
259
|
+
* - `"region" in attrs` and `"region" not in attrs` to check attribute
|
|
260
|
+
* presence. Value checks evaluate to `false` when an attribute is missing,
|
|
261
|
+
* while negated checks evaluate to `true`.
|
|
262
|
+
* - `and` (`&&`), `or` (`||`), `not (...)` (`!(...)`), and parentheses.
|
|
284
263
|
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
264
|
+
* Must be a string literal so Encore can validate it statically against cloud
|
|
265
|
+
* provider limits.
|
|
287
266
|
*/
|
|
288
267
|
filter?: string;
|
|
289
268
|
|
|
290
269
|
/**
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
* takes none. By default the service's main process consumes it.
|
|
296
|
-
*
|
|
297
|
-
* Encore reads it from the source, so it is a string written out.
|
|
270
|
+
* Name of a worker declared in `encore.service.json` under `workers` that
|
|
271
|
+
* should consume this subscription instead of the service's main process.
|
|
272
|
+
* Only that worker processes messages for this subscription. Must be a string
|
|
273
|
+
* literal.
|
|
298
274
|
*/
|
|
299
275
|
worker?: string;
|
|
300
276
|
|
|
301
277
|
/**
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
278
|
+
* Static string-literal tags that classify the subscription for policy checks
|
|
279
|
+
* (e.g. `{data: "pci"}`). Keys and values may contain lowercase letters,
|
|
280
|
+
* digits, `_`, and `-`, up to 63 characters. Keys must start with a letter
|
|
281
|
+
* and cannot start with the reserved prefix `encore`. At most 32 tags.
|
|
306
282
|
*/
|
|
307
283
|
tags?: Record<string, string>;
|
|
308
284
|
}
|
|
309
285
|
|
|
310
286
|
/**
|
|
311
|
-
*
|
|
312
|
-
* after errors either delivering the message or processing the message.
|
|
313
|
-
*
|
|
314
|
-
* The values given to this structure are parsed at compile time, such that
|
|
315
|
-
* the correct Cloud resources can be provisioned to support the queue.
|
|
287
|
+
* Retry and dead-letter configuration for failed deliveries or handler errors.
|
|
316
288
|
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
* by the target cloud).
|
|
289
|
+
* Values are parsed statically at compile time to provision cloud resources,
|
|
290
|
+
* and may be clamped to each cloud provider's supported ranges.
|
|
320
291
|
*/
|
|
321
292
|
export interface RetryPolicy {
|
|
322
293
|
/**
|
|
323
|
-
*
|
|
294
|
+
* Minimum backoff delay between retry attempts. Defaults to 10 seconds.
|
|
324
295
|
*/
|
|
325
296
|
minBackoff?: DurationString;
|
|
326
297
|
|
|
327
298
|
/**
|
|
328
|
-
*
|
|
299
|
+
* Maximum backoff delay between retry attempts. Defaults to 10 minutes.
|
|
329
300
|
*/
|
|
330
301
|
maxBackoff?: DurationString;
|
|
331
302
|
|
|
332
303
|
/**
|
|
333
|
-
*
|
|
334
|
-
*
|
|
304
|
+
* Maximum number of retries after a handler failure before forwarding the
|
|
305
|
+
* message to the dead-letter queue. Defaults to 100.
|
|
335
306
|
*
|
|
336
|
-
* - `n >= 0`:
|
|
337
|
-
*
|
|
338
|
-
* - `-1
|
|
339
|
-
*
|
|
340
|
-
* - `-2`, {@link NoRetries}: not retried, as `0`.
|
|
307
|
+
* - `n >= 0`: retry up to `n` times (`0` disables retries and dead-letters on
|
|
308
|
+
* the first failure).
|
|
309
|
+
* - `-1` ({@link InfiniteRetries}): retry indefinitely without dead-lettering.
|
|
310
|
+
* - `-2` ({@link NoRetries}): do not retry (equivalent to `0`).
|
|
341
311
|
*
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
312
|
+
* Values below `-2` are rejected. Must be a numeric literal or one of the
|
|
313
|
+
* exported constants (`NoRetries`, `InfiniteRetries`) so Encore can parse it
|
|
314
|
+
* statically.
|
|
345
315
|
*/
|
|
346
316
|
maxRetries?: number;
|
|
347
317
|
}
|
|
348
318
|
|
|
349
319
|
/**
|
|
350
|
-
*
|
|
351
|
-
* dead-letter queue
|
|
320
|
+
* `maxRetries` value that disables retries and immediately forwards failed
|
|
321
|
+
* messages to the dead-letter queue.
|
|
352
322
|
*/
|
|
353
323
|
export const NoRetries = -2;
|
|
354
324
|
|
|
355
325
|
/**
|
|
356
|
-
*
|
|
357
|
-
*
|
|
326
|
+
* `maxRetries` value that retries failed messages indefinitely without
|
|
327
|
+
* dead-lettering.
|
|
358
328
|
*/
|
|
359
329
|
export const InfiniteRetries = -1;
|