@lunora/container 1.0.0-alpha.4 → 1.0.0-alpha.6
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 +25 -1
- package/dist/bridge.d.mts +3 -3
- package/dist/bridge.d.ts +3 -3
- package/dist/bridge.mjs +10 -7
- package/dist/do/index.d.mts +518 -4
- package/dist/do/index.d.ts +518 -4
- package/dist/do/index.mjs +77 -5
- package/dist/index.d.mts +45 -18
- package/dist/index.d.ts +45 -18
- package/dist/index.mjs +2 -2
- package/dist/packem_shared/ContainerProxy-DWqUX_re.mjs +1474 -0
- package/dist/packem_shared/{containerBindingName-C7Lic2ET.mjs → containerBindingName-D5KTrblH.mjs} +19 -1
- package/dist/packem_shared/{createContainerContext-DBp8oJOr.mjs → createContainerContext-Cibbh7AE.mjs} +92 -22
- package/dist/packem_shared/{types.d-DAOLRiZQ.d.mts → types.d-BlNwNY44.d.mts} +17 -1
- package/dist/packem_shared/{types.d-DAOLRiZQ.d.ts → types.d-BlNwNY44.d.ts} +17 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type { B as BuildImageSource, c as ContainerInstanceType, d as ContainerReadinessCheck, e as ContainerRollout, f as CustomContainerInstanceType, g as NamedContainerInstanceType, R as RegistryImageSource } from "./packem_shared/types.d-
|
|
3
|
-
/**
|
|
4
|
-
* The `ctx.containers` action surface: typed handles over the `CONTAINER_*`
|
|
5
|
-
* Durable Object namespace bindings the config layer reconciles.
|
|
6
|
-
*
|
|
7
|
-
* Deliberately structural (no `@cloudflare/containers` import): a Durable
|
|
8
|
-
* Object namespace stub is all that is needed to route a request to a
|
|
9
|
-
* container-enabled DO, so this module stays Node-safe and the test double
|
|
10
|
-
* below can satisfy the exact same shape without a workerd runtime.
|
|
11
|
-
*/
|
|
1
|
+
import { C as ContainerConfig, a as ContainerDefinition, b as ContainerImageSource, N as NormalizedContainerImage } from "./packem_shared/types.d-BlNwNY44.mjs";
|
|
2
|
+
export type { B as BuildImageSource, c as ContainerInstanceType, d as ContainerReadinessCheck, e as ContainerRollout, f as CustomContainerInstanceType, g as NamedContainerInstanceType, R as RegistryImageSource } from "./packem_shared/types.d-BlNwNY44.mjs";
|
|
12
3
|
/** Options for explicitly starting an instance (mirrors `@cloudflare/containers`). */
|
|
13
4
|
interface ContainerStartOptions {
|
|
14
5
|
/** Override outbound internet access for this start. */
|
|
@@ -101,9 +92,12 @@ interface ContainerInstanceHandle extends ContainerHandle {
|
|
|
101
92
|
getState: () => Promise<ContainerInstanceState>;
|
|
102
93
|
/**
|
|
103
94
|
* Reset the instance's `sleepAfter` idle timer. The platform renews it on
|
|
104
|
-
* each request
|
|
105
|
-
*
|
|
106
|
-
*
|
|
95
|
+
* each proxied request, and because `@lunora/container` proxies WebSocket
|
|
96
|
+
* frames through the Durable Object, message traffic on an open socket
|
|
97
|
+
* renews it too (the WebSocket-keepalive gap of cloudflare/containers#147 is
|
|
98
|
+
* closed in the bundled base). This manual control is the escape hatch for
|
|
99
|
+
* keeping a container awake during activity that is neither an HTTP request
|
|
100
|
+
* nor a WS message — e.g. a long out-of-band job running inside it.
|
|
107
101
|
*/
|
|
108
102
|
renewActivityTimeout: () => Promise<void>;
|
|
109
103
|
/** Explicitly start the instance, optionally with per-instance env/entrypoint. */
|
|
@@ -137,10 +131,25 @@ interface ContainerAccessor {
|
|
|
137
131
|
* A random instance from a fixed pool of `count` (defaults to the
|
|
138
132
|
* definition's `maxInstances`, else 3 — mirroring `getRandom` from
|
|
139
133
|
* `@cloudflare/containers`). For stateless, interchangeable workloads.
|
|
134
|
+
*
|
|
135
|
+
* Like `.get()`, a path/URL-string fetch transparently retries the
|
|
136
|
+
* cold-start "instance is provisioning" transients (cloudflare/containers#45,
|
|
137
|
+
* #139); pass {@link InstanceRetryOptions} to tune or disable it.
|
|
140
138
|
*/
|
|
141
|
-
any: (count?: number) => ContainerHandle;
|
|
142
|
-
/**
|
|
143
|
-
|
|
139
|
+
any: (count?: number, options?: InstanceRetryOptions) => ContainerHandle;
|
|
140
|
+
/**
|
|
141
|
+
* The instance for `name` — one container per entity (user, room, job…),
|
|
142
|
+
* with lifecycle control.
|
|
143
|
+
*
|
|
144
|
+
* A path/URL-string fetch transparently retries the platform's cold-start
|
|
145
|
+
* transients — "there is no Container instance available" / "container is
|
|
146
|
+
* not listening" while an instance is still provisioning
|
|
147
|
+
* (cloudflare/containers#45, #139) — on the *same* instance with backoff,
|
|
148
|
+
* since the request never reached the app. Pass {@link InstanceRetryOptions}
|
|
149
|
+
* to tune attempts/backoff or disable it (`{ attempts: 1 }`). A pre-built
|
|
150
|
+
* `Request` (possibly a one-shot stream body) is sent once, never retried.
|
|
151
|
+
*/
|
|
152
|
+
get: (name: string, options?: InstanceRetryOptions) => ContainerInstanceHandle;
|
|
144
153
|
/**
|
|
145
154
|
* A resilient handle over the pool: each `fetch` picks a random instance and,
|
|
146
155
|
* on a thrown error or a retryable response (5xx by default), retries on a
|
|
@@ -177,6 +186,24 @@ interface PoolOptions {
|
|
|
177
186
|
/** Pool size to spread picks across. Defaults to the definition's `maxInstances`, else 3. */
|
|
178
187
|
size?: number;
|
|
179
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Tuning for the cold-start retry on a `.get()`/`.any()` handle. The retry fires
|
|
191
|
+
* only on the platform's provisioning transients (no-instance / not-listening /
|
|
192
|
+
* rate-limited — see {@link isColdStartTransient}), which is why it's safe by
|
|
193
|
+
* default: those responses mean the request never reached the container.
|
|
194
|
+
*/
|
|
195
|
+
interface InstanceRetryOptions {
|
|
196
|
+
/**
|
|
197
|
+
* Total attempts on a cold-start transient before the last outcome is
|
|
198
|
+
* surfaced as-is. `1` disables the retry. Default
|
|
199
|
+
* {@link DEFAULT_COLD_START_ATTEMPTS}.
|
|
200
|
+
*/
|
|
201
|
+
attempts?: number;
|
|
202
|
+
/** Base backoff in ms between attempts; doubles each retry (0 disables the wait). Default {@link DEFAULT_COLD_START_BACKOFF_MS}. */
|
|
203
|
+
backoffMs?: number;
|
|
204
|
+
/** Upper bound on a single backoff sleep, in ms. Default {@link DEFAULT_MAX_BACKOFF_MS} (30s). */
|
|
205
|
+
maxBackoffMs?: number;
|
|
206
|
+
}
|
|
180
207
|
/** Wiring info for one definition, emitted by codegen into the generated DO. */
|
|
181
208
|
interface ContainerBindingSpec {
|
|
182
209
|
/** Durable Object binding name, e.g. `CONTAINER_TRANSCODER`. */
|
|
@@ -253,4 +280,4 @@ declare const isContainerDefinition: (value: unknown) => value is ContainerDefin
|
|
|
253
280
|
* credential it was promised yields far worse errors downstream.
|
|
254
281
|
*/
|
|
255
282
|
declare const resolveContainerEnvVariables: (definition: ContainerDefinition, workerEnv: Record<string, unknown>, exportName?: string) => Record<string, string>;
|
|
256
|
-
export { type ContainerAccessor, type ContainerBindingSpec, type ContainerConfig, type ContainerDefinition, type ContainerEgressControls, type ContainerHandle, type ContainerImageSource, type ContainerInstanceHandle, type ContainerInstanceState, type ContainerNamespaceLike, type ContainerStartOptions, type ContainerTestHandler, type DurableObjectJurisdiction, type NormalizedContainerImage, type PoolOptions, containerBindingName, containerBuildTag, containerClassName, createContainerContext, createContainerTestContext, defineContainer, isContainerDefinition, normalizeContainerImage, resolveContainerEnvVariables as resolveContainerEnvVars };
|
|
283
|
+
export { type ContainerAccessor, type ContainerBindingSpec, type ContainerConfig, type ContainerDefinition, type ContainerEgressControls, type ContainerHandle, type ContainerImageSource, type ContainerInstanceHandle, type ContainerInstanceState, type ContainerNamespaceLike, type ContainerStartOptions, type ContainerTestHandler, type DurableObjectJurisdiction, type InstanceRetryOptions, type NormalizedContainerImage, type PoolOptions, containerBindingName, containerBuildTag, containerClassName, createContainerContext, createContainerTestContext, defineContainer, isContainerDefinition, normalizeContainerImage, resolveContainerEnvVariables as resolveContainerEnvVars };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type { B as BuildImageSource, c as ContainerInstanceType, d as ContainerReadinessCheck, e as ContainerRollout, f as CustomContainerInstanceType, g as NamedContainerInstanceType, R as RegistryImageSource } from "./packem_shared/types.d-
|
|
3
|
-
/**
|
|
4
|
-
* The `ctx.containers` action surface: typed handles over the `CONTAINER_*`
|
|
5
|
-
* Durable Object namespace bindings the config layer reconciles.
|
|
6
|
-
*
|
|
7
|
-
* Deliberately structural (no `@cloudflare/containers` import): a Durable
|
|
8
|
-
* Object namespace stub is all that is needed to route a request to a
|
|
9
|
-
* container-enabled DO, so this module stays Node-safe and the test double
|
|
10
|
-
* below can satisfy the exact same shape without a workerd runtime.
|
|
11
|
-
*/
|
|
1
|
+
import { C as ContainerConfig, a as ContainerDefinition, b as ContainerImageSource, N as NormalizedContainerImage } from "./packem_shared/types.d-BlNwNY44.js";
|
|
2
|
+
export type { B as BuildImageSource, c as ContainerInstanceType, d as ContainerReadinessCheck, e as ContainerRollout, f as CustomContainerInstanceType, g as NamedContainerInstanceType, R as RegistryImageSource } from "./packem_shared/types.d-BlNwNY44.js";
|
|
12
3
|
/** Options for explicitly starting an instance (mirrors `@cloudflare/containers`). */
|
|
13
4
|
interface ContainerStartOptions {
|
|
14
5
|
/** Override outbound internet access for this start. */
|
|
@@ -101,9 +92,12 @@ interface ContainerInstanceHandle extends ContainerHandle {
|
|
|
101
92
|
getState: () => Promise<ContainerInstanceState>;
|
|
102
93
|
/**
|
|
103
94
|
* Reset the instance's `sleepAfter` idle timer. The platform renews it on
|
|
104
|
-
* each request
|
|
105
|
-
*
|
|
106
|
-
*
|
|
95
|
+
* each proxied request, and because `@lunora/container` proxies WebSocket
|
|
96
|
+
* frames through the Durable Object, message traffic on an open socket
|
|
97
|
+
* renews it too (the WebSocket-keepalive gap of cloudflare/containers#147 is
|
|
98
|
+
* closed in the bundled base). This manual control is the escape hatch for
|
|
99
|
+
* keeping a container awake during activity that is neither an HTTP request
|
|
100
|
+
* nor a WS message — e.g. a long out-of-band job running inside it.
|
|
107
101
|
*/
|
|
108
102
|
renewActivityTimeout: () => Promise<void>;
|
|
109
103
|
/** Explicitly start the instance, optionally with per-instance env/entrypoint. */
|
|
@@ -137,10 +131,25 @@ interface ContainerAccessor {
|
|
|
137
131
|
* A random instance from a fixed pool of `count` (defaults to the
|
|
138
132
|
* definition's `maxInstances`, else 3 — mirroring `getRandom` from
|
|
139
133
|
* `@cloudflare/containers`). For stateless, interchangeable workloads.
|
|
134
|
+
*
|
|
135
|
+
* Like `.get()`, a path/URL-string fetch transparently retries the
|
|
136
|
+
* cold-start "instance is provisioning" transients (cloudflare/containers#45,
|
|
137
|
+
* #139); pass {@link InstanceRetryOptions} to tune or disable it.
|
|
140
138
|
*/
|
|
141
|
-
any: (count?: number) => ContainerHandle;
|
|
142
|
-
/**
|
|
143
|
-
|
|
139
|
+
any: (count?: number, options?: InstanceRetryOptions) => ContainerHandle;
|
|
140
|
+
/**
|
|
141
|
+
* The instance for `name` — one container per entity (user, room, job…),
|
|
142
|
+
* with lifecycle control.
|
|
143
|
+
*
|
|
144
|
+
* A path/URL-string fetch transparently retries the platform's cold-start
|
|
145
|
+
* transients — "there is no Container instance available" / "container is
|
|
146
|
+
* not listening" while an instance is still provisioning
|
|
147
|
+
* (cloudflare/containers#45, #139) — on the *same* instance with backoff,
|
|
148
|
+
* since the request never reached the app. Pass {@link InstanceRetryOptions}
|
|
149
|
+
* to tune attempts/backoff or disable it (`{ attempts: 1 }`). A pre-built
|
|
150
|
+
* `Request` (possibly a one-shot stream body) is sent once, never retried.
|
|
151
|
+
*/
|
|
152
|
+
get: (name: string, options?: InstanceRetryOptions) => ContainerInstanceHandle;
|
|
144
153
|
/**
|
|
145
154
|
* A resilient handle over the pool: each `fetch` picks a random instance and,
|
|
146
155
|
* on a thrown error or a retryable response (5xx by default), retries on a
|
|
@@ -177,6 +186,24 @@ interface PoolOptions {
|
|
|
177
186
|
/** Pool size to spread picks across. Defaults to the definition's `maxInstances`, else 3. */
|
|
178
187
|
size?: number;
|
|
179
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Tuning for the cold-start retry on a `.get()`/`.any()` handle. The retry fires
|
|
191
|
+
* only on the platform's provisioning transients (no-instance / not-listening /
|
|
192
|
+
* rate-limited — see {@link isColdStartTransient}), which is why it's safe by
|
|
193
|
+
* default: those responses mean the request never reached the container.
|
|
194
|
+
*/
|
|
195
|
+
interface InstanceRetryOptions {
|
|
196
|
+
/**
|
|
197
|
+
* Total attempts on a cold-start transient before the last outcome is
|
|
198
|
+
* surfaced as-is. `1` disables the retry. Default
|
|
199
|
+
* {@link DEFAULT_COLD_START_ATTEMPTS}.
|
|
200
|
+
*/
|
|
201
|
+
attempts?: number;
|
|
202
|
+
/** Base backoff in ms between attempts; doubles each retry (0 disables the wait). Default {@link DEFAULT_COLD_START_BACKOFF_MS}. */
|
|
203
|
+
backoffMs?: number;
|
|
204
|
+
/** Upper bound on a single backoff sleep, in ms. Default {@link DEFAULT_MAX_BACKOFF_MS} (30s). */
|
|
205
|
+
maxBackoffMs?: number;
|
|
206
|
+
}
|
|
180
207
|
/** Wiring info for one definition, emitted by codegen into the generated DO. */
|
|
181
208
|
interface ContainerBindingSpec {
|
|
182
209
|
/** Durable Object binding name, e.g. `CONTAINER_TRANSCODER`. */
|
|
@@ -253,4 +280,4 @@ declare const isContainerDefinition: (value: unknown) => value is ContainerDefin
|
|
|
253
280
|
* credential it was promised yields far worse errors downstream.
|
|
254
281
|
*/
|
|
255
282
|
declare const resolveContainerEnvVariables: (definition: ContainerDefinition, workerEnv: Record<string, unknown>, exportName?: string) => Record<string, string>;
|
|
256
|
-
export { type ContainerAccessor, type ContainerBindingSpec, type ContainerConfig, type ContainerDefinition, type ContainerEgressControls, type ContainerHandle, type ContainerImageSource, type ContainerInstanceHandle, type ContainerInstanceState, type ContainerNamespaceLike, type ContainerStartOptions, type ContainerTestHandler, type DurableObjectJurisdiction, type NormalizedContainerImage, type PoolOptions, containerBindingName, containerBuildTag, containerClassName, createContainerContext, createContainerTestContext, defineContainer, isContainerDefinition, normalizeContainerImage, resolveContainerEnvVariables as resolveContainerEnvVars };
|
|
283
|
+
export { type ContainerAccessor, type ContainerBindingSpec, type ContainerConfig, type ContainerDefinition, type ContainerEgressControls, type ContainerHandle, type ContainerImageSource, type ContainerInstanceHandle, type ContainerInstanceState, type ContainerNamespaceLike, type ContainerStartOptions, type ContainerTestHandler, type DurableObjectJurisdiction, type InstanceRetryOptions, type NormalizedContainerImage, type PoolOptions, containerBindingName, containerBuildTag, containerClassName, createContainerContext, createContainerTestContext, defineContainer, isContainerDefinition, normalizeContainerImage, resolveContainerEnvVariables as resolveContainerEnvVars };
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { createContainerContext, createContainerTestContext } from './packem_shared/createContainerContext-
|
|
2
|
-
export { containerBindingName, containerBuildTag, containerClassName, defineContainer, isContainerDefinition, normalizeContainerImage, resolveContainerEnvVars } from './packem_shared/containerBindingName-
|
|
1
|
+
export { createContainerContext, createContainerTestContext } from './packem_shared/createContainerContext-Cibbh7AE.mjs';
|
|
2
|
+
export { containerBindingName, containerBuildTag, containerClassName, defineContainer, isContainerDefinition, normalizeContainerImage, resolveContainerEnvVars } from './packem_shared/containerBindingName-D5KTrblH.mjs';
|