@ref0/git 0.4.0 → 0.6.0
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/dist/access/private-refs.mjs +3 -4
- package/dist/auth/authorize.mjs +9 -4
- package/dist/auth/identify.d.mts +5 -3
- package/dist/auth/tokens.mjs +12 -11
- package/dist/client/local.mjs +2 -0
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/contracts/access.d.mts +6 -2
- package/dist/contracts/authorize.d.mts +14 -10
- package/dist/contracts/events.d.mts +32 -5
- package/dist/contracts/events.mjs +14 -3
- package/dist/contracts/git.d.mts +68 -3
- package/dist/contracts/grants.d.mts +6 -1
- package/dist/contracts/lfs.d.mts +5 -2
- package/dist/contracts/objects.d.mts +7 -2
- package/dist/contracts/promises.d.mts +2 -14
- package/dist/contracts/push-uploads.d.mts +1 -1
- package/dist/contracts/queue.d.mts +15 -7
- package/dist/contracts/refs.d.mts +1 -1
- package/dist/contracts/result.d.mts +9 -5
- package/dist/contracts/result.mjs +5 -0
- package/dist/contracts/server.d.mts +13 -6
- package/dist/contracts/work.d.mts +1 -1
- package/dist/core/access.mjs +17 -1
- package/dist/core/call-names.d.mts +3 -1
- package/dist/core/claim-rows.d.mts +4 -0
- package/dist/core/claim-rows.mjs +53 -0
- package/dist/core/events/deliver.d.mts +12 -0
- package/dist/core/events/deliver.mjs +367 -145
- package/dist/core/events/seen.mjs +17 -3
- package/dist/core/forks.mjs +82 -20
- package/dist/core/hooks/post-receive.mjs +20 -17
- package/dist/core/index-job.mjs +23 -17
- package/dist/core/parts.d.mts +6 -0
- package/dist/core/purge.d.mts +8 -0
- package/dist/core/purge.mjs +16 -21
- package/dist/core/push-decide.mjs +26 -4
- package/dist/core/push.mjs +57 -20
- package/dist/core/ref-index-job.mjs +9 -14
- package/dist/core/ref-index.d.mts +1 -0
- package/dist/core/ref-index.mjs +28 -8
- package/dist/core/ref-view.mjs +14 -9
- package/dist/core/refs.mjs +13 -11
- package/dist/core/repack.d.mts +2 -1
- package/dist/core/repack.mjs +66 -118
- package/dist/core/repos.mjs +5 -5
- package/dist/core/rules/check.mjs +7 -6
- package/dist/core/rules/context.d.mts +1 -1
- package/dist/core/seam.d.mts +56 -9
- package/dist/core/seam.mjs +7 -1
- package/dist/core/still-takes.mjs +75 -0
- package/dist/core/view.d.mts +1 -0
- package/dist/core/view.mjs +8 -9
- package/dist/core/work.mjs +1 -1
- package/dist/extend.d.mts +2 -1
- package/dist/http/core-parts.mjs +19 -11
- package/dist/http/handler.mjs +2 -2
- package/dist/http/node.d.mts +2 -23
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-uploads.d.mts +10 -2
- package/dist/http/push-uploads.mjs +31 -34
- package/dist/http/receive-pack.mjs +5 -3
- package/dist/http/upload-pack.mjs +2 -2
- package/dist/index.d.mts +11 -7
- package/dist/index.mjs +5 -3
- package/dist/lfs/base.d.mts +32 -0
- package/dist/lfs/base.mjs +8 -0
- package/dist/lfs/calls.mjs +21 -12
- package/dist/lfs/layer.d.mts +27 -0
- package/dist/lfs/layer.mjs +64 -0
- package/dist/lfs/locks.mjs +13 -27
- package/dist/lfs/namespace.d.mts +2 -0
- package/dist/lfs/objects.d.mts +23 -4
- package/dist/lfs/objects.mjs +65 -81
- package/dist/lfs/pointers.mjs +8 -6
- package/dist/lfs/public.d.mts +5 -0
- package/dist/lfs/public.mjs +8 -0
- package/dist/lfs/purge.mjs +19 -25
- package/dist/lfs/rows.mjs +22 -10
- package/dist/lfs/service.d.mts +9 -4
- package/dist/lfs/service.mjs +3 -12
- package/dist/lfs/upkeep.mjs +34 -49
- package/dist/node.d.mts +3 -2
- package/dist/node.mjs +1 -1
- package/dist/protocol/wire/advertisement.d.mts +4 -10
- package/dist/protocol/wire/advertisement.mjs +16 -12
- package/dist/protocol/wire/lines.d.mts +14 -2
- package/dist/protocol/wire/lines.mjs +32 -21
- package/dist/protocol/wire/v2.d.mts +4 -15
- package/dist/protocol/wire/v2.mjs +16 -14
- package/dist/queue/advance.mjs +78 -55
- package/dist/queue/calls.mjs +4 -2
- package/dist/queue/commit.mjs +20 -13
- package/dist/queue/host.d.mts +2 -2
- package/dist/queue/layer.d.mts +4 -2
- package/dist/queue/layer.mjs +8 -3
- package/dist/queue/limits.mjs +36 -6
- package/dist/queue/rows.mjs +14 -5
- package/dist/queue/state.mjs +19 -5
- package/dist/queue/steps.mjs +10 -4
- package/dist/queue/trim.mjs +284 -0
- package/dist/rest/blobs.d.mts +19 -19
- package/dist/rest/caller.d.mts +4 -4
- package/dist/rest/commits.d.mts +96 -96
- package/dist/rest/errors.d.mts +2 -2
- package/dist/rest/events.d.mts +2 -2
- package/dist/rest/files.d.mts +54 -54
- package/dist/rest/forks.d.mts +87 -87
- package/dist/rest/handler.mjs +13 -5
- package/dist/rest/layer.d.mts +14 -0
- package/dist/rest/layer.mjs +52 -0
- package/dist/rest/me.d.mts +2 -2
- package/dist/rest/merges.d.mts +2 -2
- package/dist/rest/namespace.d.mts +2 -0
- package/dist/rest/queue.d.mts +208 -208
- package/dist/rest/refs.d.mts +131 -131
- package/dist/rest/repos.d.mts +12 -12
- package/dist/rest/tags.d.mts +70 -70
- package/dist/rest/tokens.d.mts +23 -23
- package/dist/rest/topics.d.mts +111 -111
- package/dist/rest/trees.d.mts +57 -57
- package/dist/rest/wire.d.mts +2 -0
- package/dist/rest/wire.mjs +2 -2
- package/dist/rest/work.d.mts +6 -6
- package/dist/server/edge-node.d.mts +20 -0
- package/dist/server/edge-node.mjs +20 -0
- package/dist/server/edge.d.mts +10 -0
- package/dist/server/edge.mjs +23 -0
- package/dist/server/extension.mjs +1 -1
- package/dist/server/git-layer.d.mts +15 -4
- package/dist/server/git-layer.mjs +13 -2
- package/dist/server/git-namespace.d.mts +5 -4
- package/dist/server/git-namespace.mjs +6 -3
- package/dist/server/registry.d.mts +3 -0
- package/dist/server/registry.mjs +58 -7
- package/dist/server/server.d.mts +3 -0
- package/dist/server/server.mjs +81 -39
- package/dist/server/uploads.d.mts +14 -0
- package/dist/server/uploads.mjs +15 -0
- package/dist/storage/calls.d.mts +7 -8
- package/dist/storage/calls.mjs +14 -14
- package/dist/storage/clean-up.mjs +59 -29
- package/dist/storage/host-bucket.mjs +16 -1
- package/dist/storage/index-build.d.mts +1 -1
- package/dist/storage/layout.mjs +5 -0
- package/dist/storage/merge.d.mts +1 -1
- package/dist/storage/push-uploads.mjs +12 -16
- package/dist/storage/quarantine.d.mts +1 -1
- package/dist/storage/quarantine.mjs +51 -12
- package/dist/storage/receive-bounds.d.mts +1 -1
- package/dist/storage/repack-job.d.mts +1 -1
- package/dist/storage/repack-job.mjs +7 -14
- package/dist/storage/rows.mjs +42 -3
- package/dist/storage/runs.d.mts +1 -1
- package/dist/store/job-try.mjs +26 -0
- package/dist/store/list-job.mjs +22 -16
- package/dist/store/outbox.mjs +38 -12
- package/dist/store/promises.d.mts +6 -1
- package/dist/store/promises.mjs +74 -89
- package/dist/store/queue-jobs.mjs +22 -1
- package/dist/store/scopes.mjs +0 -10
- package/dist/sync/mirror.d.mts +1 -1
- package/dist/sync/mirror.mjs +1 -1
- package/dist/sync/publish.mjs +12 -7
- package/dist/sync/step.mjs +4 -0
- package/package.json +3 -3
- package/dist/lfs/repo.mjs +0 -42
- package/dist/storage/promise-calls.mjs +0 -29
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { decodeRow, storeCall } from "../store/errors.mjs";
|
|
2
|
+
import { madeJob } from "../store/job-try.mjs";
|
|
3
|
+
import { TrimData, trimName } from "../store/queue-jobs.mjs";
|
|
4
|
+
import { readRecord } from "../store/repo-record.mjs";
|
|
5
|
+
import { collections, jobRepo, newChangeId, repoScope } from "../store/scopes.mjs";
|
|
6
|
+
import { queueJobRetry, queueLimits } from "./limits.mjs";
|
|
7
|
+
import { CandidateRow, EntryRow, HoldRow, KeyRow, TargetRow } from "./rows.mjs";
|
|
8
|
+
import { keyRowId } from "./state.mjs";
|
|
9
|
+
import { CurrentJob, Job } from "@ref0/infra";
|
|
10
|
+
import * as Effect from "effect/Effect";
|
|
11
|
+
import * as Clock$1 from "effect/Clock";
|
|
12
|
+
// src/queue/trim.ts
|
|
13
|
+
const phases = [
|
|
14
|
+
"targets",
|
|
15
|
+
"entries",
|
|
16
|
+
"candidates",
|
|
17
|
+
"holds"
|
|
18
|
+
];
|
|
19
|
+
/** Whether a row that ended at `ended` is past `queueLimits.kept` at `now`. */
|
|
20
|
+
const past = (ended, now) => ended !== void 0 && ended + queueLimits.kept <= now;
|
|
21
|
+
const idReads = (collection, ids) => ids.map((id) => ({
|
|
22
|
+
collection,
|
|
23
|
+
id
|
|
24
|
+
}));
|
|
25
|
+
/** The rows of `results` from `results[from]` on, one each, by ID. */
|
|
26
|
+
const byId = (results, from, count) => new Map(results.slice(from, from + count).flatMap((rows) => rows.map((row) => [row.id, row])));
|
|
27
|
+
/** A page of `phase`'s rows after `after`: `undefined` once the repo is gone. */
|
|
28
|
+
const readPage = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId, collection, limit, after) {
|
|
29
|
+
const { record, snapshot } = yield* readRecord(store, internalId, [after === void 0 ? {
|
|
30
|
+
collection,
|
|
31
|
+
limit
|
|
32
|
+
} : {
|
|
33
|
+
collection,
|
|
34
|
+
limit,
|
|
35
|
+
after
|
|
36
|
+
}]);
|
|
37
|
+
if (record === void 0 || record.deleted === true) return void 0;
|
|
38
|
+
const rows = snapshot.results[1] ?? [];
|
|
39
|
+
return {
|
|
40
|
+
rows,
|
|
41
|
+
version: snapshot.version,
|
|
42
|
+
after: rows.length < limit ? void 0 : rows.at(-1)?.id
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
/** Idle targets' rows past `kept`, read and deleted at one version. */
|
|
46
|
+
const trimTargets = /* @__PURE__ */ Effect.fnUntraced(function* (rows, now) {
|
|
47
|
+
const gone = [];
|
|
48
|
+
for (const row of rows) {
|
|
49
|
+
const target = yield* decodeRow(TargetRow, row, `The queue of '${row.id}'`);
|
|
50
|
+
if (past(target.idle, now)) gone.push({
|
|
51
|
+
collection: row.collection,
|
|
52
|
+
id: row.id
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return { delete: gone };
|
|
56
|
+
});
|
|
57
|
+
/** Released holds past `kept`: no write opens one again. */
|
|
58
|
+
const trimHolds = /* @__PURE__ */ Effect.fnUntraced(function* (rows, now) {
|
|
59
|
+
const gone = [];
|
|
60
|
+
for (const row of rows) {
|
|
61
|
+
const hold = yield* decodeRow(HoldRow, row, `The hold '${row.id}'`);
|
|
62
|
+
if (hold.released === true && past(hold.ended, now)) gone.push({
|
|
63
|
+
collection: row.collection,
|
|
64
|
+
id: row.id
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return { delete: gone };
|
|
68
|
+
});
|
|
69
|
+
/** Whether `entry` ended past `kept`: merged, failed or removed, and not revived since. */
|
|
70
|
+
const endedPast = (entry, now) => (entry.state === "merged" || entry.state === "failed" || entry.state === "removed") && past(entry.ended, now);
|
|
71
|
+
/**
|
|
72
|
+
* Ended entries past `kept`, read again with their keys' rows at one version, so a revival since
|
|
73
|
+
* the page keeps its entry: each with its `meta`, and its key's row when it's the key's latest,
|
|
74
|
+
* or that row without `merged` when only its merge was.
|
|
75
|
+
*/
|
|
76
|
+
const trimEntries = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId, rows, now) {
|
|
77
|
+
const due = [];
|
|
78
|
+
const ids = [];
|
|
79
|
+
for (const row of rows) {
|
|
80
|
+
const entry = yield* decodeRow(EntryRow, row, `The queue entry '${row.id}'`);
|
|
81
|
+
if (!endedPast(entry, now)) continue;
|
|
82
|
+
due.push(entry);
|
|
83
|
+
ids.push(row.id);
|
|
84
|
+
}
|
|
85
|
+
if (ids.length === 0) return void 0;
|
|
86
|
+
const keys = [...new Set(due.map((entry) => keyRowId(entry.target, entry.key)))];
|
|
87
|
+
const reads = [...idReads(collections.queueEntries, ids), ...idReads(collections.queueKeys, keys)];
|
|
88
|
+
const { record, snapshot } = yield* readRecord(store, internalId, reads);
|
|
89
|
+
if (record === void 0 || record.deleted === true) return void 0;
|
|
90
|
+
const entries = byId(snapshot.results, 1, ids.length);
|
|
91
|
+
const keyRows = byId(snapshot.results, 1 + ids.length, keys.length);
|
|
92
|
+
const gone = /* @__PURE__ */ new Set();
|
|
93
|
+
const remove = [];
|
|
94
|
+
for (const id of ids) {
|
|
95
|
+
const row = entries.get(id);
|
|
96
|
+
if (row === void 0) continue;
|
|
97
|
+
const entry = yield* decodeRow(EntryRow, row, `The queue entry '${id}'`);
|
|
98
|
+
if (!endedPast(entry, now)) continue;
|
|
99
|
+
gone.add(id);
|
|
100
|
+
remove.push({
|
|
101
|
+
collection: collections.queueEntries,
|
|
102
|
+
id
|
|
103
|
+
});
|
|
104
|
+
if (entry.meta === true) remove.push({
|
|
105
|
+
collection: collections.queueMeta,
|
|
106
|
+
id
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
const put = [];
|
|
110
|
+
for (const [id, row] of keyRows) {
|
|
111
|
+
const key = yield* decodeRow(KeyRow, row, `The queue key '${id}'`);
|
|
112
|
+
if (gone.has(key.latest)) remove.push({
|
|
113
|
+
collection: collections.queueKeys,
|
|
114
|
+
id
|
|
115
|
+
});
|
|
116
|
+
else if (key.merged !== void 0 && gone.has(key.merged.entry)) put.push({
|
|
117
|
+
collection: collections.queueKeys,
|
|
118
|
+
id,
|
|
119
|
+
value: { latest: key.latest }
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
delete: remove,
|
|
124
|
+
put,
|
|
125
|
+
version: snapshot.version
|
|
126
|
+
};
|
|
127
|
+
});
|
|
128
|
+
/** Whether `candidate` closed past `kept`, its bisect, if it had one, ended. */
|
|
129
|
+
const closedPast = (candidate, now) => candidate.state === "closed" && candidate.search === void 0 && past(candidate.ended, now);
|
|
130
|
+
/**
|
|
131
|
+
* Closed candidates past `kept`, read again with their entries at one version, up to
|
|
132
|
+
* `candidateEntries` entries: each with its report, once none of its entries is left, so an entry
|
|
133
|
+
* waiting with the report that judged it keeps both. `after` is the last it decided on, when it
|
|
134
|
+
* left some of the page for the next try.
|
|
135
|
+
*/
|
|
136
|
+
const trimCandidates = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId, rows, now) {
|
|
137
|
+
const due = [];
|
|
138
|
+
let entryCount = 0;
|
|
139
|
+
let stopped;
|
|
140
|
+
for (const row of rows) {
|
|
141
|
+
const candidate = yield* decodeRow(CandidateRow, row, `The candidate '${row.id}'`);
|
|
142
|
+
if (!closedPast(candidate, now)) continue;
|
|
143
|
+
if (entryCount + candidate.entries.length > queueLimits.candidateEntries) {
|
|
144
|
+
stopped = due.at(-1)?.[0];
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
entryCount += candidate.entries.length;
|
|
148
|
+
due.push([row.id, candidate]);
|
|
149
|
+
}
|
|
150
|
+
if (due.length === 0) return void 0;
|
|
151
|
+
const ids = due.map(([id]) => id);
|
|
152
|
+
const entryIds = [...new Set(due.flatMap(([, candidate]) => candidate.entries))];
|
|
153
|
+
const reads = [...idReads(collections.queueCandidates, ids), ...idReads(collections.queueEntries, entryIds)];
|
|
154
|
+
const { record, snapshot } = yield* readRecord(store, internalId, reads);
|
|
155
|
+
if (record === void 0 || record.deleted === true) return void 0;
|
|
156
|
+
const candidates = byId(snapshot.results, 1, ids.length);
|
|
157
|
+
const left = byId(snapshot.results, 1 + ids.length, entryIds.length);
|
|
158
|
+
const remove = [];
|
|
159
|
+
for (const id of ids) {
|
|
160
|
+
const row = candidates.get(id);
|
|
161
|
+
if (row === void 0) continue;
|
|
162
|
+
const candidate = yield* decodeRow(CandidateRow, row, `The candidate '${id}'`);
|
|
163
|
+
if (!closedPast(candidate, now) || candidate.entries.some((entry) => left.has(entry))) continue;
|
|
164
|
+
remove.push({
|
|
165
|
+
collection: collections.queueCandidates,
|
|
166
|
+
id
|
|
167
|
+
});
|
|
168
|
+
remove.push({
|
|
169
|
+
collection: collections.queueReports,
|
|
170
|
+
id
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
delete: remove,
|
|
175
|
+
version: snapshot.version,
|
|
176
|
+
stopped
|
|
177
|
+
};
|
|
178
|
+
});
|
|
179
|
+
/** The collections a pass reads, each read for its first row at its end: one row says one is left. */
|
|
180
|
+
const firstRows = [
|
|
181
|
+
{
|
|
182
|
+
collection: collections.queueTargets,
|
|
183
|
+
limit: 1
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
collection: collections.queueEntries,
|
|
187
|
+
limit: 1
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
collection: collections.queueCandidates,
|
|
191
|
+
limit: 1
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
collection: collections.queueHolds,
|
|
195
|
+
limit: 1
|
|
196
|
+
}
|
|
197
|
+
];
|
|
198
|
+
/** Whether the repo's queues hold any row a pass reads: `false` once the repo is gone too. */
|
|
199
|
+
const rowsLeft = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId) {
|
|
200
|
+
const { record, snapshot } = yield* readRecord(store, internalId, firstRows);
|
|
201
|
+
if (record === void 0 || record.deleted === true) return false;
|
|
202
|
+
return snapshot.results.slice(1).some((rows) => rows.length > 0);
|
|
203
|
+
});
|
|
204
|
+
/**
|
|
205
|
+
* One try of `queue.trim` at `cursor`: one page of its phase, read, decided on and committed.
|
|
206
|
+
* Due again now while the pass goes on, or with the same cursor when its commit lost; a day on
|
|
207
|
+
* once a pass ends with queue rows left, and done once none are, till a target's first write
|
|
208
|
+
* saves it again.
|
|
209
|
+
*/
|
|
210
|
+
const trimStep = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId, cursor, now) {
|
|
211
|
+
const targets = cursor.phase === "targets";
|
|
212
|
+
const collection = {
|
|
213
|
+
targets: collections.queueTargets,
|
|
214
|
+
entries: collections.queueEntries,
|
|
215
|
+
candidates: collections.queueCandidates,
|
|
216
|
+
holds: collections.queueHolds
|
|
217
|
+
}[cursor.phase];
|
|
218
|
+
const limit = targets ? queueLimits.trimTargets : queueLimits.trimPage;
|
|
219
|
+
const page = yield* readPage(store, internalId, collection, limit, cursor.after);
|
|
220
|
+
if (page === void 0) return void 0;
|
|
221
|
+
let step;
|
|
222
|
+
if (cursor.phase === "targets" || cursor.phase === "holds") step = {
|
|
223
|
+
...yield* (targets ? trimTargets : trimHolds)(page.rows, now),
|
|
224
|
+
after: page.after,
|
|
225
|
+
version: page.version
|
|
226
|
+
};
|
|
227
|
+
else if (cursor.phase === "entries") {
|
|
228
|
+
const decided = yield* trimEntries(store, internalId, page.rows, now);
|
|
229
|
+
step = decided === void 0 ? void 0 : {
|
|
230
|
+
...decided,
|
|
231
|
+
after: page.after
|
|
232
|
+
};
|
|
233
|
+
} else {
|
|
234
|
+
const decided = yield* trimCandidates(store, internalId, page.rows, now);
|
|
235
|
+
const after = decided?.stopped ?? page.after;
|
|
236
|
+
step = decided === void 0 ? void 0 : {
|
|
237
|
+
...decided,
|
|
238
|
+
after
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
if (step !== void 0 && step.delete.length + (step.put?.length ?? 0) > 0) {
|
|
242
|
+
const change = {
|
|
243
|
+
id: newChangeId(),
|
|
244
|
+
expect: step.version,
|
|
245
|
+
delete: [...step.delete],
|
|
246
|
+
put: [...step.put ?? []]
|
|
247
|
+
};
|
|
248
|
+
if (!(yield* storeCall(() => store.commit(repoScope(internalId), change))).ok) return {
|
|
249
|
+
kind: "more",
|
|
250
|
+
data: cursor
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
const after = step?.after ?? page.after;
|
|
254
|
+
if (after !== void 0) return {
|
|
255
|
+
kind: "more",
|
|
256
|
+
data: {
|
|
257
|
+
phase: cursor.phase,
|
|
258
|
+
after
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
const next = phases[phases.indexOf(cursor.phase) + 1];
|
|
262
|
+
if (next !== void 0) return {
|
|
263
|
+
kind: "more",
|
|
264
|
+
data: { phase: next }
|
|
265
|
+
};
|
|
266
|
+
if (!(yield* rowsLeft(store, internalId))) return void 0;
|
|
267
|
+
return {
|
|
268
|
+
kind: "more",
|
|
269
|
+
at: now + queueLimits.sweepEvery,
|
|
270
|
+
data: { phase: "targets" }
|
|
271
|
+
};
|
|
272
|
+
});
|
|
273
|
+
const TrimJob = /* @__PURE__ */ Job.make(trimName, {
|
|
274
|
+
payload: TrimData,
|
|
275
|
+
retry: queueJobRetry
|
|
276
|
+
});
|
|
277
|
+
/**
|
|
278
|
+
* `queue.trim` over `host`, which `createGitServer` registers beside the queue's other jobs: its
|
|
279
|
+
* time is the host's clock, as the other jobs' is. A try that fails its last retry passes its
|
|
280
|
+
* failure to `onFailure`, so the host's `repo.work.failed` names it and `work.retry` runs it again:
|
|
281
|
+
* a failed job's row stays failed whatever a target's first write saves.
|
|
282
|
+
*/
|
|
283
|
+
const queueTrimJob = (host, onFailure) => madeJob(TrimJob.definition((cursor) => Effect.flatMap(Effect.all([CurrentJob.store, CurrentJob.current]), ([store, job]) => Effect.flatMap(Effect.provideContext(Clock$1.currentTimeMillis, host.needs), (now) => trimStep(store, jobRepo(job), cursor, now))), onFailure === void 0 ? {} : { onFailure }));
|
|
284
|
+
export { queueTrimJob };
|
package/dist/rest/blobs.d.mts
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import { GitCallerMiddleware, GitRestServices } from "./caller.mjs";
|
|
2
2
|
import * as Schema from "effect/Schema";
|
|
3
3
|
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/http-api";
|
|
4
|
-
declare const BlobsApiGroup_base: HttpApiGroup.HttpApiGroup<"blobs", HttpApiEndpoint.HttpApiEndpoint<"
|
|
4
|
+
declare const BlobsApiGroup_base: HttpApiGroup.HttpApiGroup<"blobs", HttpApiEndpoint.HttpApiEndpoint<"create", "POST", "/repos/:repo/-/blobs", Schema.toCodecStringTree<Schema.Struct<{
|
|
5
5
|
repo: Schema.String;
|
|
6
|
-
oid: Schema.String;
|
|
7
6
|
}>>, Schema.toCodecStringTree<Schema.Struct<{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
readonly
|
|
11
|
-
|
|
12
|
-
}>>, never, never, HttpApiSchema.WithHeaders<HttpApiSchema.StreamUint8Array, Schema.toCodecStringTree<Schema.Struct<{
|
|
13
|
-
etag: Schema.String;
|
|
14
|
-
'content-length': Schema.NumberFromString;
|
|
15
|
-
}>>>, Schema.toCodecJson<HttpApiSchema.encodeToWithHeaders<Schema.Codec<{
|
|
7
|
+
key: Schema.optionalKey<Schema.String>;
|
|
8
|
+
}>>, HttpApiSchema.StreamUint8Array, never, Schema.toCodecJson<Schema.Struct<{
|
|
9
|
+
readonly oid: Schema.String;
|
|
10
|
+
}>>, Schema.toCodecJson<HttpApiSchema.encodeToWithHeaders<Schema.Codec<{
|
|
16
11
|
readonly code: "ALREADY_EXISTS";
|
|
17
12
|
readonly message: string;
|
|
18
13
|
readonly hint?: string;
|
|
@@ -296,7 +291,7 @@ declare const BlobsApiGroup_base: HttpApiGroup.HttpApiGroup<"blobs", HttpApiEndp
|
|
|
296
291
|
readonly message: Schema.decodeTo<Schema.String, Schema.String, never, never>;
|
|
297
292
|
readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
|
|
298
293
|
readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
|
|
299
|
-
reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
|
|
294
|
+
reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
|
|
300
295
|
indexBytes: Schema.optionalKey<Schema.Number>;
|
|
301
296
|
pushBytes: Schema.optionalKey<Schema.Number>;
|
|
302
297
|
most: Schema.optionalKey<Schema.Number>;
|
|
@@ -388,7 +383,7 @@ declare const BlobsApiGroup_base: HttpApiGroup.HttpApiGroup<"blobs", HttpApiEndp
|
|
|
388
383
|
readonly message: Schema.decodeTo<Schema.String, Schema.String, never, never>;
|
|
389
384
|
readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
|
|
390
385
|
readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
|
|
391
|
-
reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
|
|
386
|
+
reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
|
|
392
387
|
indexBytes: Schema.optionalKey<Schema.Number>;
|
|
393
388
|
pushBytes: Schema.optionalKey<Schema.Number>;
|
|
394
389
|
most: Schema.optionalKey<Schema.Number>;
|
|
@@ -411,13 +406,18 @@ declare const BlobsApiGroup_base: HttpApiGroup.HttpApiGroup<"blobs", HttpApiEndp
|
|
|
411
406
|
}>, {
|
|
412
407
|
"ref0-code": Schema.String;
|
|
413
408
|
'www-authenticate': Schema.String;
|
|
414
|
-
}>>, GitCallerMiddleware, GitRestServices> | HttpApiEndpoint.HttpApiEndpoint<"
|
|
409
|
+
}>>, GitCallerMiddleware, GitRestServices> | HttpApiEndpoint.HttpApiEndpoint<"get", "GET", "/repos/:repo/-/blobs/:oid", Schema.toCodecStringTree<Schema.Struct<{
|
|
415
410
|
repo: Schema.String;
|
|
411
|
+
oid: Schema.String;
|
|
416
412
|
}>>, Schema.toCodecStringTree<Schema.Struct<{
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
readonly
|
|
420
|
-
|
|
413
|
+
readonly objects: Schema.optionalKey<Schema.Int>;
|
|
414
|
+
readonly bytes: Schema.optionalKey<Schema.Int>;
|
|
415
|
+
readonly entries: Schema.optionalKey<Schema.Int>;
|
|
416
|
+
readonly milliseconds: Schema.optionalKey<Schema.Int>;
|
|
417
|
+
}>>, never, never, HttpApiSchema.WithHeaders<HttpApiSchema.StreamUint8Array, Schema.toCodecStringTree<Schema.Struct<{
|
|
418
|
+
etag: Schema.String;
|
|
419
|
+
'content-length': Schema.NumberFromString;
|
|
420
|
+
}>>>, Schema.toCodecJson<HttpApiSchema.encodeToWithHeaders<Schema.Codec<{
|
|
421
421
|
readonly code: "ALREADY_EXISTS";
|
|
422
422
|
readonly message: string;
|
|
423
423
|
readonly hint?: string;
|
|
@@ -701,7 +701,7 @@ declare const BlobsApiGroup_base: HttpApiGroup.HttpApiGroup<"blobs", HttpApiEndp
|
|
|
701
701
|
readonly message: Schema.decodeTo<Schema.String, Schema.String, never, never>;
|
|
702
702
|
readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
|
|
703
703
|
readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
|
|
704
|
-
reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
|
|
704
|
+
reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
|
|
705
705
|
indexBytes: Schema.optionalKey<Schema.Number>;
|
|
706
706
|
pushBytes: Schema.optionalKey<Schema.Number>;
|
|
707
707
|
most: Schema.optionalKey<Schema.Number>;
|
|
@@ -793,7 +793,7 @@ declare const BlobsApiGroup_base: HttpApiGroup.HttpApiGroup<"blobs", HttpApiEndp
|
|
|
793
793
|
readonly message: Schema.decodeTo<Schema.String, Schema.String, never, never>;
|
|
794
794
|
readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
|
|
795
795
|
readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
|
|
796
|
-
reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
|
|
796
|
+
reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
|
|
797
797
|
indexBytes: Schema.optionalKey<Schema.Number>;
|
|
798
798
|
pushBytes: Schema.optionalKey<Schema.Number>;
|
|
799
799
|
most: Schema.optionalKey<Schema.Number>;
|
package/dist/rest/caller.d.mts
CHANGED
|
@@ -309,7 +309,7 @@ declare const GitCallerMiddleware_base: HttpApiMiddleware.ServiceClass<GitCaller
|
|
|
309
309
|
readonly message: import("effect/Schema").decodeTo<import("effect/Schema").String, import("effect/Schema").String, never, never>;
|
|
310
310
|
readonly hint: import("effect/Schema").optionalKey<import("effect/Schema").decodeTo<import("effect/Schema").String, import("effect/Schema").String, never, never>>;
|
|
311
311
|
readonly context: import("effect/Schema").optionalKey<import("effect/Schema").StructWithRest<import("effect/Schema").Struct<{
|
|
312
|
-
reason: import("effect/Schema").optionalKey<import("effect/Schema").Union<readonly [import("effect/Schema").Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>, import("effect/Schema").decodeTo<import("effect/Schema").String, import("effect/Schema").String, never, never>]>>;
|
|
312
|
+
reason: import("effect/Schema").optionalKey<import("effect/Schema").Union<readonly [import("effect/Schema").Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>, import("effect/Schema").decodeTo<import("effect/Schema").String, import("effect/Schema").String, never, never>]>>;
|
|
313
313
|
indexBytes: import("effect/Schema").optionalKey<import("effect/Schema").Number>;
|
|
314
314
|
pushBytes: import("effect/Schema").optionalKey<import("effect/Schema").Number>;
|
|
315
315
|
most: import("effect/Schema").optionalKey<import("effect/Schema").Number>;
|
|
@@ -401,7 +401,7 @@ declare const GitCallerMiddleware_base: HttpApiMiddleware.ServiceClass<GitCaller
|
|
|
401
401
|
readonly message: import("effect/Schema").decodeTo<import("effect/Schema").String, import("effect/Schema").String, never, never>;
|
|
402
402
|
readonly hint: import("effect/Schema").optionalKey<import("effect/Schema").decodeTo<import("effect/Schema").String, import("effect/Schema").String, never, never>>;
|
|
403
403
|
readonly context: import("effect/Schema").optionalKey<import("effect/Schema").StructWithRest<import("effect/Schema").Struct<{
|
|
404
|
-
reason: import("effect/Schema").optionalKey<import("effect/Schema").Union<readonly [import("effect/Schema").Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>, import("effect/Schema").decodeTo<import("effect/Schema").String, import("effect/Schema").String, never, never>]>>;
|
|
404
|
+
reason: import("effect/Schema").optionalKey<import("effect/Schema").Union<readonly [import("effect/Schema").Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>, import("effect/Schema").decodeTo<import("effect/Schema").String, import("effect/Schema").String, never, never>]>>;
|
|
405
405
|
indexBytes: import("effect/Schema").optionalKey<import("effect/Schema").Number>;
|
|
406
406
|
pushBytes: import("effect/Schema").optionalKey<import("effect/Schema").Number>;
|
|
407
407
|
most: import("effect/Schema").optionalKey<import("effect/Schema").Number>;
|
|
@@ -2408,7 +2408,7 @@ declare const GitCallerMiddleware_base: HttpApiMiddleware.ServiceClass<GitCaller
|
|
|
2408
2408
|
readonly message: import("effect/Schema").decodeTo<import("effect/Schema").String, import("effect/Schema").String, never, never>;
|
|
2409
2409
|
readonly hint: import("effect/Schema").optionalKey<import("effect/Schema").decodeTo<import("effect/Schema").String, import("effect/Schema").String, never, never>>;
|
|
2410
2410
|
readonly context: import("effect/Schema").optionalKey<import("effect/Schema").StructWithRest<import("effect/Schema").Struct<{
|
|
2411
|
-
reason: import("effect/Schema").optionalKey<import("effect/Schema").Union<readonly [import("effect/Schema").Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>, import("effect/Schema").decodeTo<import("effect/Schema").String, import("effect/Schema").String, never, never>]>>;
|
|
2411
|
+
reason: import("effect/Schema").optionalKey<import("effect/Schema").Union<readonly [import("effect/Schema").Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>, import("effect/Schema").decodeTo<import("effect/Schema").String, import("effect/Schema").String, never, never>]>>;
|
|
2412
2412
|
indexBytes: import("effect/Schema").optionalKey<import("effect/Schema").Number>;
|
|
2413
2413
|
pushBytes: import("effect/Schema").optionalKey<import("effect/Schema").Number>;
|
|
2414
2414
|
most: import("effect/Schema").optionalKey<import("effect/Schema").Number>;
|
|
@@ -2500,7 +2500,7 @@ declare const GitCallerMiddleware_base: HttpApiMiddleware.ServiceClass<GitCaller
|
|
|
2500
2500
|
readonly message: import("effect/Schema").decodeTo<import("effect/Schema").String, import("effect/Schema").String, never, never>;
|
|
2501
2501
|
readonly hint: import("effect/Schema").optionalKey<import("effect/Schema").decodeTo<import("effect/Schema").String, import("effect/Schema").String, never, never>>;
|
|
2502
2502
|
readonly context: import("effect/Schema").optionalKey<import("effect/Schema").StructWithRest<import("effect/Schema").Struct<{
|
|
2503
|
-
reason: import("effect/Schema").optionalKey<import("effect/Schema").Union<readonly [import("effect/Schema").Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>, import("effect/Schema").decodeTo<import("effect/Schema").String, import("effect/Schema").String, never, never>]>>;
|
|
2503
|
+
reason: import("effect/Schema").optionalKey<import("effect/Schema").Union<readonly [import("effect/Schema").Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large"]>, import("effect/Schema").decodeTo<import("effect/Schema").String, import("effect/Schema").String, never, never>]>>;
|
|
2504
2504
|
indexBytes: import("effect/Schema").optionalKey<import("effect/Schema").Number>;
|
|
2505
2505
|
pushBytes: import("effect/Schema").optionalKey<import("effect/Schema").Number>;
|
|
2506
2506
|
most: import("effect/Schema").optionalKey<import("effect/Schema").Number>;
|