@ref0/git 0.11.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 +8 -7
- 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 +14 -3
- package/dist/contracts/git.d.mts +41 -12
- 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 +30 -23
- package/dist/contracts/result.mjs +24 -9
- 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 +90 -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.d.mts +1 -0
- package/dist/core/access.mjs +34 -13
- package/dist/core/ancestry.d.mts +9 -0
- package/dist/core/ancestry.mjs +6 -6
- package/dist/core/asked.mjs +68 -0
- package/dist/core/call-names.mjs +1 -0
- package/dist/core/call-services.mjs +2 -1
- package/dist/core/events/deliver.d.mts +1 -0
- package/dist/core/events/deliver.mjs +15 -3
- package/dist/core/forks.mjs +42 -16
- package/dist/core/imports.mjs +156 -13
- 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/objects/reading.mjs +17 -9
- package/dist/core/parts.d.mts +8 -2
- 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 +107 -32
- package/dist/core/receipts.mjs +26 -10
- package/dist/core/ref-view.mjs +59 -5
- package/dist/core/refs.mjs +18 -10
- package/dist/core/registered-rows.mjs +7 -5
- package/dist/core/repack.mjs +16 -11
- package/dist/core/repo-info.mjs +16 -9
- package/dist/core/repos.mjs +30 -14
- package/dist/core/saved-caller-views.d.mts +18 -0
- package/dist/core/saved-caller-views.mjs +17 -4
- package/dist/core/saved-callers-public.d.mts +3 -3
- package/dist/core/saved-callers-public.mjs +3 -2
- package/dist/core/saved-callers.d.mts +7 -0
- 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 +4 -3
- package/dist/extend.mjs +3 -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 +120 -59
- 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/locks.mjs +14 -9
- package/dist/lfs/objects.d.mts +6 -0
- package/dist/lfs/objects.mjs +95 -61
- 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/calls.mjs +21 -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 +16 -8
- 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 +272 -239
- 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 +112 -100
- package/dist/rest/forks.d.mts +146 -122
- 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 +10 -2
- 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 +292 -236
- package/dist/rest/refs.d.mts +98 -69
- package/dist/rest/repos.d.mts +133 -105
- package/dist/rest/tags.d.mts +100 -88
- package/dist/rest/tokens.d.mts +192 -168
- package/dist/rest/topics.d.mts +154 -134
- package/dist/rest/trees.d.mts +32 -16
- 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 +4 -4
- 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 +139 -216
- 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 +154 -8
- package/dist/storage/merge-cut.mjs +5 -4
- package/dist/storage/pack-reads.mjs +246 -34
- 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-seen.mjs +11 -6
- package/dist/storage/prune-walk.mjs +219 -81
- package/dist/storage/prune.mjs +629 -196
- package/dist/storage/push-uploads.mjs +36 -12
- package/dist/storage/quarantine.mjs +9 -7
- 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 +27 -0
- package/dist/store/repo-record.mjs +141 -4
- 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 +63 -42
- package/dist/sync/http.mjs +36 -1
- package/dist/sync/import.mjs +4 -2
- 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 +227 -147
- package/dist/sync/said.mjs +204 -0
- package/dist/sync/smart-http.mjs +4 -2
- package/dist/sync/step.mjs +33 -13
- package/dist/sync/tries.mjs +71 -24
- package/dist/sync.d.mts +2 -2
- package/dist/topics/advance.mjs +10 -3
- 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 -4
- 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 {
|
|
74
|
-
import {
|
|
75
|
-
import { QueueBase, QueueInternals, queueKeysOf, queueOptions } from "../queue/host.mjs";
|
|
68
|
+
import { entryAdderOf, queueCalls } from "../queue/calls.mjs";
|
|
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 = {
|
|
@@ -213,7 +160,8 @@ const wireServer = (options, wiring) => {
|
|
|
213
160
|
const { registry } = extensions;
|
|
214
161
|
const events = deliveryLog({
|
|
215
162
|
store,
|
|
216
|
-
now
|
|
163
|
+
now,
|
|
164
|
+
fetchLimits
|
|
217
165
|
});
|
|
218
166
|
registry.bindDeliveries((registered) => events.fill(registered));
|
|
219
167
|
const onFailure = workFailed(events, now);
|
|
@@ -240,7 +188,8 @@ const wireServer = (options, wiring) => {
|
|
|
240
188
|
now,
|
|
241
189
|
fetchLimits,
|
|
242
190
|
parts: [registry.purge],
|
|
243
|
-
scopes: registry.repoScopes
|
|
191
|
+
scopes: registry.repoScopes,
|
|
192
|
+
deliveries: events.deliveries
|
|
244
193
|
});
|
|
245
194
|
const own = [
|
|
246
195
|
listJob,
|
|
@@ -272,7 +221,8 @@ const wireServer = (options, wiring) => {
|
|
|
272
221
|
registry.bindRows({
|
|
273
222
|
store,
|
|
274
223
|
fences,
|
|
275
|
-
repackJobRow: repackRow
|
|
224
|
+
repackJobRow: repackRow,
|
|
225
|
+
fetchLimits
|
|
276
226
|
});
|
|
277
227
|
const parts = {
|
|
278
228
|
store,
|
|
@@ -312,11 +262,12 @@ const wireServer = (options, wiring) => {
|
|
|
312
262
|
});
|
|
313
263
|
const stored = Context.make(Storage, objects).pipe(Context.add(ObjectsParts, {
|
|
314
264
|
objects: sealed,
|
|
315
|
-
fetchLimits
|
|
265
|
+
fetchLimits,
|
|
266
|
+
files,
|
|
267
|
+
repo
|
|
316
268
|
}), Context.add(Objects, objectsOverViews), Context.add(Changes, changes));
|
|
317
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));
|
|
318
|
-
const
|
|
319
|
-
const viewed = Context.add(merging, View, viewOver(merging));
|
|
270
|
+
const viewed = Context.add(base, View, viewOver(base));
|
|
320
271
|
const needs = Context.add(viewed, Refs, providedCalls(refsCalls, viewed));
|
|
321
272
|
const streams = streamsOver({
|
|
322
273
|
clock,
|
|
@@ -324,15 +275,7 @@ const wireServer = (options, wiring) => {
|
|
|
324
275
|
closing,
|
|
325
276
|
through
|
|
326
277
|
}, needs);
|
|
327
|
-
const queueHost = queueOf === void 0 ? void 0 : {
|
|
328
|
-
needs,
|
|
329
|
-
records: rawRecords,
|
|
330
|
-
options: queueOf,
|
|
331
|
-
keys: wiring.optional.queueKeys,
|
|
332
|
-
buildMilliseconds: buildMillisecondsOf(adapter.requestLimits.cpuMs)
|
|
333
|
-
};
|
|
334
278
|
const queueHeld = wiring.queue;
|
|
335
|
-
queueHeld.host = queueHost;
|
|
336
279
|
const queueBase = QueueBase.of({
|
|
337
280
|
records: rawRecords,
|
|
338
281
|
needs,
|
|
@@ -354,28 +297,38 @@ const wireServer = (options, wiring) => {
|
|
|
354
297
|
if (lfsAttached !== void 0) return Effect.die(/* @__PURE__ */ new TypeError("The server has Git LFS: provide Lfs.layer once"));
|
|
355
298
|
lfsAttached = lfs;
|
|
356
299
|
return registry.addCheck(lfs.check);
|
|
357
|
-
})
|
|
300
|
+
}),
|
|
301
|
+
copy: Effect.sync(() => lfsAttached?.copy)
|
|
358
302
|
});
|
|
359
303
|
const { uploads } = adapter;
|
|
360
304
|
const staging = counted === void 0 || uploads === void 0 ? void 0 : {
|
|
361
305
|
bucket: counted,
|
|
362
306
|
uploads
|
|
363
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
|
+
}
|
|
364
323
|
let uploadsAttached;
|
|
365
324
|
const uploadsBase = UploadsBase.of({
|
|
366
325
|
staging,
|
|
367
326
|
attach: (above) => Effect.suspend(() => {
|
|
368
327
|
if (staging === void 0 || uploadsAttached !== void 0) return Effect.die(/* @__PURE__ */ new TypeError("The server takes push uploads: provide Git.layerUploads once"));
|
|
369
|
-
uploadsAttached = pushUploads(needs, staging, above);
|
|
328
|
+
uploadsAttached = pushUploads(needs, staging, above, adapter.requestLimits.cpuMs);
|
|
370
329
|
return Effect.void;
|
|
371
330
|
})
|
|
372
331
|
});
|
|
373
|
-
if (queueHost !== void 0) {
|
|
374
|
-
registry.bridge("queue", "refs/queue/");
|
|
375
|
-
const queueJobList = queueJobs(queueHost, onFailure).map((job) => job(gitJob));
|
|
376
|
-
gits.knowJobs(queueJobList);
|
|
377
|
-
jobs.register(...jobsWithin(jobLimits, queueJobList));
|
|
378
|
-
}
|
|
379
332
|
let topicsAttached;
|
|
380
333
|
const topicsBase = TopicsBase.of({ attach: (service) => Effect.sync(() => {
|
|
381
334
|
topicsAttached = service;
|
|
@@ -400,15 +353,6 @@ const wireServer = (options, wiring) => {
|
|
|
400
353
|
refuse: (error) => refusal(error, true)
|
|
401
354
|
})
|
|
402
355
|
});
|
|
403
|
-
if (optional.tokens !== void 0) {
|
|
404
|
-
registry.bridge("tokens");
|
|
405
|
-
tokensHeld.calls = tokenCalls({
|
|
406
|
-
store,
|
|
407
|
-
now,
|
|
408
|
-
cleanup,
|
|
409
|
-
events
|
|
410
|
-
});
|
|
411
|
-
}
|
|
412
356
|
const identify = identifier({
|
|
413
357
|
store,
|
|
414
358
|
tokens: () => tokensHeld.calls !== void 0,
|
|
@@ -421,16 +365,13 @@ const wireServer = (options, wiring) => {
|
|
|
421
365
|
needs,
|
|
422
366
|
pushRefsMost: pushRefLimitOf(refIndex),
|
|
423
367
|
through: wiring.through
|
|
424
|
-
}), Context.add(SavedCallers, savedCallersOf(needs)), Context.add(LfsBase, lfsBase), Context.add(UploadsBase, uploadsBase), Context.add(TopicsBase, topicsBase), Context.add(TokensBase, tokensBase));
|
|
425
|
-
const
|
|
426
|
-
const withTokens = tokensHeld.calls === void 0 ? queuedServices : Context.add(queuedServices, Tokens, tokensHeld.calls);
|
|
427
|
-
const streamed = Context.add(withTokens, EventStreams, { feed: streams.feed });
|
|
428
|
-
const services = merges === void 0 ? streamed : Context.merge(streamed, merges);
|
|
368
|
+
}), Context.add(SavedCallers, savedCallersOf(needs, entryAdderOf)), Context.add(LfsBase, lfsBase), Context.add(UploadsBase, uploadsBase), Context.add(TopicsBase, topicsBase), Context.add(TokensBase, tokensBase));
|
|
369
|
+
const services = Context.add(decided, EventStreams, { feed: streams.feed });
|
|
429
370
|
/**
|
|
430
371
|
* Every group of the server's calls deciding for `bound`, over `needs`: the one list `callsAs`
|
|
431
372
|
* and `hostCalls` both build from, so a group added to one is in the other. `Git.host`'s are host
|
|
432
|
-
* code's, as `asHost` says. An optional group is there
|
|
433
|
-
*
|
|
373
|
+
* code's, as `asHost` says. An optional group is there once its feature attached, as
|
|
374
|
+
* `tokensHeld` and `queueHeld` hold it.
|
|
434
375
|
*/
|
|
435
376
|
const groupsOf = (bound) => {
|
|
436
377
|
const over = (calls) => aroundCalls(calls, (effect) => Effect.provideContext(acting(bound, effect), needs));
|
|
@@ -488,8 +429,9 @@ const wireServer = (options, wiring) => {
|
|
|
488
429
|
httpOptions.calls = before(fetchHooks)(countedMost(objects) ?? callLimits);
|
|
489
430
|
httpOptions.pushCalls = before(0)(callLimits);
|
|
490
431
|
httpOptions.lfs = () => lfsAttached?.service;
|
|
491
|
-
httpOptions.uploads = () => uploadsAttached;
|
|
492
|
-
|
|
432
|
+
httpOptions.uploads = () => stepping ? uploadsAttached : void 0;
|
|
433
|
+
httpParts = coreHttpParts(served, httpOptions);
|
|
434
|
+
const http = gitHttp(httpParts);
|
|
493
435
|
return {
|
|
494
436
|
parts: served,
|
|
495
437
|
adapter: {
|
|
@@ -513,43 +455,19 @@ const wireServer = (options, wiring) => {
|
|
|
513
455
|
};
|
|
514
456
|
};
|
|
515
457
|
/** Whether `adapter` is several Layers. */
|
|
516
|
-
const signInPathSet = new Set(Object.values(signInPaths));
|
|
517
458
|
const isLayers = (adapter) => Array.isArray(adapter);
|
|
518
459
|
/**
|
|
519
|
-
*
|
|
520
|
-
*
|
|
521
|
-
* runtime builds the adapter's Layers and Git's wiring once the tick that made it ends, which
|
|
522
|
-
* registers Git's jobs on the adapter's queue, and never runs them: the host starts them.
|
|
523
|
-
*/
|
|
524
|
-
const createGitServer = (options) => serverWith(options, () => ({
|
|
525
|
-
policy: policyOf(options.authorize),
|
|
526
|
-
auth: authOf(options.auth)
|
|
527
|
-
}));
|
|
528
|
-
/**
|
|
529
|
-
* `createGitServer` deciding with `decidersOf`'s answer, which it asks once as the server builds:
|
|
530
|
-
* `createGitServer` gives its options' hooks. Internal: no entry exports it, so a host
|
|
531
|
-
* gives a `Policy` only through `Git.layer`.
|
|
532
|
-
*/
|
|
533
|
-
const serverWith = (options, decidersOf, features) => openServer(options, decidersOf, "build", features).server;
|
|
534
|
-
/**
|
|
535
|
-
* `serverWith`, sealing as its build ends, or `later`, when `Git.layer` seals once its features
|
|
536
|
-
* have registered, after this build.
|
|
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.
|
|
537
462
|
*/
|
|
538
|
-
const openServer = (options, decidersOf
|
|
463
|
+
const openServer = (options, decidersOf) => {
|
|
539
464
|
const setup = options;
|
|
540
|
-
const bridges = bridged(setup);
|
|
541
|
-
if (setup.signIn !== void 0 && setup.tokens === void 0) throw new TypeError("signIn mints tokens: pass tokens() too");
|
|
542
|
-
if (setup.access !== void 0 && setup.objects.indexed !== true) throw new TypeError("access hides refs, which needs objects that follow them: pass packs()");
|
|
543
|
-
const queueOf = setup.queue === void 0 ? void 0 : queueOptions(setup.queue);
|
|
544
|
-
const listed = (setup.rules ?? []).filter((rule) => !Effect.isEffect(rule) && rule.kind === "push");
|
|
545
|
-
if (queueOf === void 0 && sealing === "build") servedSources(listed);
|
|
546
|
-
if (setup.topics !== void 0 && queueOf === void 0) throw new TypeError("topics merge through each repo’s queue: pass queue too");
|
|
547
|
-
if (queueOf !== void 0 && setup.xdiff === void 0) throw new TypeError("the merge queue merges trees: pass xdiff too");
|
|
548
465
|
const fetchLimits = fetchLimitsOf(setup.fetchLimits);
|
|
466
|
+
const files = pushFilesOf(setup.pushes?.files);
|
|
467
|
+
const repo = pushRepoOf(setup.pushes?.repo);
|
|
549
468
|
const grants = heldGrants();
|
|
550
469
|
const basePath = normalBase(setup.basePath ?? "");
|
|
551
470
|
const extensions = openExtensions(basePath);
|
|
552
|
-
const joins = [];
|
|
553
471
|
const life = serverLife();
|
|
554
472
|
const isClosed = () => life.admit("call") === "closed";
|
|
555
473
|
const guard = Effect.suspend(() => isClosed() ? Effect.die(closedError()) : Effect.void);
|
|
@@ -559,17 +477,11 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
559
477
|
};
|
|
560
478
|
const through = throughDoor(life);
|
|
561
479
|
const closingWith = (signal) => signal === void 0 ? life.closing : AbortSignal.any([signal, life.closing]);
|
|
562
|
-
const optional = {
|
|
563
|
-
queue: queueOf,
|
|
564
|
-
queueKeys: setup.queue === void 0 ? void 0 : queueKeysOf(setup.queue),
|
|
565
|
-
topics: setup.topics,
|
|
566
|
-
tokens: setup.tokens
|
|
567
|
-
};
|
|
568
480
|
const tokensHeld = { calls: void 0 };
|
|
569
481
|
const queueHeld = { host: void 0 };
|
|
570
|
-
const names = namesOf(
|
|
571
|
-
const joinedNames = namesOf(
|
|
572
|
-
const queueOn = () =>
|
|
482
|
+
const names = namesOf(false, false);
|
|
483
|
+
const joinedNames = namesOf(true, true);
|
|
484
|
+
const queueOn = () => queueHeld.host !== void 0;
|
|
573
485
|
const joinedCall = (calls, group, name) => callOrMissing(calls, group, name, () => Effect.fail(noTokens));
|
|
574
486
|
const runCall = async (effect, crossing, signal) => {
|
|
575
487
|
if (isClosed()) throw closedError();
|
|
@@ -584,10 +496,7 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
584
496
|
const register = registerLater;
|
|
585
497
|
const check = checkLater;
|
|
586
498
|
if (register === void 0 || check === void 0) return Effect.die(/* @__PURE__ */ new Error("Git's registry seals after the server's build"));
|
|
587
|
-
return Effect.flatMap(extensions.registry.seal(), (jobs) => Effect.sync(() =>
|
|
588
|
-
check();
|
|
589
|
-
register(jobs);
|
|
590
|
-
}));
|
|
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)))));
|
|
591
500
|
});
|
|
592
501
|
const wiring = Layer.effectContext(Effect.gen(function* () {
|
|
593
502
|
const records = yield* Records.Records;
|
|
@@ -599,10 +508,6 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
599
508
|
const uploads = yield* Effect.serviceOption(BucketUploads.BucketUploads);
|
|
600
509
|
const clock = yield* Effect.clockWith(Effect.succeed);
|
|
601
510
|
const logging = Context.make(References.CurrentLoggers, yield* References.CurrentLoggers).pipe(Context.add(References.MinimumLogLevel, yield* References.MinimumLogLevel));
|
|
602
|
-
const xdiff = setup.xdiff;
|
|
603
|
-
const loaded = xdiff === void 0 ? void 0 : yield* Effect.cached(Effect.flatMap(Effect.promise(() => import("../merges/merges.mjs")), ({ mergesContext }) => mergesContext({ xdiff }, objectsOverViews)));
|
|
604
|
-
const merges = loaded === void 0 ? void 0 : Context.make(MergeParts, partsOnce(loaded));
|
|
605
|
-
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"));
|
|
606
511
|
const rules = yield* rulesOf(setup.rules ?? []);
|
|
607
512
|
const context = yield* Effect.context();
|
|
608
513
|
const guardedRecords = doorRecords(records, context, door);
|
|
@@ -621,12 +526,12 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
621
526
|
};
|
|
622
527
|
const given = {
|
|
623
528
|
adapter,
|
|
624
|
-
merges,
|
|
625
529
|
rules,
|
|
626
|
-
optional,
|
|
627
530
|
tokens: tokensHeld,
|
|
628
531
|
queue: queueHeld,
|
|
629
532
|
fetchLimits,
|
|
533
|
+
files,
|
|
534
|
+
repo,
|
|
630
535
|
deciders: decidersOf(),
|
|
631
536
|
grants,
|
|
632
537
|
extensions,
|
|
@@ -642,72 +547,91 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
642
547
|
through,
|
|
643
548
|
runtime
|
|
644
549
|
}));
|
|
645
|
-
yield* bridges.features(wired.services, extensions.registry);
|
|
646
|
-
const over = wired.services.pipe(Context.add(Git, {
|
|
647
|
-
register: extensions.registry.register,
|
|
648
|
-
route: (request) => Effect.map(Effect.promise(() => server.route(request)), Option.fromUndefinedOr),
|
|
649
|
-
handle: (request) => Effect.promise(() => server.fetch(request)),
|
|
650
|
-
identify: (request) => resultCall(() => server.identify(request)),
|
|
651
|
-
checkFetch: checkFetchOver(Effect.succeed(wired.parts))
|
|
652
|
-
}), Context.add(JoinedCalls, joinedOf(server, wired)));
|
|
653
|
-
const featureServices = features === void 0 ? Context.empty() : yield* Layer.build(features).pipe(Effect.provide(over), Effect.mapError(legacyError));
|
|
654
|
-
const joinedOver = Context.merge(over, featureServices).pipe(Context.merge(loaded === void 0 ? Context.empty() : yield* loaded));
|
|
655
|
-
for (const join of joins) {
|
|
656
|
-
const exit = yield* join.build(joinedOver);
|
|
657
|
-
if (Exit.isFailure(exit)) return yield* Effect.mapError(Effect.failCause(exit.cause), legacyError);
|
|
658
|
-
}
|
|
659
550
|
const jobLimits = jobLimitsOf(callLimits);
|
|
660
551
|
const register = (jobs) => adapter.jobs.register(...jobsWithin(jobLimits, jobs));
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
} else {
|
|
665
|
-
registerLater = register;
|
|
666
|
-
checkLater = wired.checkSources;
|
|
667
|
-
}
|
|
668
|
-
const built = Context.merge(Context.add(wired.services, Wired, wired), featureServices);
|
|
669
|
-
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);
|
|
670
555
|
}));
|
|
671
556
|
const { adapter } = setup;
|
|
672
|
-
const
|
|
673
|
-
const
|
|
674
|
-
|
|
675
|
-
|
|
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
|
+
});
|
|
676
563
|
return Layer.provideMerge(wiring, host);
|
|
677
564
|
}).pipe(Layer.tap((built) => Effect.sync(() => {
|
|
678
565
|
life.move({
|
|
679
566
|
kind: "built",
|
|
680
567
|
wired: Context.get(built, Wired)
|
|
681
568
|
});
|
|
682
|
-
})), Layer.tapCause((cause) =>
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
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();
|
|
582
|
+
/**
|
|
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
|
+
};
|
|
686
598
|
/**
|
|
687
|
-
* The server's build as the door answers it, every call's way in: built, or
|
|
688
|
-
* joining the build while it isn't settled. A closed
|
|
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.
|
|
689
602
|
*/
|
|
690
603
|
const enter = async () => {
|
|
691
604
|
const settled = () => {
|
|
692
605
|
const admitted = life.admit("call");
|
|
693
606
|
if (admitted === "closed") throw closedError();
|
|
694
607
|
const now = life.now();
|
|
695
|
-
if (admitted === "run" && now.kind === "built") return
|
|
696
|
-
|
|
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
|
+
};
|
|
697
617
|
};
|
|
698
618
|
const before = settled();
|
|
699
619
|
if (before !== void 0) return before;
|
|
620
|
+
rebuild();
|
|
700
621
|
const exit = await exitOn(runtime, Effect.service(Wired), noCall);
|
|
701
|
-
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
|
+
});
|
|
702
629
|
};
|
|
703
|
-
const wired = Effect.flatMap(Effect.promise(enter), (
|
|
704
|
-
/** `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. */
|
|
705
632
|
const run = async (use, crossing, signal) => {
|
|
706
633
|
const built = await enter();
|
|
707
|
-
if (
|
|
708
|
-
kind: "error",
|
|
709
|
-
error: unavailable(built.cause)
|
|
710
|
-
};
|
|
634
|
+
if (built.kind === "error") return built;
|
|
711
635
|
return runCall(use(built.value), crossing, signal);
|
|
712
636
|
};
|
|
713
637
|
/**
|
|
@@ -739,13 +663,13 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
739
663
|
/** Git's HTTP answer to `request`, else sign-in's, or `undefined` outside both's URLs. */
|
|
740
664
|
const route = async (request) => {
|
|
741
665
|
const built = await enter();
|
|
742
|
-
if (
|
|
666
|
+
if (built.kind === "error") {
|
|
743
667
|
const url = new URL(request.url);
|
|
744
|
-
return gitUrlOf(url, basePath) !== void 0 ||
|
|
668
|
+
return gitUrlOf(url, basePath) !== void 0 || extensions.registry.routeOf(/* @__PURE__ */ new Set([
|
|
745
669
|
"pre",
|
|
746
670
|
"plain",
|
|
747
671
|
"post"
|
|
748
|
-
]), request, url.pathname) !== void 0 ? refusal(
|
|
672
|
+
]), request, url.pathname) !== void 0 ? refusal(built.error) : void 0;
|
|
749
673
|
}
|
|
750
674
|
const path = new URL(request.url).pathname;
|
|
751
675
|
const first = extensions.registry.routeOf(/* @__PURE__ */ new Set(["pre", "plain"]), request, path);
|
|
@@ -761,7 +685,9 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
761
685
|
fetch: async (request) => await route(request) ?? new Response("Not found", { status: 404 }),
|
|
762
686
|
route,
|
|
763
687
|
identify: (request) => run((built) => built.identify(request), uncounted("a host's identify: no Git request"), request.signal),
|
|
764
|
-
runtime
|
|
688
|
+
get runtime() {
|
|
689
|
+
return runtime;
|
|
690
|
+
},
|
|
765
691
|
close: async () => {
|
|
766
692
|
life.move({ kind: "closed" });
|
|
767
693
|
await runtime.dispose();
|
|
@@ -769,6 +695,7 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
769
695
|
};
|
|
770
696
|
attachJoins(server, {
|
|
771
697
|
admit: life.admit,
|
|
698
|
+
addSealCheck: extensions.registry.addSealCheck,
|
|
772
699
|
basePath,
|
|
773
700
|
fetchLimits,
|
|
774
701
|
get queueKeys() {
|
|
@@ -776,10 +703,7 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
776
703
|
},
|
|
777
704
|
built: wired,
|
|
778
705
|
through,
|
|
779
|
-
failed: () =>
|
|
780
|
-
const now = life.now();
|
|
781
|
-
return now.kind === "failed" ? unavailable(now.cause) : void 0;
|
|
782
|
-
},
|
|
706
|
+
failed: () => refusedNow(life),
|
|
783
707
|
callsFor: (caller, budget) => {
|
|
784
708
|
let calls;
|
|
785
709
|
return heldGroup(callsOver((built) => {
|
|
@@ -798,8 +722,7 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
798
722
|
identify: (request, budget) => run((built) => built.identify(request), {
|
|
799
723
|
calls: void 0,
|
|
800
724
|
budget
|
|
801
|
-
}, request.signal)
|
|
802
|
-
joins
|
|
725
|
+
}, request.signal)
|
|
803
726
|
});
|
|
804
727
|
attachParts(server, {
|
|
805
728
|
basePath,
|
|
@@ -809,7 +732,7 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
809
732
|
parts: Effect.map(wired, (built) => built.parts)
|
|
810
733
|
});
|
|
811
734
|
queueMicrotask(() => {
|
|
812
|
-
if (life.
|
|
735
|
+
if (life.now().kind === "unbuilt") exitOn(runtime, Effect.void, noCall);
|
|
813
736
|
});
|
|
814
737
|
return {
|
|
815
738
|
server,
|
|
@@ -818,4 +741,4 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
818
741
|
seal
|
|
819
742
|
};
|
|
820
743
|
};
|
|
821
|
-
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;
|