@ref0/git 0.12.0 → 0.14.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 -3
- package/dist/auth/auth.d.mts +2 -2
- package/dist/auth/auth.mjs +3 -6
- package/dist/auth/authorize.mjs +1 -17
- package/dist/auth/helpers.mjs +3 -11
- package/dist/auth/host-services.mjs +11 -0
- package/dist/auth/policy.d.mts +27 -7
- package/dist/auth/policy.mjs +8 -4
- package/dist/auth/tokens-layer.d.mts +1 -2
- package/dist/auth/tokens-layer.mjs +2 -3
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens.d.mts +1 -8
- package/dist/auth/tokens.mjs +1 -8
- package/dist/auth.d.mts +1 -4
- package/dist/auth.mjs +1 -3
- package/dist/client/git-http.mjs +18 -4
- package/dist/client/push-upload.mjs +33 -7
- package/dist/client/remote.mjs +94 -28
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/contracts/access.d.mts +8 -8
- package/dist/contracts/actors.d.mts +2 -34
- package/dist/contracts/blobs.d.mts +2 -2
- package/dist/contracts/client.d.mts +8 -3
- package/dist/contracts/commits.d.mts +10 -2
- package/dist/contracts/commits.mjs +9 -1
- package/dist/contracts/files.d.mts +2 -2
- package/dist/contracts/forks.d.mts +11 -1
- package/dist/contracts/git.d.mts +18 -7
- package/dist/contracts/git.mjs +3 -2
- package/dist/contracts/lfs.d.mts +0 -7
- package/dist/contracts/objects.d.mts +80 -10
- package/dist/contracts/operations.d.mts +3 -0
- package/dist/contracts/operations.mjs +12 -2
- package/dist/contracts/push-uploads.d.mts +44 -5
- package/dist/contracts/push-uploads.mjs +7 -3
- package/dist/contracts/refs.d.mts +28 -6
- package/dist/contracts/remote.mjs +1 -3
- package/dist/contracts/repo-records.d.mts +1 -0
- package/dist/contracts/repos.d.mts +90 -2
- package/dist/contracts/repos.mjs +29 -2
- package/dist/contracts/result.d.mts +23 -18
- package/dist/contracts/result.mjs +17 -4
- package/dist/contracts/rules.d.mts +22 -22
- package/dist/contracts/server.d.mts +28 -77
- package/dist/contracts/signin.d.mts +1 -1
- package/dist/contracts/sync.d.mts +79 -19
- package/dist/contracts/sync.mjs +34 -10
- package/dist/contracts/tokens.d.mts +1 -6
- package/dist/contracts/tokens.mjs +1 -2
- package/dist/contracts/topics.d.mts +0 -5
- package/dist/contracts/work.d.mts +66 -2
- package/dist/contracts/work.mjs +8 -1
- package/dist/core/access.mjs +27 -5
- package/dist/core/ancestry.d.mts +9 -0
- package/dist/core/ancestry.mjs +6 -6
- package/dist/core/asked.mjs +42 -4
- package/dist/core/call-names.mjs +1 -0
- package/dist/core/call-services.mjs +2 -1
- package/dist/core/events/deliver.mjs +10 -2
- package/dist/core/forks.mjs +3 -3
- package/dist/core/imports.mjs +147 -9
- package/dist/core/index-job.mjs +9 -6
- package/dist/core/job-view.mjs +8 -9
- package/dist/core/mirror-rows.mjs +19 -4
- package/dist/core/objects/commits.mjs +16 -6
- package/dist/core/parts.d.mts +6 -1
- package/dist/core/parts.mjs +1 -4
- package/dist/core/purge.mjs +76 -6
- package/dist/core/push-decide.mjs +1 -1
- package/dist/core/push-files.d.mts +12 -0
- package/dist/core/push-files.mjs +225 -0
- package/dist/core/push-repo.d.mts +8 -0
- package/dist/core/push-repo.mjs +56 -0
- package/dist/core/push.d.mts +17 -0
- package/dist/core/push.mjs +98 -26
- package/dist/core/receipts.mjs +26 -10
- package/dist/core/ref-view.mjs +59 -5
- package/dist/core/refs.mjs +13 -8
- package/dist/core/repack.mjs +11 -8
- package/dist/core/repo-info.mjs +16 -9
- package/dist/core/repos.mjs +30 -14
- package/dist/core/seam.mjs +2 -2
- package/dist/core/view.d.mts +6 -0
- package/dist/core/view.mjs +45 -12
- package/dist/core/work.mjs +47 -22
- package/dist/effect.d.mts +3 -1
- package/dist/effect.mjs +3 -1
- package/dist/engine/reads.mjs +13 -6
- package/dist/engine/walk.mjs +4 -4
- package/dist/event-streams/event-streams.d.mts +1 -1
- package/dist/event-streams/event-streams.mjs +1 -1
- package/dist/event-streams/stream.d.mts +1 -1
- package/dist/event-streams/stream.mjs +1 -1
- package/dist/extend.d.mts +3 -3
- package/dist/extend.mjs +2 -2
- package/dist/http/answers.mjs +4 -2
- package/dist/http/core-parts.mjs +64 -15
- package/dist/http/handler.mjs +2 -2
- package/dist/http/node.mjs +5 -4
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-upload-job.mjs +503 -0
- package/dist/http/push-uploads.d.mts +1 -0
- package/dist/http/push-uploads.mjs +114 -56
- package/dist/http/upload-pack.mjs +7 -6
- package/dist/index.d.mts +23 -24
- package/dist/index.mjs +4 -7
- package/dist/lfs/base.d.mts +7 -3
- package/dist/lfs/base.mjs +2 -1
- package/dist/lfs/copy.d.mts +46 -0
- package/dist/lfs/copy.mjs +26 -0
- package/dist/lfs/layer.mjs +4 -2
- package/dist/lfs/objects.d.mts +6 -0
- package/dist/lfs/objects.mjs +68 -41
- package/dist/lfs/rows.d.mts +13 -0
- package/dist/lfs/service.d.mts +1 -7
- package/dist/lfs/service.mjs +1 -9
- package/dist/lfs/upload-most.mjs +5 -5
- package/dist/node.d.mts +2 -2
- package/dist/protocol/bytes/sha256-hasher.d.mts +15 -0
- package/dist/protocol/bytes/sha256.d.mts +32 -0
- package/dist/protocol/bytes/sha256.mjs +105 -49
- package/dist/protocol/wire/advertisement.mjs +9 -4
- package/dist/protocol/wire/lines.d.mts +4 -2
- package/dist/protocol/wire/lines.mjs +11 -5
- package/dist/protocol/wire/push-uploads.mjs +13 -1
- package/dist/protocol/wire/v2.mjs +2 -2
- package/dist/protocol.d.mts +3 -1
- package/dist/protocol.mjs +3 -1
- package/dist/queue/advance.mjs +1 -1
- package/dist/queue/host.d.mts +1 -7
- package/dist/queue/host.mjs +1 -7
- package/dist/queue/layer.mjs +1 -1
- package/dist/queue/trim.mjs +1 -1
- package/dist/rest/blobs.d.mts +31 -23
- package/dist/rest/blobs.mjs +1 -1
- package/dist/rest/caller.d.mts +49 -9
- package/dist/rest/caller.mjs +1 -1
- package/dist/rest/client.d.mts +10 -3
- package/dist/rest/client.mjs +4 -0
- package/dist/rest/commits.d.mts +273 -240
- package/dist/rest/errors.d.mts +24 -4
- package/dist/rest/events.d.mts +9 -6
- package/dist/rest/events.mjs +1 -2
- package/dist/rest/files.d.mts +127 -115
- package/dist/rest/forks.d.mts +121 -97
- package/dist/rest/handler.mjs +4 -57
- package/dist/rest/handlers.d.mts +1 -1
- package/dist/rest/handlers.mjs +18 -4
- package/dist/rest/layer.mjs +2 -1
- package/dist/rest/me.d.mts +8 -4
- package/dist/rest/merges.d.mts +8 -4
- package/dist/rest/paths.mjs +1 -0
- package/dist/rest/queue.d.mts +282 -226
- package/dist/rest/refs.d.mts +205 -176
- package/dist/rest/repos.d.mts +108 -80
- package/dist/rest/tags.d.mts +24 -12
- package/dist/rest/tokens.d.mts +235 -211
- package/dist/rest/topics.d.mts +53 -33
- package/dist/rest/trees.d.mts +105 -89
- package/dist/rest/work.d.mts +467 -20
- package/dist/rest/work.mjs +8 -0
- package/dist/server/edge-node.d.mts +9 -13
- package/dist/server/edge-node.mjs +9 -12
- package/dist/server/git-layer.d.mts +1 -6
- package/dist/server/git-layer.mjs +2 -2
- package/dist/server/git-namespace.d.mts +3 -3
- package/dist/server/joined.d.mts +15 -22
- package/dist/server/joined.mjs +5 -29
- package/dist/server/lifecycle.mjs +107 -23
- package/dist/server/registry.mjs +9 -1
- package/dist/server/server.mjs +133 -212
- package/dist/storage/budget.mjs +2 -2
- package/dist/storage/clean-up.mjs +13 -10
- package/dist/storage/fetch.mjs +13 -8
- package/dist/storage/file-limits.mjs +24 -0
- package/dist/storage/index-build.d.mts +1 -0
- package/dist/storage/index-build.mjs +106 -62
- package/dist/storage/index-fetch.mjs +16 -3
- package/dist/storage/index-reach.mjs +33 -5
- package/dist/storage/index-remap.mjs +8 -1
- package/dist/storage/index-shallow.mjs +5 -3
- package/dist/storage/largest-files.mjs +48 -0
- package/dist/storage/lfs-pointers.mjs +10 -1
- package/dist/storage/loose.mjs +3 -1
- package/dist/storage/memory-budget.mjs +28 -4
- package/dist/storage/pack-reads.mjs +8 -8
- package/dist/storage/pack-receive.mjs +83 -25
- package/dist/storage/packs.mjs +37 -21
- package/dist/storage/prune-keep.mjs +203 -34
- package/dist/storage/prune-walk.mjs +54 -16
- package/dist/storage/prune.mjs +629 -196
- package/dist/storage/push-uploads.mjs +36 -12
- package/dist/storage/quarantine.mjs +9 -9
- package/dist/storage/ready.mjs +47 -19
- package/dist/storage/receive-bounds.mjs +29 -8
- package/dist/storage/receive-state.mjs +8 -0
- package/dist/storage/receive-steps.mjs +71 -18
- package/dist/storage/repack.d.mts +1 -1
- package/dist/storage/repack.mjs +1 -8
- package/dist/storage/rows.mjs +12 -1
- package/dist/storage/shallow.d.mts +1 -0
- package/dist/storage/shallow.mjs +26 -4
- package/dist/storage/stream-whole.mjs +5 -2
- package/dist/storage/visible.mjs +29 -1
- package/dist/storage/walk.mjs +2 -1
- package/dist/store/catalogue.mjs +1 -0
- package/dist/store/cursor-seal-namespace.d.mts +2 -0
- package/dist/store/cursor-seal-public.d.mts +5 -0
- package/dist/store/cursor-seal-public.mjs +5 -0
- package/dist/store/cursor-seal.d.mts +16 -2
- package/dist/store/cursor-seal.mjs +26 -14
- package/dist/store/errors.mjs +9 -1
- package/dist/store/records.d.mts +2 -0
- package/dist/store/records.mjs +9 -6
- package/dist/store/repo-record.d.mts +9 -7
- package/dist/store/repo-record.mjs +102 -19
- package/dist/store/scopes.mjs +10 -2
- package/dist/sync/bound.d.mts +2 -0
- package/dist/sync/bound.mjs +11 -2
- package/dist/sync/github.d.mts +6 -1
- package/dist/sync/github.mjs +55 -43
- package/dist/sync/http.mjs +36 -1
- package/dist/sync/import.mjs +1 -0
- package/dist/sync/layer.mjs +6 -2
- package/dist/sync/lfs-batch.mjs +119 -0
- package/dist/sync/lfs-copy.mjs +251 -0
- package/dist/sync/mirror.mjs +210 -137
- package/dist/sync/smart-http.mjs +4 -2
- package/dist/sync/step.mjs +25 -5
- package/dist/sync/tries.mjs +45 -14
- package/dist/sync.d.mts +2 -2
- package/dist/topics/host.mjs +1 -19
- package/dist/topics/layer.mjs +1 -1
- package/package.json +3 -8
- package/dist/auth/bridge.mjs +0 -30
- package/dist/auth/helpers.d.mts +0 -17
- package/dist/core/purge.d.mts +0 -8
- package/dist/core/registered-rows.d.mts +0 -5
- package/dist/core/repack.d.mts +0 -11
- package/dist/http/handler.d.mts +0 -2
- package/dist/rest/handler.d.mts +0 -21
- package/dist/rest.d.mts +0 -2
- package/dist/rest.mjs +0 -1
- package/dist/server/registry.d.mts +0 -16
- package/dist/server/server.d.mts +0 -36
- package/dist/storage/repack-job.d.mts +0 -3
- package/dist/topics/host.d.mts +0 -7
package/dist/server/server.mjs
CHANGED
|
@@ -2,14 +2,12 @@ import { PrivateRefs } from "../contracts/access.mjs";
|
|
|
2
2
|
import { pushRefLimitOf } from "../core/push-decide.mjs";
|
|
3
3
|
import { millis } from "../contracts/promises.mjs";
|
|
4
4
|
import { fail } from "../contracts/result.mjs";
|
|
5
|
-
import { Tokens } from "../contracts/tokens.mjs";
|
|
6
5
|
import { Authorize } from "../contracts/authorize.mjs";
|
|
7
6
|
import { RepoRecords } from "../contracts/repo-records.mjs";
|
|
8
|
-
import {
|
|
7
|
+
import { host } from "../contracts/git.mjs";
|
|
9
8
|
import { Refs } from "../contracts/refs.mjs";
|
|
10
9
|
import { Rules } from "../contracts/rules.mjs";
|
|
11
10
|
import { accessOf, audienceOf, authorizer } from "../auth/authorize.mjs";
|
|
12
|
-
import { authOf, policyOf } from "../auth/bridge.mjs";
|
|
13
11
|
import { grantFences } from "../auth/fences.mjs";
|
|
14
12
|
import { grantAgain, heldGrants } from "../auth/grants.mjs";
|
|
15
13
|
import { identifier } from "../auth/identify.mjs";
|
|
@@ -21,6 +19,7 @@ import { fileCalls } from "../core/objects/files.mjs";
|
|
|
21
19
|
import { mergeCalls } from "../core/objects/merges.mjs";
|
|
22
20
|
import { tagCalls } from "../core/objects/tags.mjs";
|
|
23
21
|
import { treeCalls } from "../core/objects/trees.mjs";
|
|
22
|
+
import { acting } from "../core/access.mjs";
|
|
24
23
|
import { refIndexOf } from "../core/ref-index.mjs";
|
|
25
24
|
import { callNames } from "../core/call-names.mjs";
|
|
26
25
|
import { clocksOf } from "../core/clock.mjs";
|
|
@@ -38,27 +37,23 @@ import { refIndexJob, refIndexJobRow } from "../core/ref-index-job.mjs";
|
|
|
38
37
|
import { forkCalls } from "../core/forks.mjs";
|
|
39
38
|
import { repoCalls } from "../core/repos.mjs";
|
|
40
39
|
import { EventStreams } from "../event-streams/event-streams.mjs";
|
|
41
|
-
import { MergeParts } from "../core/merge-parts.mjs";
|
|
42
40
|
import { streamsOver } from "../event-streams/stream.mjs";
|
|
43
41
|
import { attachParts, renamedTo, seamAuthorize } from "../core/seam.mjs";
|
|
44
|
-
import { checkFetchOver } from "./check-fetch.mjs";
|
|
45
42
|
import { tokenCallsAs } from "../core/tokens.mjs";
|
|
46
43
|
import { workCalls } from "../core/work.mjs";
|
|
47
44
|
import { coreHttpParts } from "../http/core-parts.mjs";
|
|
48
45
|
import { refusal } from "../http/answers.mjs";
|
|
49
46
|
import { LfsBase } from "../lfs/base.mjs";
|
|
50
|
-
import { UploadsBase
|
|
47
|
+
import { UploadsBase } from "./uploads.mjs";
|
|
51
48
|
import { lfsCalls } from "../lfs/calls.mjs";
|
|
52
|
-
import { lfsRegistration } from "../lfs/layer.mjs";
|
|
53
49
|
import { gitHttp } from "../http/handler.mjs";
|
|
54
50
|
import { gitUrlOf, normalBase } from "../http/paths.mjs";
|
|
51
|
+
import { pushUploadJob } from "../http/push-upload-job.mjs";
|
|
55
52
|
import { pushUploads } from "../http/push-uploads.mjs";
|
|
56
|
-
import { signInRegistration } from "../signin/layer.mjs";
|
|
57
|
-
import { signInPaths } from "../signin/wire.mjs";
|
|
58
53
|
import { hostRecordOf, pinOf } from "../store/catalogue.mjs";
|
|
59
54
|
import { answerOf } from "../contracts/calls-spent.mjs";
|
|
60
55
|
import { closedError } from "../store/closed.mjs";
|
|
61
|
-
import { clientWentAway
|
|
56
|
+
import { clientWentAway } from "../store/errors.mjs";
|
|
62
57
|
import { cursorSeal } from "../store/cursor-seal.mjs";
|
|
63
58
|
import { gitStore } from "../store/git-store.mjs";
|
|
64
59
|
import { doorBucket, doorLinks, doorRecords, doorUploads, promisesClock, promisesQueue, promisesStore } from "../store/promises.mjs";
|
|
@@ -67,30 +62,27 @@ import { countedBucket } from "../storage/counted-bucket.mjs";
|
|
|
67
62
|
import { hostFailures, hostLinks, hostUploads } from "../storage/host-bucket.mjs";
|
|
68
63
|
import { pushUploadUpkeep } from "../storage/push-uploads.mjs";
|
|
69
64
|
import { checkedLimits, countedMost, hookCallsBefore, lessBefore, noScope } from "../store/call-count.mjs";
|
|
70
|
-
import {
|
|
65
|
+
import { jobLimitsOf, jobsWithin } from "../store/job-try.mjs";
|
|
71
66
|
import { exitOn, noCall, syncIn, uncounted } from "../store/crossing.mjs";
|
|
72
67
|
import { pruneFloor } from "../storage/rows.mjs";
|
|
73
|
-
import { queueJobs } from "../queue/advance.mjs";
|
|
74
68
|
import { entryAdderOf, queueCalls } from "../queue/calls.mjs";
|
|
75
|
-
import { QueueBase
|
|
69
|
+
import { QueueBase } from "../queue/host.mjs";
|
|
76
70
|
import { queuePush } from "../queue/push-option.mjs";
|
|
77
|
-
import {
|
|
78
|
-
import { topicsOptions } from "../topics/host.mjs";
|
|
79
|
-
import { TopicsBase, topicsRegistration } from "../topics/layer.mjs";
|
|
80
|
-
import { MergeQueue } from "../contracts/queue.mjs";
|
|
81
|
-
import { queueService } from "../queue/layer.mjs";
|
|
71
|
+
import { TopicsBase } from "../topics/layer.mjs";
|
|
82
72
|
import { listJob } from "../store/list-job.mjs";
|
|
83
73
|
import { openExtensions } from "./extension.mjs";
|
|
84
|
-
import {
|
|
85
|
-
import { bridgeRefusal, serverLife, throughDoor, unavailable } from "./lifecycle.mjs";
|
|
74
|
+
import { attachJoins } from "./joined.mjs";
|
|
75
|
+
import { afterFailure, bridgeRefusal, refusedNow, serverLife, throughDoor, unavailable } from "./lifecycle.mjs";
|
|
86
76
|
import { aroundCalls, callOrMissing, guardedCalls, heldGroup, lazyGroups, providedCalls, signalOf } from "../core/promise.mjs";
|
|
87
|
-
import { CoreParts, ObjectsParts, QueueParts, SyncBase
|
|
77
|
+
import { CoreParts, ObjectsParts, QueueParts, SyncBase } from "../core/parts.mjs";
|
|
88
78
|
import { SavedCallers, savedCallersOf } from "../core/saved-caller-views.mjs";
|
|
89
79
|
import { withAudienceMemo } from "../core/ref-view.mjs";
|
|
90
80
|
import { Changes } from "../core/changes.mjs";
|
|
91
81
|
import { changes } from "../core/rules/changes.mjs";
|
|
92
82
|
import { SealedObjects, View, objectsOverViews, viewOver } from "../core/view.mjs";
|
|
93
83
|
import { IndexedStorage, Objects, Storage } from "../core/objects/objects.mjs";
|
|
84
|
+
import { pushFilesOf } from "../core/push-files.mjs";
|
|
85
|
+
import { pushRepoOf } from "../core/push-repo.mjs";
|
|
94
86
|
import * as Clock$1 from "effect/Clock";
|
|
95
87
|
import * as Effect from "effect/Effect";
|
|
96
88
|
import * as Option from "effect/Option";
|
|
@@ -124,78 +116,33 @@ const fetchLimitsOf = (given) => {
|
|
|
124
116
|
milliseconds: given.milliseconds
|
|
125
117
|
};
|
|
126
118
|
};
|
|
127
|
-
/** `factory`'s objects, as they keep their index: `
|
|
119
|
+
/** `factory`'s objects, as they keep their index: `access` is read only over them. */
|
|
128
120
|
const indexedOpen = (factory, input) => factory.open(input);
|
|
129
121
|
/** `most` as a count's bound: each kind it leaves out unbound. */
|
|
130
122
|
const boundOf = (most) => ({
|
|
131
123
|
bucket: most?.bucket ?? Number.POSITIVE_INFINITY,
|
|
132
124
|
subrequests: most?.subrequests ?? Number.POSITIVE_INFINITY
|
|
133
125
|
});
|
|
134
|
-
/** A build's failure as the legacy server's `Error`, until `createGitServer` is removed in 2c. */
|
|
135
|
-
const legacyError = (error) => new Error(error.message, { cause: error });
|
|
136
126
|
/** The server's wiring, in its runtime: built once, with the runtime. */
|
|
137
127
|
const Wired = /* @__PURE__ */ Context.Service("@ref0/git/server/Wired");
|
|
138
128
|
/**
|
|
139
|
-
* The groups a face names: every group
|
|
140
|
-
* unless `tokensOn`, and `queue` unless `queueOn
|
|
129
|
+
* The groups a face names: every group less `topics`, which is the `Topics` service's, `tokens`
|
|
130
|
+
* unless `tokensOn`, and `queue` unless `queueOn`.
|
|
141
131
|
*/
|
|
142
|
-
const namesOf = (
|
|
132
|
+
const namesOf = (tokensOn, queueOn) => {
|
|
143
133
|
const names = { ...callNames };
|
|
134
|
+
delete names.topics;
|
|
144
135
|
if (!tokensOn) delete names.tokens;
|
|
145
|
-
if (!queueOn
|
|
146
|
-
if (optional.topics === void 0) delete names.topics;
|
|
136
|
+
if (!queueOn) delete names.queue;
|
|
147
137
|
return names;
|
|
148
138
|
};
|
|
149
|
-
/** `Merges`' part over the one `loaded` makes: each call waits on that load, which runs once. */
|
|
150
|
-
const partsOnce = (loaded) => {
|
|
151
|
-
const parts = Effect.map(loaded, (context) => Context.get(context, MergeParts));
|
|
152
|
-
return {
|
|
153
|
-
mergeTrees: (read, input, allot, call, roots) => Effect.flatMap(parts, (one) => one.mergeTrees(read, input, allot, call, roots)),
|
|
154
|
-
lineDiff: (allot) => Effect.flatMap(parts, (one) => one.lineDiff(allot))
|
|
155
|
-
};
|
|
156
|
-
};
|
|
157
|
-
/**
|
|
158
|
-
* `createGitServer`'s options onto the Layers that replace them, run once its wiring is built and
|
|
159
|
-
* before the seal, in one list: core's inputs first, then the features, `lfs` building
|
|
160
|
-
* `Lfs.layer()`, `topics` `Topics.layer` and `pushes.upload` `Git.layerUploads`. 2c-3b deletes
|
|
161
|
-
* it, with `createGitServer`.
|
|
162
|
-
*/
|
|
163
|
-
const bridged = (setup) => ({
|
|
164
|
-
inputs: setup.access === void 0 ? Layer.empty : Layer.succeed(PrivateRefs, setup.access),
|
|
165
|
-
features: Effect.fnUntraced(function* (services, registry) {
|
|
166
|
-
if (setup.lfs !== void 0) {
|
|
167
|
-
const registration = yield* registry.register({ name: "lfs" });
|
|
168
|
-
yield* Effect.provideContext(lfsRegistration(registration, setup.lfs), services);
|
|
169
|
-
}
|
|
170
|
-
if (setup.topics !== void 0) {
|
|
171
|
-
const registration = yield* registry.register({
|
|
172
|
-
name: "topics",
|
|
173
|
-
scopes: ["git/topic/", "git/topics"]
|
|
174
|
-
});
|
|
175
|
-
const queue = Context.getOrUndefined(services, QueueInternals);
|
|
176
|
-
if (queue === void 0) return yield* Effect.die(/* @__PURE__ */ new Error("The topics bridge requires a queue"));
|
|
177
|
-
yield* Effect.provideContext(topicsRegistration(registration, topicsOptions(setup.topics)).pipe(Effect.provideService(QueueInternals, queue), Effect.provideService(MergeQueue, queueService(queue))), services);
|
|
178
|
-
}
|
|
179
|
-
if (setup.signIn !== void 0) {
|
|
180
|
-
const registration = yield* registry.register({
|
|
181
|
-
name: "signin",
|
|
182
|
-
scopes: ["git/signin"]
|
|
183
|
-
});
|
|
184
|
-
yield* Effect.provideContext(signInRegistration(registration, setup.signIn), services);
|
|
185
|
-
}
|
|
186
|
-
const upload = setup.pushes?.upload;
|
|
187
|
-
if (upload !== void 0 && Context.get(services, UploadsBase).staging !== void 0) yield* Effect.provideContext(attachUploads(upload), services);
|
|
188
|
-
})
|
|
189
|
-
});
|
|
190
139
|
/** Git's own wiring over the adapter's services, as the runtime's build runs it. */
|
|
191
140
|
const wireServer = (options, wiring) => {
|
|
192
|
-
const { adapter,
|
|
141
|
+
const { adapter, fetchLimits, files, repo, deciders, grants, extensions, guard, through, closing } = wiring;
|
|
193
142
|
const runtimeClock = wiring.clock;
|
|
194
|
-
const queueOf = optional.queue;
|
|
195
143
|
const { store, jobs, records: rawRecords } = adapter;
|
|
196
144
|
const { clock, now } = clocksOf(adapter.clock);
|
|
197
145
|
const counted = adapter.bucket === void 0 ? void 0 : countedBucket(adapter.bucket);
|
|
198
|
-
if (options.lfs !== void 0 && counted === void 0) throw new TypeError("lfs() keeps its objects in the adapter's bucket: give the adapter a bucket");
|
|
199
146
|
const callLimits = lessBefore(checkedLimits(adapter.callLimits, "The adapter's callLimits."));
|
|
200
147
|
const jobLimits = jobLimitsOf(adapter.callLimits);
|
|
201
148
|
const opening = {
|
|
@@ -241,7 +188,8 @@ const wireServer = (options, wiring) => {
|
|
|
241
188
|
now,
|
|
242
189
|
fetchLimits,
|
|
243
190
|
parts: [registry.purge],
|
|
244
|
-
scopes: registry.repoScopes
|
|
191
|
+
scopes: registry.repoScopes,
|
|
192
|
+
deliveries: events.deliveries
|
|
245
193
|
});
|
|
246
194
|
const own = [
|
|
247
195
|
listJob,
|
|
@@ -314,11 +262,12 @@ const wireServer = (options, wiring) => {
|
|
|
314
262
|
});
|
|
315
263
|
const stored = Context.make(Storage, objects).pipe(Context.add(ObjectsParts, {
|
|
316
264
|
objects: sealed,
|
|
317
|
-
fetchLimits
|
|
265
|
+
fetchLimits,
|
|
266
|
+
files,
|
|
267
|
+
repo
|
|
318
268
|
}), Context.add(Objects, objectsOverViews), Context.add(Changes, changes));
|
|
319
269
|
const base = Context.make(CoreParts, parts).pipe(Context.add(Rules, wiring.rules), Context.merge(indexed === void 0 ? stored : Context.add(stored, IndexedStorage, indexed)), Context.add(QueueParts, { jobs }), Context.add(Authorize, decider), Context.add(Clock$1.Clock, runtimeClock), Context.merge(wiring.logging));
|
|
320
|
-
const
|
|
321
|
-
const viewed = Context.add(merging, View, viewOver(merging));
|
|
270
|
+
const viewed = Context.add(base, View, viewOver(base));
|
|
322
271
|
const needs = Context.add(viewed, Refs, providedCalls(refsCalls, viewed));
|
|
323
272
|
const streams = streamsOver({
|
|
324
273
|
clock,
|
|
@@ -326,15 +275,7 @@ const wireServer = (options, wiring) => {
|
|
|
326
275
|
closing,
|
|
327
276
|
through
|
|
328
277
|
}, needs);
|
|
329
|
-
const queueHost = queueOf === void 0 ? void 0 : {
|
|
330
|
-
needs,
|
|
331
|
-
records: rawRecords,
|
|
332
|
-
options: queueOf,
|
|
333
|
-
keys: wiring.optional.queueKeys,
|
|
334
|
-
buildMilliseconds: buildMillisecondsOf(adapter.requestLimits.cpuMs)
|
|
335
|
-
};
|
|
336
278
|
const queueHeld = wiring.queue;
|
|
337
|
-
queueHeld.host = queueHost;
|
|
338
279
|
const queueBase = QueueBase.of({
|
|
339
280
|
records: rawRecords,
|
|
340
281
|
needs,
|
|
@@ -356,28 +297,38 @@ const wireServer = (options, wiring) => {
|
|
|
356
297
|
if (lfsAttached !== void 0) return Effect.die(/* @__PURE__ */ new TypeError("The server has Git LFS: provide Lfs.layer once"));
|
|
357
298
|
lfsAttached = lfs;
|
|
358
299
|
return registry.addCheck(lfs.check);
|
|
359
|
-
})
|
|
300
|
+
}),
|
|
301
|
+
copy: Effect.sync(() => lfsAttached?.copy)
|
|
360
302
|
});
|
|
361
303
|
const { uploads } = adapter;
|
|
362
304
|
const staging = counted === void 0 || uploads === void 0 ? void 0 : {
|
|
363
305
|
bucket: counted,
|
|
364
306
|
uploads
|
|
365
307
|
};
|
|
308
|
+
let httpParts;
|
|
309
|
+
const stepping = staging !== void 0 && objects.stage !== void 0 && objects.receiveStep !== void 0;
|
|
310
|
+
if (stepping) {
|
|
311
|
+
const stepJobs = [pushUploadJob({
|
|
312
|
+
...staging,
|
|
313
|
+
needs,
|
|
314
|
+
cpuMs: adapter.requestLimits.cpuMs,
|
|
315
|
+
http: () => {
|
|
316
|
+
if (httpParts === void 0) throw new TypeError("A push upload landed before its server was built");
|
|
317
|
+
return httpParts;
|
|
318
|
+
}
|
|
319
|
+
})];
|
|
320
|
+
gits.knowJobs(stepJobs);
|
|
321
|
+
jobs.register(...jobsWithin(jobLimits, stepJobs));
|
|
322
|
+
}
|
|
366
323
|
let uploadsAttached;
|
|
367
324
|
const uploadsBase = UploadsBase.of({
|
|
368
325
|
staging,
|
|
369
326
|
attach: (above) => Effect.suspend(() => {
|
|
370
327
|
if (staging === void 0 || uploadsAttached !== void 0) return Effect.die(/* @__PURE__ */ new TypeError("The server takes push uploads: provide Git.layerUploads once"));
|
|
371
|
-
uploadsAttached = pushUploads(needs, staging, above);
|
|
328
|
+
uploadsAttached = pushUploads(needs, staging, above, adapter.requestLimits.cpuMs);
|
|
372
329
|
return Effect.void;
|
|
373
330
|
})
|
|
374
331
|
});
|
|
375
|
-
if (queueHost !== void 0) {
|
|
376
|
-
registry.bridge("queue", "refs/queue/");
|
|
377
|
-
const queueJobList = queueJobs(queueHost, onFailure).map((job) => job(gitJob));
|
|
378
|
-
gits.knowJobs(queueJobList);
|
|
379
|
-
jobs.register(...jobsWithin(jobLimits, queueJobList));
|
|
380
|
-
}
|
|
381
332
|
let topicsAttached;
|
|
382
333
|
const topicsBase = TopicsBase.of({ attach: (service) => Effect.sync(() => {
|
|
383
334
|
topicsAttached = service;
|
|
@@ -402,15 +353,6 @@ const wireServer = (options, wiring) => {
|
|
|
402
353
|
refuse: (error) => refusal(error, true)
|
|
403
354
|
})
|
|
404
355
|
});
|
|
405
|
-
if (optional.tokens !== void 0) {
|
|
406
|
-
registry.bridge("tokens");
|
|
407
|
-
tokensHeld.calls = tokenCalls({
|
|
408
|
-
store,
|
|
409
|
-
now,
|
|
410
|
-
cleanup,
|
|
411
|
-
events
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
356
|
const identify = identifier({
|
|
415
357
|
store,
|
|
416
358
|
tokens: () => tokensHeld.calls !== void 0,
|
|
@@ -424,15 +366,12 @@ const wireServer = (options, wiring) => {
|
|
|
424
366
|
pushRefsMost: pushRefLimitOf(refIndex),
|
|
425
367
|
through: wiring.through
|
|
426
368
|
}), Context.add(SavedCallers, savedCallersOf(needs, entryAdderOf)), Context.add(LfsBase, lfsBase), Context.add(UploadsBase, uploadsBase), Context.add(TopicsBase, topicsBase), Context.add(TokensBase, tokensBase));
|
|
427
|
-
const
|
|
428
|
-
const withTokens = tokensHeld.calls === void 0 ? queuedServices : Context.add(queuedServices, Tokens, tokensHeld.calls);
|
|
429
|
-
const streamed = Context.add(withTokens, EventStreams, { feed: streams.feed });
|
|
430
|
-
const services = merges === void 0 ? streamed : Context.merge(streamed, merges);
|
|
369
|
+
const services = Context.add(decided, EventStreams, { feed: streams.feed });
|
|
431
370
|
/**
|
|
432
371
|
* Every group of the server's calls deciding for `bound`, over `needs`: the one list `callsAs`
|
|
433
372
|
* and `hostCalls` both build from, so a group added to one is in the other. `Git.host`'s are host
|
|
434
|
-
* code's, as `asHost` says. An optional group is there
|
|
435
|
-
*
|
|
373
|
+
* code's, as `asHost` says. An optional group is there once its feature attached, as
|
|
374
|
+
* `tokensHeld` and `queueHeld` hold it.
|
|
436
375
|
*/
|
|
437
376
|
const groupsOf = (bound) => {
|
|
438
377
|
const over = (calls) => aroundCalls(calls, (effect) => Effect.provideContext(acting(bound, effect), needs));
|
|
@@ -490,8 +429,9 @@ const wireServer = (options, wiring) => {
|
|
|
490
429
|
httpOptions.calls = before(fetchHooks)(countedMost(objects) ?? callLimits);
|
|
491
430
|
httpOptions.pushCalls = before(0)(callLimits);
|
|
492
431
|
httpOptions.lfs = () => lfsAttached?.service;
|
|
493
|
-
httpOptions.uploads = () => uploadsAttached;
|
|
494
|
-
|
|
432
|
+
httpOptions.uploads = () => stepping ? uploadsAttached : void 0;
|
|
433
|
+
httpParts = coreHttpParts(served, httpOptions);
|
|
434
|
+
const http = gitHttp(httpParts);
|
|
495
435
|
return {
|
|
496
436
|
parts: served,
|
|
497
437
|
adapter: {
|
|
@@ -515,43 +455,19 @@ const wireServer = (options, wiring) => {
|
|
|
515
455
|
};
|
|
516
456
|
};
|
|
517
457
|
/** Whether `adapter` is several Layers. */
|
|
518
|
-
const signInPathSet = new Set(Object.values(signInPaths));
|
|
519
458
|
const isLayers = (adapter) => Array.isArray(adapter);
|
|
520
459
|
/**
|
|
521
|
-
*
|
|
522
|
-
*
|
|
523
|
-
* runtime builds the adapter's Layers and Git's wiring once the tick that made it ends, which
|
|
524
|
-
* registers Git's jobs on the adapter's queue, and never runs them: the host starts them.
|
|
460
|
+
* The server `Git.layer` builds on: its wiring builds over `options`, and `Git.layer` seals its
|
|
461
|
+
* registry once its features have registered, after this build.
|
|
525
462
|
*/
|
|
526
|
-
const
|
|
527
|
-
policy: policyOf(options.authorize),
|
|
528
|
-
auth: authOf(options.auth)
|
|
529
|
-
}));
|
|
530
|
-
/**
|
|
531
|
-
* `createGitServer` deciding with `decidersOf`'s answer, which it asks once as the server builds:
|
|
532
|
-
* `createGitServer` gives its options' hooks. Internal: no entry exports it, so a host
|
|
533
|
-
* gives a `Policy` only through `Git.layer`.
|
|
534
|
-
*/
|
|
535
|
-
const serverWith = (options, decidersOf, features) => openServer(options, decidersOf, "build", features).server;
|
|
536
|
-
/**
|
|
537
|
-
* `serverWith`, sealing as its build ends, or `later`, when `Git.layer` seals once its features
|
|
538
|
-
* have registered, after this build.
|
|
539
|
-
*/
|
|
540
|
-
const openServer = (options, decidersOf, sealing, features) => {
|
|
463
|
+
const openServer = (options, decidersOf) => {
|
|
541
464
|
const setup = options;
|
|
542
|
-
const bridges = bridged(setup);
|
|
543
|
-
if (setup.signIn !== void 0 && setup.tokens === void 0) throw new TypeError("signIn mints tokens: pass tokens() too");
|
|
544
|
-
if (setup.access !== void 0 && setup.objects.indexed !== true) throw new TypeError("access hides refs, which needs objects that follow them: pass packs()");
|
|
545
|
-
const queueOf = setup.queue === void 0 ? void 0 : queueOptions(setup.queue);
|
|
546
|
-
const listed = (setup.rules ?? []).filter((rule) => !Effect.isEffect(rule) && rule.kind === "push");
|
|
547
|
-
if (queueOf === void 0 && sealing === "build") servedSources(listed);
|
|
548
|
-
if (setup.topics !== void 0 && queueOf === void 0) throw new TypeError("topics merge through each repo’s queue: pass queue too");
|
|
549
|
-
if (queueOf !== void 0 && setup.xdiff === void 0) throw new TypeError("the merge queue merges trees: pass xdiff too");
|
|
550
465
|
const fetchLimits = fetchLimitsOf(setup.fetchLimits);
|
|
466
|
+
const files = pushFilesOf(setup.pushes?.files);
|
|
467
|
+
const repo = pushRepoOf(setup.pushes?.repo);
|
|
551
468
|
const grants = heldGrants();
|
|
552
469
|
const basePath = normalBase(setup.basePath ?? "");
|
|
553
470
|
const extensions = openExtensions(basePath);
|
|
554
|
-
const joins = [];
|
|
555
471
|
const life = serverLife();
|
|
556
472
|
const isClosed = () => life.admit("call") === "closed";
|
|
557
473
|
const guard = Effect.suspend(() => isClosed() ? Effect.die(closedError()) : Effect.void);
|
|
@@ -561,17 +477,11 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
561
477
|
};
|
|
562
478
|
const through = throughDoor(life);
|
|
563
479
|
const closingWith = (signal) => signal === void 0 ? life.closing : AbortSignal.any([signal, life.closing]);
|
|
564
|
-
const optional = {
|
|
565
|
-
queue: queueOf,
|
|
566
|
-
queueKeys: setup.queue === void 0 ? void 0 : queueKeysOf(setup.queue),
|
|
567
|
-
topics: setup.topics,
|
|
568
|
-
tokens: setup.tokens
|
|
569
|
-
};
|
|
570
480
|
const tokensHeld = { calls: void 0 };
|
|
571
481
|
const queueHeld = { host: void 0 };
|
|
572
|
-
const names = namesOf(
|
|
573
|
-
const joinedNames = namesOf(
|
|
574
|
-
const queueOn = () =>
|
|
482
|
+
const names = namesOf(false, false);
|
|
483
|
+
const joinedNames = namesOf(true, true);
|
|
484
|
+
const queueOn = () => queueHeld.host !== void 0;
|
|
575
485
|
const joinedCall = (calls, group, name) => callOrMissing(calls, group, name, () => Effect.fail(noTokens));
|
|
576
486
|
const runCall = async (effect, crossing, signal) => {
|
|
577
487
|
if (isClosed()) throw closedError();
|
|
@@ -586,10 +496,7 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
586
496
|
const register = registerLater;
|
|
587
497
|
const check = checkLater;
|
|
588
498
|
if (register === void 0 || check === void 0) return Effect.die(/* @__PURE__ */ new Error("Git's registry seals after the server's build"));
|
|
589
|
-
return Effect.flatMap(extensions.registry.seal(), (jobs) => Effect.sync(() =>
|
|
590
|
-
check();
|
|
591
|
-
register(jobs);
|
|
592
|
-
}));
|
|
499
|
+
return Effect.flatMap(extensions.registry.seal(), (jobs) => Effect.sync(check).pipe(Effect.andThen(Effect.all(extensions.registry.sealChecks(), { discard: true })), Effect.andThen(Effect.sync(() => register(jobs)))));
|
|
593
500
|
});
|
|
594
501
|
const wiring = Layer.effectContext(Effect.gen(function* () {
|
|
595
502
|
const records = yield* Records.Records;
|
|
@@ -601,10 +508,6 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
601
508
|
const uploads = yield* Effect.serviceOption(BucketUploads.BucketUploads);
|
|
602
509
|
const clock = yield* Effect.clockWith(Effect.succeed);
|
|
603
510
|
const logging = Context.make(References.CurrentLoggers, yield* References.CurrentLoggers).pipe(Context.add(References.MinimumLogLevel, yield* References.MinimumLogLevel));
|
|
604
|
-
const xdiff = setup.xdiff;
|
|
605
|
-
const loaded = xdiff === void 0 ? void 0 : yield* Effect.cached(Effect.flatMap(Effect.promise(() => import("../merges/merges.mjs")), ({ mergesContext }) => mergesContext({ xdiff }, objectsOverViews)));
|
|
606
|
-
const merges = loaded === void 0 ? void 0 : Context.make(MergeParts, partsOnce(loaded));
|
|
607
|
-
if (Option.isSome(yield* Effect.serviceOption(Rules))) return yield* Effect.die(/* @__PURE__ */ new TypeError("The adapter provides Rules; pass rules through createGitServer's rules option"));
|
|
608
511
|
const rules = yield* rulesOf(setup.rules ?? []);
|
|
609
512
|
const context = yield* Effect.context();
|
|
610
513
|
const guardedRecords = doorRecords(records, context, door);
|
|
@@ -623,12 +526,12 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
623
526
|
};
|
|
624
527
|
const given = {
|
|
625
528
|
adapter,
|
|
626
|
-
merges,
|
|
627
529
|
rules,
|
|
628
|
-
optional,
|
|
629
530
|
tokens: tokensHeld,
|
|
630
531
|
queue: queueHeld,
|
|
631
532
|
fetchLimits,
|
|
533
|
+
files,
|
|
534
|
+
repo,
|
|
632
535
|
deciders: decidersOf(),
|
|
633
536
|
grants,
|
|
634
537
|
extensions,
|
|
@@ -644,72 +547,91 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
644
547
|
through,
|
|
645
548
|
runtime
|
|
646
549
|
}));
|
|
647
|
-
yield* bridges.features(wired.services, extensions.registry);
|
|
648
|
-
const over = wired.services.pipe(Context.add(Git, {
|
|
649
|
-
register: extensions.registry.register,
|
|
650
|
-
route: (request) => Effect.map(Effect.promise(() => server.route(request)), Option.fromUndefinedOr),
|
|
651
|
-
handle: (request) => Effect.promise(() => server.fetch(request)),
|
|
652
|
-
identify: (request) => resultCall(() => server.identify(request)),
|
|
653
|
-
checkFetch: checkFetchOver(Effect.succeed(wired.parts))
|
|
654
|
-
}), Context.add(JoinedCalls, joinedOf(server, wired)));
|
|
655
|
-
const featureServices = features === void 0 ? Context.empty() : yield* Layer.build(features).pipe(Effect.provide(over), Effect.mapError(legacyError));
|
|
656
|
-
const joinedOver = Context.merge(over, featureServices).pipe(Context.merge(loaded === void 0 ? Context.empty() : yield* loaded));
|
|
657
|
-
for (const join of joins) {
|
|
658
|
-
const exit = yield* join.build(joinedOver);
|
|
659
|
-
if (Exit.isFailure(exit)) return yield* Effect.mapError(Effect.failCause(exit.cause), legacyError);
|
|
660
|
-
}
|
|
661
550
|
const jobLimits = jobLimitsOf(callLimits);
|
|
662
551
|
const register = (jobs) => adapter.jobs.register(...jobsWithin(jobLimits, jobs));
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
} else {
|
|
667
|
-
registerLater = register;
|
|
668
|
-
checkLater = wired.checkSources;
|
|
669
|
-
}
|
|
670
|
-
const built = Context.merge(Context.add(wired.services, Wired, wired), featureServices);
|
|
671
|
-
return loaded === void 0 ? built : Context.merge(built, yield* loaded);
|
|
552
|
+
registerLater = register;
|
|
553
|
+
checkLater = wired.checkSources;
|
|
554
|
+
return Context.add(wired.services, Wired, wired);
|
|
672
555
|
}));
|
|
673
556
|
const { adapter } = setup;
|
|
674
|
-
const
|
|
675
|
-
const
|
|
676
|
-
|
|
677
|
-
|
|
557
|
+
const host = isLayers(adapter) ? Layer.mergeAll(Layer.empty, ...adapter) : adapter;
|
|
558
|
+
const makeRuntime = () => ManagedRuntime.make(Layer.suspend(() => {
|
|
559
|
+
life.move({
|
|
560
|
+
kind: "building",
|
|
561
|
+
failures: 0
|
|
562
|
+
});
|
|
678
563
|
return Layer.provideMerge(wiring, host);
|
|
679
564
|
}).pipe(Layer.tap((built) => Effect.sync(() => {
|
|
680
565
|
life.move({
|
|
681
566
|
kind: "built",
|
|
682
567
|
wired: Context.get(built, Wired)
|
|
683
568
|
});
|
|
684
|
-
})), Layer.tapCause((cause) =>
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
569
|
+
})), Layer.tapCause((cause) => {
|
|
570
|
+
const building = life.now();
|
|
571
|
+
if (building.kind !== "building") return Effect.void;
|
|
572
|
+
const failures = building.failures + 1;
|
|
573
|
+
const next = afterFailure(cause, failures, life.clock());
|
|
574
|
+
if (!life.move(next)) return Effect.void;
|
|
575
|
+
if (failures === 1) return Effect.logError("The Git server failed to start", cause);
|
|
576
|
+
return Effect.logWarning("The Git server failed to start again", cause).pipe(Effect.annotateLogs({
|
|
577
|
+
failures,
|
|
578
|
+
next: next.kind === "waiting" ? next.at : "none"
|
|
579
|
+
}));
|
|
580
|
+
})));
|
|
581
|
+
let runtime = makeRuntime();
|
|
688
582
|
/**
|
|
689
|
-
* The
|
|
690
|
-
*
|
|
583
|
+
* The next build, once a call comes at or after `waiting`'s `at`: the call that wins the move to
|
|
584
|
+
* `building` makes a fresh runtime, and disposes the failed one, and a call that loses it waits on
|
|
585
|
+
* that build.
|
|
586
|
+
*/
|
|
587
|
+
const rebuild = () => {
|
|
588
|
+
const now = life.now();
|
|
589
|
+
if (now.kind !== "waiting" || life.admit("call") !== "wait") return;
|
|
590
|
+
if (!life.move({
|
|
591
|
+
kind: "building",
|
|
592
|
+
failures: now.failures
|
|
593
|
+
})) return;
|
|
594
|
+
const failed = runtime;
|
|
595
|
+
runtime = makeRuntime();
|
|
596
|
+
failed.dispose();
|
|
597
|
+
};
|
|
598
|
+
/**
|
|
599
|
+
* The server's build as the door answers it, every call's way in: built, or refused while it
|
|
600
|
+
* failed or waits to build again, starting or joining the build while it isn't settled. A closed
|
|
601
|
+
* server throws, before the build or after.
|
|
691
602
|
*/
|
|
692
603
|
const enter = async () => {
|
|
693
604
|
const settled = () => {
|
|
694
605
|
const admitted = life.admit("call");
|
|
695
606
|
if (admitted === "closed") throw closedError();
|
|
696
607
|
const now = life.now();
|
|
697
|
-
if (admitted === "run" && now.kind === "built") return
|
|
698
|
-
|
|
608
|
+
if (admitted === "run" && now.kind === "built") return {
|
|
609
|
+
kind: "success",
|
|
610
|
+
value: now.wired
|
|
611
|
+
};
|
|
612
|
+
const refused = admitted === "unavailable" ? refusedNow(life) : void 0;
|
|
613
|
+
return refused === void 0 ? void 0 : {
|
|
614
|
+
kind: "error",
|
|
615
|
+
error: refused
|
|
616
|
+
};
|
|
699
617
|
};
|
|
700
618
|
const before = settled();
|
|
701
619
|
if (before !== void 0) return before;
|
|
620
|
+
rebuild();
|
|
702
621
|
const exit = await exitOn(runtime, Effect.service(Wired), noCall);
|
|
703
|
-
return settled() ?? exit
|
|
622
|
+
return settled() ?? (Exit.isSuccess(exit) ? {
|
|
623
|
+
kind: "success",
|
|
624
|
+
value: exit.value
|
|
625
|
+
} : {
|
|
626
|
+
kind: "error",
|
|
627
|
+
error: unavailable(exit.cause)
|
|
628
|
+
});
|
|
704
629
|
};
|
|
705
|
-
const wired = Effect.flatMap(Effect.promise(enter), (
|
|
706
|
-
/** `use`'s Effect over the built server, its `Result`, or `UNAVAILABLE`
|
|
630
|
+
const wired = Effect.flatMap(Effect.promise(enter), (built) => built.kind === "success" ? Effect.succeed(built.value) : Effect.fail(built.error));
|
|
631
|
+
/** `use`'s Effect over the built server, its `Result`, or the `UNAVAILABLE` `enter` refuses with. */
|
|
707
632
|
const run = async (use, crossing, signal) => {
|
|
708
633
|
const built = await enter();
|
|
709
|
-
if (
|
|
710
|
-
kind: "error",
|
|
711
|
-
error: unavailable(built.cause)
|
|
712
|
-
};
|
|
634
|
+
if (built.kind === "error") return built;
|
|
713
635
|
return runCall(use(built.value), crossing, signal);
|
|
714
636
|
};
|
|
715
637
|
/**
|
|
@@ -741,13 +663,13 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
741
663
|
/** Git's HTTP answer to `request`, else sign-in's, or `undefined` outside both's URLs. */
|
|
742
664
|
const route = async (request) => {
|
|
743
665
|
const built = await enter();
|
|
744
|
-
if (
|
|
666
|
+
if (built.kind === "error") {
|
|
745
667
|
const url = new URL(request.url);
|
|
746
|
-
return gitUrlOf(url, basePath) !== void 0 ||
|
|
668
|
+
return gitUrlOf(url, basePath) !== void 0 || extensions.registry.routeOf(/* @__PURE__ */ new Set([
|
|
747
669
|
"pre",
|
|
748
670
|
"plain",
|
|
749
671
|
"post"
|
|
750
|
-
]), request, url.pathname) !== void 0 ? refusal(
|
|
672
|
+
]), request, url.pathname) !== void 0 ? refusal(built.error) : void 0;
|
|
751
673
|
}
|
|
752
674
|
const path = new URL(request.url).pathname;
|
|
753
675
|
const first = extensions.registry.routeOf(/* @__PURE__ */ new Set(["pre", "plain"]), request, path);
|
|
@@ -763,7 +685,9 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
763
685
|
fetch: async (request) => await route(request) ?? new Response("Not found", { status: 404 }),
|
|
764
686
|
route,
|
|
765
687
|
identify: (request) => run((built) => built.identify(request), uncounted("a host's identify: no Git request"), request.signal),
|
|
766
|
-
runtime
|
|
688
|
+
get runtime() {
|
|
689
|
+
return runtime;
|
|
690
|
+
},
|
|
767
691
|
close: async () => {
|
|
768
692
|
life.move({ kind: "closed" });
|
|
769
693
|
await runtime.dispose();
|
|
@@ -771,6 +695,7 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
771
695
|
};
|
|
772
696
|
attachJoins(server, {
|
|
773
697
|
admit: life.admit,
|
|
698
|
+
addSealCheck: extensions.registry.addSealCheck,
|
|
774
699
|
basePath,
|
|
775
700
|
fetchLimits,
|
|
776
701
|
get queueKeys() {
|
|
@@ -778,10 +703,7 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
778
703
|
},
|
|
779
704
|
built: wired,
|
|
780
705
|
through,
|
|
781
|
-
failed: () =>
|
|
782
|
-
const now = life.now();
|
|
783
|
-
return now.kind === "failed" ? unavailable(now.cause) : void 0;
|
|
784
|
-
},
|
|
706
|
+
failed: () => refusedNow(life),
|
|
785
707
|
callsFor: (caller, budget) => {
|
|
786
708
|
let calls;
|
|
787
709
|
return heldGroup(callsOver((built) => {
|
|
@@ -800,8 +722,7 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
800
722
|
identify: (request, budget) => run((built) => built.identify(request), {
|
|
801
723
|
calls: void 0,
|
|
802
724
|
budget
|
|
803
|
-
}, request.signal)
|
|
804
|
-
joins
|
|
725
|
+
}, request.signal)
|
|
805
726
|
});
|
|
806
727
|
attachParts(server, {
|
|
807
728
|
basePath,
|
|
@@ -811,7 +732,7 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
811
732
|
parts: Effect.map(wired, (built) => built.parts)
|
|
812
733
|
});
|
|
813
734
|
queueMicrotask(() => {
|
|
814
|
-
if (life.
|
|
735
|
+
if (life.now().kind === "unbuilt") exitOn(runtime, Effect.void, noCall);
|
|
815
736
|
});
|
|
816
737
|
return {
|
|
817
738
|
server,
|
|
@@ -820,4 +741,4 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
820
741
|
seal
|
|
821
742
|
};
|
|
822
743
|
};
|
|
823
|
-
export {
|
|
744
|
+
export { openServer };
|
package/dist/storage/budget.mjs
CHANGED
|
@@ -98,8 +98,8 @@ const pushAdmissionOf = (size) => pushFixedOf(size) + receiveRoomAdmitted(size.o
|
|
|
98
98
|
/**
|
|
99
99
|
* The most objects a push of `size`'s length takes in a `packs()` instance of `memory`, at most
|
|
100
100
|
* `receiveTableMost`: the most whose admission fits beside the read reserve, and whose index files
|
|
101
|
-
* fit beside it too as they're made.
|
|
102
|
-
*
|
|
101
|
+
* fit beside it too as they're made. In a Worker's 128 MB, 1,215,694 for a chunked push. What a
|
|
102
|
+
* push takes is the less of it and what a prune walk holds an index of, `pushObjectsMostOf`.
|
|
103
103
|
*/
|
|
104
104
|
const receiveObjectsMostOf = (memory, size = {}) => {
|
|
105
105
|
const room = allottableOf(memory) - readReserveBytes;
|