@astrale-os/adapter-cloudflare 0.5.0-beta.228 → 0.5.0-beta.229
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 +2 -1
- package/dist/hosting/kv.d.ts +10 -8
- package/dist/hosting/kv.js +11 -9
- package/dist/hosting/retirement.d.ts +1 -1
- package/dist/hosting/retirement.js +3 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -127,7 +127,8 @@ Node and inside a Worker (`fetch` and WebCrypto only).
|
|
|
127
127
|
the name's labels), `cron:<name>` (canonical UTC crons). The record's metadata is mandatory: a
|
|
128
128
|
`record:<label>` without it activates nothing at the dispatcher (every path of the label answers
|
|
129
129
|
as not active yet, and no cron fires on it) and the kit refuses it (`record-invalid`) instead of
|
|
130
|
-
reading it as any record. Every write is read back before it counts
|
|
130
|
+
reading it as any record. Every write is read back before it counts, for up to 65 s: a Workers
|
|
131
|
+
KV location keeps each read it answered, a key's absence included, for 60 s after it.
|
|
131
132
|
- **Scripts.** `deploymentBindings`, `deploymentTags` (with a host's extra tags),
|
|
132
133
|
`uploadDeploymentScript` (create-only, every module kind, assets in parallel),
|
|
133
134
|
`observeScript`, `scriptSettings`, `scriptSecretNames`, `putScriptSecret`, `deleteScript`, and
|
package/dist/hosting/kv.d.ts
CHANGED
|
@@ -12,8 +12,7 @@ import type { CloudflareClient } from './client.js';
|
|
|
12
12
|
* `record:<label>` activates the label and outlives its retirement. Its metadata is mandatory: a
|
|
13
13
|
* value without it is no record the kit writes: it activates nothing at the dispatcher, and the
|
|
14
14
|
* kit refuses it (`record-invalid`). Workers KV has no compare-and-set: every write is read
|
|
15
|
-
* back before it counts
|
|
16
|
-
* `KV_READ_BACK_MS`.
|
|
15
|
+
* back before it counts, within `KV_VISIBILITY_MS`.
|
|
17
16
|
*/
|
|
18
17
|
export declare const RECORD_PREFIX = "record:";
|
|
19
18
|
export declare const RETIREMENT_PREFIX = "retirement:";
|
|
@@ -51,15 +50,18 @@ export type RoutingKvLocator = {
|
|
|
51
50
|
readonly title: string;
|
|
52
51
|
};
|
|
53
52
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* the
|
|
53
|
+
* The longest a Workers KV write or delete may stay invisible to a reader, the kit's own reads
|
|
54
|
+
* through the account API included. A location keeps each read it answers, a key's absence
|
|
55
|
+
* included, for the read's `cacheTtl`, and a change does not evict it: a reader that read the key
|
|
56
|
+
* just before the change sees the change only once that entry expires. An account API read sets
|
|
57
|
+
* no `cacheTtl` and keeps the default, 60 s, as every dispatcher read does; 5 s cover the expiry.
|
|
58
|
+
* A read back that misses a change sooner is no evidence that the change was lost.
|
|
57
59
|
*/
|
|
58
|
-
export declare const
|
|
60
|
+
export declare const KV_VISIBILITY_MS = 65000;
|
|
59
61
|
/**
|
|
60
62
|
* One routing KV, through the account API. Reads answer the stored text (undefined when absent);
|
|
61
63
|
* every write and delete is read back before it counts, and fails `unavailable` when it does not
|
|
62
|
-
* read back within `
|
|
64
|
+
* read back within `KV_VISIBILITY_MS` (or the client's deadline).
|
|
63
65
|
*/
|
|
64
66
|
export declare class RoutingKv {
|
|
65
67
|
private readonly client;
|
|
@@ -93,7 +95,7 @@ export declare class RoutingKv {
|
|
|
93
95
|
keys(prefix: string): Promise<readonly string[]>;
|
|
94
96
|
/**
|
|
95
97
|
* Read back what a write or delete at `key` left, until `kept` admits it, within
|
|
96
|
-
* `
|
|
98
|
+
* `KV_VISIBILITY_MS`; a read that fails `unavailable` is tried again too. `kept` reads through this
|
|
97
99
|
* KV on a client bounded by that budget, so no single read outlasts it.
|
|
98
100
|
*/
|
|
99
101
|
private readBack;
|
package/dist/hosting/kv.js
CHANGED
|
@@ -15,8 +15,7 @@ import { HostingRefusal } from './refusal.js';
|
|
|
15
15
|
* `record:<label>` activates the label and outlives its retirement. Its metadata is mandatory: a
|
|
16
16
|
* value without it is no record the kit writes: it activates nothing at the dispatcher, and the
|
|
17
17
|
* kit refuses it (`record-invalid`). Workers KV has no compare-and-set: every write is read
|
|
18
|
-
* back before it counts
|
|
19
|
-
* `KV_READ_BACK_MS`.
|
|
18
|
+
* back before it counts, within `KV_VISIBILITY_MS`.
|
|
20
19
|
*/
|
|
21
20
|
export const RECORD_PREFIX = 'record:';
|
|
22
21
|
export const RETIREMENT_PREFIX = 'retirement:';
|
|
@@ -89,17 +88,20 @@ export function decodeSchedules(text, name) {
|
|
|
89
88
|
return crons;
|
|
90
89
|
}
|
|
91
90
|
/**
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* the
|
|
91
|
+
* The longest a Workers KV write or delete may stay invisible to a reader, the kit's own reads
|
|
92
|
+
* through the account API included. A location keeps each read it answers, a key's absence
|
|
93
|
+
* included, for the read's `cacheTtl`, and a change does not evict it: a reader that read the key
|
|
94
|
+
* just before the change sees the change only once that entry expires. An account API read sets
|
|
95
|
+
* no `cacheTtl` and keeps the default, 60 s, as every dispatcher read does; 5 s cover the expiry.
|
|
96
|
+
* A read back that misses a change sooner is no evidence that the change was lost.
|
|
95
97
|
*/
|
|
96
|
-
export const
|
|
98
|
+
export const KV_VISIBILITY_MS = 65_000;
|
|
97
99
|
/** The most keys one page of a KV key listing returns, as Cloudflare caps it. */
|
|
98
100
|
const KEYS_PAGE = 1_000;
|
|
99
101
|
/**
|
|
100
102
|
* One routing KV, through the account API. Reads answer the stored text (undefined when absent);
|
|
101
103
|
* every write and delete is read back before it counts, and fails `unavailable` when it does not
|
|
102
|
-
* read back within `
|
|
104
|
+
* read back within `KV_VISIBILITY_MS` (or the client's deadline).
|
|
103
105
|
*/
|
|
104
106
|
export class RoutingKv {
|
|
105
107
|
client;
|
|
@@ -190,11 +192,11 @@ export class RoutingKv {
|
|
|
190
192
|
}
|
|
191
193
|
/**
|
|
192
194
|
* Read back what a write or delete at `key` left, until `kept` admits it, within
|
|
193
|
-
* `
|
|
195
|
+
* `KV_VISIBILITY_MS`; a read that fails `unavailable` is tried again too. `kept` reads through this
|
|
194
196
|
* KV on a client bounded by that budget, so no single read outlasts it.
|
|
195
197
|
*/
|
|
196
198
|
async readBack(key, effect, kept) {
|
|
197
|
-
await this.client.retryWithin(
|
|
199
|
+
await this.client.retryWithin(KV_VISIBILITY_MS, async (client) => {
|
|
198
200
|
if (!(await kept(new RoutingKv(client, this.id))))
|
|
199
201
|
notKept(key, effect);
|
|
200
202
|
});
|
|
@@ -5,7 +5,7 @@ import type { NamespaceScript } from './script.js';
|
|
|
5
5
|
import { WITHDRAWN } from './kv.js';
|
|
6
6
|
/** The dispatcher's retirement probe path; it is never a call of the deployment. */
|
|
7
7
|
export declare const RETIREMENT_PROBE_PATH = "/__services_retirement_probe__";
|
|
8
|
-
/** How long Workers KV takes to carry a tombstone to every dispatcher. */
|
|
8
|
+
/** How long Workers KV takes to carry a tombstone to every dispatcher (`KV_VISIBILITY_MS`). */
|
|
9
9
|
export declare const RETIREMENT_PROPAGATION_MS = 65000;
|
|
10
10
|
/** How long a caller waits before probing again when the dispatcher does not answer yet. */
|
|
11
11
|
export declare const RETIREMENT_PROBE_RETRY_MS = 15000;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { readRecord, readRetirement, sameRecord } from './activation.js';
|
|
2
|
-
import { retirementKey, WITHDRAWN } from './kv.js';
|
|
2
|
+
import { KV_VISIBILITY_MS, retirementKey, WITHDRAWN } from './kv.js';
|
|
3
3
|
import { deleteScript, observeScript } from './script.js';
|
|
4
4
|
/** The dispatcher's retirement probe path; it is never a call of the deployment. */
|
|
5
5
|
export const RETIREMENT_PROBE_PATH = '/__services_retirement_probe__';
|
|
6
|
-
/** How long Workers KV takes to carry a tombstone to every dispatcher. */
|
|
7
|
-
export const RETIREMENT_PROPAGATION_MS =
|
|
6
|
+
/** How long Workers KV takes to carry a tombstone to every dispatcher (`KV_VISIBILITY_MS`). */
|
|
7
|
+
export const RETIREMENT_PROPAGATION_MS = KV_VISIBILITY_MS;
|
|
8
8
|
/** How long a caller waits before probing again when the dispatcher does not answer yet. */
|
|
9
9
|
export const RETIREMENT_PROBE_RETRY_MS = 15_000;
|
|
10
10
|
const DEFAULT_PROBE_TIMEOUT_MS = 10_000;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrale-os/adapter-cloudflare",
|
|
3
|
-
"version": "0.5.0-beta.
|
|
3
|
+
"version": "0.5.0-beta.229",
|
|
4
4
|
"description": "Deploy an Astrale Domain through Cloudflare Workers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adapter",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"registry": "https://registry.npmjs.org/"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@astrale-os/sdk": "0.6.0-beta.
|
|
64
|
+
"@astrale-os/sdk": "0.6.0-beta.74",
|
|
65
65
|
"@noble/hashes": "2.3.0",
|
|
66
66
|
"@restatedev/restate-sdk-cloudflare-workers": "1.17.0",
|
|
67
67
|
"hono": "^4.13.11",
|