@ref0/git 0.14.0 → 0.20.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/auth/access-jwt.mjs +2 -2
- package/dist/auth/authorize.mjs +3 -3
- package/dist/auth/fences.d.mts +1 -2
- package/dist/auth/fences.mjs +3 -3
- package/dist/auth/grants.mjs +4 -4
- package/dist/auth/host-function.mjs +18 -1
- package/dist/auth/identify.d.mts +1 -1
- package/dist/auth/identify.mjs +3 -3
- package/dist/auth/token-cleanup.mjs +67 -0
- package/dist/auth/token-rows.mjs +1 -1
- package/dist/auth/token-text.mjs +9 -1
- package/dist/auth/tokens-base.d.mts +35 -0
- package/dist/auth/tokens-base.mjs +13 -0
- package/dist/auth/tokens-layer.d.mts +2 -27
- package/dist/auth/tokens-layer.mjs +6 -11
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens.d.mts +7 -10
- package/dist/auth/tokens.mjs +9 -80
- package/dist/client/answer.mjs +21 -42
- package/dist/client/client.d.mts +2 -4
- package/dist/client/git-http.mjs +17 -7
- package/dist/client/local.mjs +14 -13
- package/dist/client/push-upload.mjs +9 -8
- package/dist/client/remote.mjs +8 -10
- package/dist/client/run-remote-helper.d.mts +1 -0
- package/dist/client/run-remote-helper.mjs +58 -24
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/client/transport.mjs +105 -46
- package/dist/contracts/blobs.d.mts +55 -8
- package/dist/contracts/blobs.mjs +16 -2
- package/dist/contracts/call-allowance.d.mts +13 -0
- package/dist/contracts/call-allowance.mjs +44 -0
- package/dist/contracts/calls-spent.mjs +8 -3
- package/dist/contracts/client.d.mts +15 -16
- package/dist/contracts/commits.d.mts +24 -24
- package/dist/contracts/engine.d.mts +6 -1
- package/dist/contracts/engine.mjs +10 -1
- package/dist/contracts/files.d.mts +10 -10
- package/dist/contracts/forks.d.mts +17 -17
- package/dist/contracts/git-events.d.mts +29 -1
- package/dist/contracts/git-hooks.d.mts +1 -1
- package/dist/contracts/git.d.mts +21 -0
- package/dist/contracts/grants.d.mts +24 -4
- package/dist/contracts/handlers.d.mts +1 -1
- package/dist/contracts/lfs.d.mts +28 -2
- package/dist/contracts/merges.d.mts +3 -2
- package/dist/contracts/objects.d.mts +23 -25
- package/dist/contracts/queue.d.mts +40 -12
- package/dist/contracts/queue.mjs +3 -4
- package/dist/contracts/refs.d.mts +26 -23
- package/dist/contracts/remote.d.mts +6 -7
- package/dist/contracts/remote.mjs +4 -1
- package/dist/contracts/repos.d.mts +29 -138
- package/dist/contracts/repos.mjs +5 -3
- package/dist/contracts/result.d.mts +35 -16
- package/dist/contracts/result.mjs +35 -7
- package/dist/contracts/server.d.mts +25 -50
- package/dist/contracts/services.d.mts +1 -1
- package/dist/contracts/store.d.mts +6 -5
- package/dist/contracts/sync.d.mts +11 -7
- package/dist/contracts/sync.mjs +12 -2
- package/dist/contracts/tags.d.mts +10 -10
- package/dist/contracts/time.d.mts +3 -0
- package/dist/contracts/{promises.mjs → time.mjs} +1 -1
- package/dist/contracts/tokens.d.mts +15 -17
- package/dist/contracts/tokens.mjs +3 -2
- package/dist/contracts/topics.d.mts +1 -1
- package/dist/contracts/trees.d.mts +12 -12
- package/dist/contracts/work.d.mts +24 -13
- package/dist/core/access.d.mts +1 -2
- package/dist/core/access.mjs +20 -9
- package/dist/core/ancestry.d.mts +1 -0
- package/dist/core/asked.mjs +1 -1
- package/dist/core/call-names.mjs +6 -1
- package/dist/core/call-services.mjs +11 -3
- package/dist/core/events/deliver.d.mts +1 -2
- package/dist/core/events/deliver.mjs +43 -36
- package/dist/core/events/retired.mjs +119 -0
- package/dist/core/forks.mjs +928 -432
- package/dist/core/hooks/groups.mjs +1 -1
- package/dist/core/imports.mjs +29 -23
- package/dist/core/index-job.mjs +122 -34
- package/dist/core/index-lost.d.mts +1 -2
- package/dist/core/index-lost.mjs +2 -2
- package/dist/core/loose-tally.mjs +1 -1
- package/dist/core/objects/blobs.mjs +129 -3
- package/dist/core/objects/lines.mjs +2 -2
- package/dist/core/objects/merges.mjs +4 -1
- package/dist/core/objects/objects-layer.d.mts +1 -1
- package/dist/core/objects/objects-layer.mjs +3 -3
- package/dist/core/objects/reading.mjs +24 -13
- package/dist/core/objects/tags.mjs +4 -1
- package/dist/core/objects/trees.mjs +2 -2
- package/dist/core/objects/writing.mjs +2 -2
- package/dist/core/own-writes.mjs +1 -1
- package/dist/core/parts.d.mts +4 -5
- package/dist/core/parts.mjs +3 -8
- package/dist/core/promise.mjs +9 -12
- package/dist/core/purge.mjs +287 -83
- package/dist/core/push-decide.mjs +2 -0
- package/dist/core/push-files.d.mts +1 -1
- package/dist/core/push.mjs +58 -47
- package/dist/core/receipts.mjs +8 -3
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +2 -2
- package/dist/core/refs.mjs +5 -5
- package/dist/core/registered-rows.mjs +2 -2
- package/dist/core/repack.mjs +36 -21
- package/dist/core/repo-info.mjs +3 -3
- package/dist/core/repos.mjs +21 -9
- package/dist/core/rules/commit-changes.d.mts +0 -1
- package/dist/core/saved-caller-views.d.mts +7 -2
- package/dist/core/saved-caller-views.mjs +2 -2
- package/dist/core/saved-callers.d.mts +19 -2
- package/dist/core/seam.d.mts +16 -26
- package/dist/core/seam.mjs +7 -28
- package/dist/core/tokens.mjs +1 -1
- package/dist/core/view.mjs +7 -15
- package/dist/core/work.mjs +59 -14
- package/dist/effect.d.mts +3 -12
- package/dist/effect.mjs +1 -10
- package/dist/engine/failures.mjs +2 -1
- package/dist/engine/reads.mjs +4 -4
- package/dist/event-streams/stream.d.mts +2 -2
- package/dist/event-streams/stream.mjs +37 -14
- package/dist/extend.d.mts +2 -3
- package/dist/extend.mjs +2 -1
- package/dist/http/answers.mjs +8 -5
- package/dist/http/core-parts.mjs +95 -79
- package/dist/http/handler.mjs +34 -7
- package/dist/http/node.d.mts +14 -1
- package/dist/http/node.mjs +56 -27
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-upload-job.mjs +30 -26
- package/dist/http/push-uploads.mjs +36 -21
- package/dist/http/upload-pack.mjs +3 -3
- package/dist/index.d.mts +14 -14
- package/dist/index.mjs +2 -2
- package/dist/lfs/answer.mjs +37 -0
- package/dist/lfs/base.d.mts +2 -0
- package/dist/lfs/base.mjs +25 -1
- package/dist/lfs/copy.d.mts +21 -7
- package/dist/lfs/copy.mjs +89 -6
- package/dist/lfs/layer.d.mts +15 -1
- package/dist/lfs/layer.mjs +24 -11
- package/dist/lfs/locks.mjs +2 -2
- package/dist/lfs/objects.d.mts +1 -0
- package/dist/lfs/objects.mjs +87 -17
- package/dist/lfs/pointers.mjs +2 -2
- package/dist/lfs/rows.mjs +42 -8
- package/dist/lfs/upkeep.mjs +48 -14
- package/dist/lfs/wire.mjs +6 -31
- package/dist/merges/merges.mjs +2 -2
- package/dist/node.d.mts +2 -2
- package/dist/protocol/bytes/buffers.mjs +13 -5
- package/dist/protocol/bytes/reader.mjs +6 -1
- package/dist/protocol/bytes/streams.mjs +27 -1
- package/dist/protocol/diff/read.d.mts +4 -3
- package/dist/protocol/diff/read.mjs +8 -3
- package/dist/protocol/objects/lfs-pointer.d.mts +14 -2
- package/dist/protocol/objects/lfs-pointer.mjs +1 -3
- package/dist/protocol/objects/links-raw.mjs +24 -10
- package/dist/protocol/objects/tag.d.mts +1 -1
- package/dist/protocol/objects/tree.mjs +23 -6
- package/dist/protocol/packs/delta.d.mts +6 -3
- package/dist/protocol/packs/delta.mjs +96 -32
- package/dist/protocol/packs/idx.d.mts +2 -1
- package/dist/protocol/packs/idx.mjs +22 -3
- package/dist/protocol/packs/parts.d.mts +4 -1
- package/dist/protocol/packs/parts.mjs +10 -7
- package/dist/protocol/packs/reader.d.mts +5 -0
- package/dist/protocol/packs/reader.mjs +3 -2
- package/dist/protocol/packs/writer.mjs +26 -8
- package/dist/queue/advance.mjs +21 -24
- package/dist/queue/base.d.mts +55 -0
- package/dist/queue/base.mjs +44 -0
- package/dist/queue/calls.mjs +51 -54
- package/dist/queue/commit.mjs +1 -1
- package/dist/queue/host.d.mts +1 -15
- package/dist/queue/host.mjs +2 -7
- package/dist/queue/layer.d.mts +2 -1
- package/dist/queue/layer.mjs +10 -3
- package/dist/queue/limits.mjs +2 -0
- package/dist/queue/push-option.mjs +9 -24
- package/dist/queue/schedule.mjs +1 -1
- package/dist/queue/state.mjs +2 -10
- package/dist/queue/trim.mjs +5 -3
- package/dist/rest/blobs.mjs +29 -5
- package/dist/rest/caller.d.mts +4 -4271
- package/dist/rest/caller.mjs +4 -0
- package/dist/rest/client.d.mts +8 -5
- package/dist/rest/client.mjs +19 -2
- package/dist/rest/handlers.mjs +50 -5
- package/dist/rest/layer.d.mts +2 -2
- package/dist/rest/layer.mjs +5 -12
- package/dist/rest/me.d.mts +3 -432
- package/dist/server/check-fetch.mjs +3 -3
- package/dist/server/edge-node.d.mts +11 -8
- package/dist/server/edge-node.mjs +9 -6
- package/dist/server/edge.d.mts +21 -7
- package/dist/server/edge.mjs +32 -11
- package/dist/server/extension.mjs +1 -1
- package/dist/server/git-layer.d.mts +5 -5
- package/dist/server/git-layer.mjs +28 -22
- package/dist/server/git-namespace.d.mts +4 -3
- package/dist/server/git-namespace.mjs +3 -2
- package/dist/server/joined.d.mts +6 -18
- package/dist/server/joined.mjs +9 -36
- package/dist/server/lifecycle.mjs +18 -106
- package/dist/server/registry.mjs +24 -7
- package/dist/server/server.mjs +205 -346
- package/dist/signin/context.d.mts +1 -2
- package/dist/signin/layer.d.mts +1 -1
- package/dist/signin/layer.mjs +1 -1
- package/dist/storage/allotted.mjs +18 -3
- package/dist/storage/batch-upkeep.mjs +274 -0
- package/dist/storage/batches.d.mts +8 -0
- package/dist/storage/batches.mjs +344 -0
- package/dist/storage/calls.d.mts +1 -2
- package/dist/storage/calls.mjs +144 -158
- package/dist/storage/chunks.d.mts +9 -0
- package/dist/storage/chunks.mjs +297 -0
- package/dist/storage/clean-up.mjs +72 -9
- package/dist/storage/counted-bucket.mjs +4 -4
- package/dist/storage/fetch.d.mts +1 -0
- package/dist/storage/fetch.mjs +287 -210
- package/dist/storage/host-bucket.mjs +1 -2
- package/dist/storage/id-mix.mjs +19 -5
- package/dist/storage/index-bitmaps.mjs +9 -2
- package/dist/storage/index-build.d.mts +0 -1
- package/dist/storage/index-build.mjs +80 -23
- package/dist/storage/index-fetch.mjs +113 -72
- package/dist/storage/index-files.d.mts +3 -0
- package/dist/storage/index-files.mjs +10 -5
- package/dist/storage/index-graph.mjs +72 -22
- package/dist/storage/index-remap.mjs +200 -64
- package/dist/storage/index-whole.mjs +127 -0
- package/dist/storage/largest-files.mjs +1 -1
- package/dist/storage/layout.mjs +23 -0
- package/dist/storage/loose.d.mts +7 -4
- package/dist/storage/loose.mjs +212 -67
- package/dist/storage/memory-budget.mjs +16 -4
- package/dist/storage/merge-plan.mjs +3 -2
- package/dist/storage/merge-row.mjs +7 -1
- package/dist/storage/merge-stream.mjs +164 -25
- package/dist/storage/merge-walk.mjs +8 -4
- package/dist/storage/merge-write.mjs +1 -1
- package/dist/storage/merge.d.mts +1 -1
- package/dist/storage/merge.mjs +1 -1
- package/dist/storage/object-rows.d.mts +1 -0
- package/dist/storage/object-rows.mjs +385 -65
- package/dist/storage/oid-table.mjs +171 -0
- package/dist/storage/pack-order.mjs +8 -4
- package/dist/storage/pack-ranges.d.mts +1 -2
- package/dist/storage/pack-ranges.mjs +4 -5
- package/dist/storage/pack-reads.d.mts +2 -1
- package/dist/storage/pack-reads.mjs +158 -42
- package/dist/storage/pack-receive.d.mts +1 -1
- package/dist/storage/pack-receive.mjs +2 -2
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +136 -66
- package/dist/storage/placed-reads.mjs +1 -1
- package/dist/storage/plan-columns.d.mts +4 -0
- package/dist/storage/plan-columns.mjs +238 -0
- package/dist/storage/prune-keep.mjs +134 -41
- package/dist/storage/prune-walk.mjs +202 -62
- package/dist/storage/prune.mjs +194 -91
- package/dist/storage/push-allotment.mjs +91 -12
- package/dist/storage/push-uploads.mjs +4 -4
- package/dist/storage/pushed-commits.mjs +4 -2
- package/dist/storage/quarantine.d.mts +1 -1
- package/dist/storage/range-cache.mjs +125 -8
- package/dist/storage/ready.d.mts +1 -1
- package/dist/storage/ready.mjs +8 -6
- package/dist/storage/receive-bounds.mjs +23 -8
- package/dist/storage/repack-backlog.mjs +6 -3
- package/dist/storage/repack.d.mts +1 -1
- package/dist/storage/rows.d.mts +1 -1
- package/dist/storage/rows.mjs +1 -1
- package/dist/storage/runs.mjs +195 -43
- package/dist/storage/send-list.d.mts +1 -0
- package/dist/storage/send-list.mjs +54 -10
- package/dist/storage/single-flight.mjs +13 -7
- package/dist/storage/stream-whole.mjs +127 -26
- package/dist/storage/unpack.mjs +371 -79
- package/dist/storage/visible.mjs +2 -2
- package/dist/storage/walk.mjs +192 -38
- package/dist/storage/wants.mjs +5 -5
- package/dist/store/bodies.mjs +38 -0
- package/dist/store/call-count.d.mts +8 -12
- package/dist/store/call-count.mjs +34 -46
- package/dist/store/catalogue.d.mts +2 -2
- package/dist/store/catalogue.mjs +145 -35
- package/dist/store/crossing.mjs +1 -3
- package/dist/store/cursor-seal.d.mts +1 -2
- package/dist/store/cursor-seal.mjs +16 -6
- package/dist/store/door.mjs +183 -0
- package/dist/store/errors.d.mts +3 -4
- package/dist/store/errors.mjs +15 -33
- package/dist/store/git-store.mjs +25 -7
- package/dist/store/job-try.mjs +9 -32
- package/dist/store/list-job.mjs +44 -8
- package/dist/store/records.d.mts +3 -0
- package/dist/store/records.mjs +3 -0
- package/dist/store/repo-record.d.mts +1 -2
- package/dist/store/repo-record.mjs +32 -20
- package/dist/store/reservations.mjs +1 -1
- package/dist/store/scopes.mjs +11 -0
- package/dist/store/settle.mjs +4 -4
- package/dist/sync/github.mjs +3 -3
- package/dist/sync/import.mjs +31 -18
- package/dist/sync/lfs-batch.mjs +4 -5
- package/dist/sync/lfs-copy.mjs +17 -6
- package/dist/sync/mirror.mjs +34 -31
- package/dist/sync/said.mjs +16 -37
- package/dist/sync/step.mjs +33 -25
- package/dist/sync/tries.mjs +9 -9
- package/dist/topics/advance.mjs +10 -11
- package/dist/topics/base.d.mts +15 -0
- package/dist/topics/base.mjs +8 -0
- package/dist/topics/host.mjs +1 -1
- package/dist/topics/layer.d.mts +4 -9
- package/dist/topics/layer.mjs +2 -3
- package/dist/topics/members.mjs +4 -4
- package/dist/topics/public.d.mts +2 -1
- package/dist/topics/topic.mjs +2 -2
- package/package.json +5 -4
- package/dist/contracts/promises.d.mts +0 -39
- package/dist/core/call-names.d.mts +0 -3
- package/dist/core/clock.mjs +0 -18
- package/dist/lfs/calls.mjs +0 -26
- package/dist/rest/api.d.mts +0 -23
- package/dist/rest/blobs.d.mts +0 -833
- package/dist/rest/commits.d.mts +0 -3543
- package/dist/rest/errors.d.mts +0 -2124
- package/dist/rest/events.d.mts +0 -426
- package/dist/rest/files.d.mts +0 -1342
- package/dist/rest/forks.d.mts +0 -2160
- package/dist/rest/handlers.d.mts +0 -8
- package/dist/rest/merges.d.mts +0 -477
- package/dist/rest/queue.d.mts +0 -5917
- package/dist/rest/refs.d.mts +0 -2988
- package/dist/rest/repos.d.mts +0 -2567
- package/dist/rest/tags.d.mts +0 -1316
- package/dist/rest/tokens.d.mts +0 -2614
- package/dist/rest/topics.d.mts +0 -2224
- package/dist/rest/trees.d.mts +0 -1709
- package/dist/rest/work.d.mts +0 -1695
- package/dist/server/lifecycle.d.mts +0 -2
- package/dist/store/promises.d.mts +0 -11
- package/dist/store/promises.mjs +0 -327
package/dist/server/server.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PrivateRefs } from "../contracts/access.mjs";
|
|
2
2
|
import { pushRefLimitOf } from "../core/push-decide.mjs";
|
|
3
|
-
import { millis } from "../contracts/
|
|
3
|
+
import { millis } from "../contracts/time.mjs";
|
|
4
4
|
import { fail } from "../contracts/result.mjs";
|
|
5
5
|
import { Authorize } from "../contracts/authorize.mjs";
|
|
6
6
|
import { RepoRecords } from "../contracts/repo-records.mjs";
|
|
@@ -11,8 +11,8 @@ import { accessOf, audienceOf, authorizer } from "../auth/authorize.mjs";
|
|
|
11
11
|
import { grantFences } from "../auth/fences.mjs";
|
|
12
12
|
import { grantAgain, heldGrants } from "../auth/grants.mjs";
|
|
13
13
|
import { identifier } from "../auth/identify.mjs";
|
|
14
|
-
import {
|
|
15
|
-
import { TokensBase, noTokens } from "../auth/tokens-
|
|
14
|
+
import { tokenCleanupJob } from "../auth/token-cleanup.mjs";
|
|
15
|
+
import { TokensBase, noTokens } from "../auth/tokens-base.mjs";
|
|
16
16
|
import { blobCalls } from "../core/objects/blobs.mjs";
|
|
17
17
|
import { commitCalls } from "../core/objects/commits.mjs";
|
|
18
18
|
import { fileCalls } from "../core/objects/files.mjs";
|
|
@@ -22,8 +22,8 @@ import { treeCalls } from "../core/objects/trees.mjs";
|
|
|
22
22
|
import { acting } from "../core/access.mjs";
|
|
23
23
|
import { refIndexOf } from "../core/ref-index.mjs";
|
|
24
24
|
import { callNames } from "../core/call-names.mjs";
|
|
25
|
-
import { clocksOf } from "../core/clock.mjs";
|
|
26
25
|
import { deliveryLog, workFailed } from "../core/events/deliver.mjs";
|
|
26
|
+
import { checkRetired, newRetireStart, writeRetired } from "../core/events/retired.mjs";
|
|
27
27
|
import { servedSources } from "../core/rules/protect.mjs";
|
|
28
28
|
import { rulesOf } from "../core/rules/service.mjs";
|
|
29
29
|
import { refsAs, refsCalls } from "../core/refs.mjs";
|
|
@@ -38,42 +38,38 @@ import { forkCalls } from "../core/forks.mjs";
|
|
|
38
38
|
import { repoCalls } from "../core/repos.mjs";
|
|
39
39
|
import { EventStreams } from "../event-streams/event-streams.mjs";
|
|
40
40
|
import { streamsOver } from "../event-streams/stream.mjs";
|
|
41
|
-
import {
|
|
41
|
+
import { renamedTo, seamAuthorize } from "../core/seam.mjs";
|
|
42
|
+
import { checkFetchOver } from "./check-fetch.mjs";
|
|
42
43
|
import { tokenCallsAs } from "../core/tokens.mjs";
|
|
43
44
|
import { workCalls } from "../core/work.mjs";
|
|
44
|
-
import {
|
|
45
|
+
import { make } from "../http/core-parts.mjs";
|
|
45
46
|
import { refusal } from "../http/answers.mjs";
|
|
46
|
-
import { LfsBase } from "../lfs/base.mjs";
|
|
47
|
+
import { LfsBase, lfsCalls } from "../lfs/base.mjs";
|
|
47
48
|
import { UploadsBase } from "./uploads.mjs";
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
50
|
-
import { gitUrlOf, normalBase } from "../http/paths.mjs";
|
|
49
|
+
import { make as make$1 } from "../http/handler.mjs";
|
|
50
|
+
import { normalBase } from "../http/paths.mjs";
|
|
51
51
|
import { pushUploadJob } from "../http/push-upload-job.mjs";
|
|
52
|
-
import {
|
|
52
|
+
import { make as make$2 } from "../http/push-uploads.mjs";
|
|
53
53
|
import { hostRecordOf, pinOf } from "../store/catalogue.mjs";
|
|
54
|
-
import { answerOf } from "../contracts/calls-spent.mjs";
|
|
55
54
|
import { closedError } from "../store/closed.mjs";
|
|
56
55
|
import { clientWentAway } from "../store/errors.mjs";
|
|
57
56
|
import { cursorSeal } from "../store/cursor-seal.mjs";
|
|
58
57
|
import { gitStore } from "../store/git-store.mjs";
|
|
59
|
-
import { doorBucket, doorLinks, doorRecords, doorUploads,
|
|
58
|
+
import { doorBucket, doorLinks, doorQueue, doorRecords, doorUploads, throughBridge } from "../store/door.mjs";
|
|
60
59
|
import { defaultFetchLimits } from "../storage/fetch.mjs";
|
|
61
60
|
import { countedBucket } from "../storage/counted-bucket.mjs";
|
|
62
61
|
import { hostFailures, hostLinks, hostUploads } from "../storage/host-bucket.mjs";
|
|
63
62
|
import { pushUploadUpkeep } from "../storage/push-uploads.mjs";
|
|
64
|
-
import { checkedLimits, countedMost, hookCallsBefore, lessBefore
|
|
63
|
+
import { checkedLimits, countedMost, hookCallsBefore, lessBefore } from "../store/call-count.mjs";
|
|
65
64
|
import { jobLimitsOf, jobsWithin } from "../store/job-try.mjs";
|
|
66
|
-
import { exitOn, noCall, syncIn, uncounted } from "../store/crossing.mjs";
|
|
67
65
|
import { pruneFloor } from "../storage/rows.mjs";
|
|
68
|
-
import {
|
|
69
|
-
import {
|
|
70
|
-
import { queuePush } from "../queue/push-option.mjs";
|
|
71
|
-
import { TopicsBase } from "../topics/layer.mjs";
|
|
66
|
+
import { QueueBase, noQueuePush } from "../queue/base.mjs";
|
|
67
|
+
import { TopicsBase } from "../topics/base.mjs";
|
|
72
68
|
import { listJob } from "../store/list-job.mjs";
|
|
73
69
|
import { openExtensions } from "./extension.mjs";
|
|
74
|
-
import {
|
|
75
|
-
import {
|
|
76
|
-
import { aroundCalls, callOrMissing, guardedCalls, heldGroup, lazyGroups, providedCalls
|
|
70
|
+
import { joinedOf } from "./joined.mjs";
|
|
71
|
+
import { retireErrors, retryDelay } from "./lifecycle.mjs";
|
|
72
|
+
import { aroundCalls, callOrMissing, guardedCall, guardedCalls, heldGroup, lazyGroups, providedCalls } from "../core/promise.mjs";
|
|
77
73
|
import { CoreParts, ObjectsParts, QueueParts, SyncBase } from "../core/parts.mjs";
|
|
78
74
|
import { SavedCallers, savedCallersOf } from "../core/saved-caller-views.mjs";
|
|
79
75
|
import { withAudienceMemo } from "../core/ref-view.mjs";
|
|
@@ -83,17 +79,15 @@ import { SealedObjects, View, objectsOverViews, viewOver } from "../core/view.mj
|
|
|
83
79
|
import { IndexedStorage, Objects, Storage } from "../core/objects/objects.mjs";
|
|
84
80
|
import { pushFilesOf } from "../core/push-files.mjs";
|
|
85
81
|
import { pushRepoOf } from "../core/push-repo.mjs";
|
|
86
|
-
import * as Clock
|
|
82
|
+
import * as Clock from "effect/Clock";
|
|
87
83
|
import * as Effect from "effect/Effect";
|
|
88
84
|
import * as Option from "effect/Option";
|
|
89
85
|
import * as Cause from "effect/Cause";
|
|
90
|
-
import * as Exit from "effect/Exit";
|
|
91
86
|
import * as EffectResult from "effect/Result";
|
|
92
87
|
import { Bucket, BucketLinks, BucketUploads, CallLimits, JobQueue, Records, RequestLimits } from "@ref0/infra";
|
|
93
88
|
import * as Context from "effect/Context";
|
|
94
|
-
import * as Layer from "effect/Layer";
|
|
95
89
|
import * as References from "effect/References";
|
|
96
|
-
import * as
|
|
90
|
+
import * as Duration from "effect/Duration";
|
|
97
91
|
// src/server/server.ts
|
|
98
92
|
/**
|
|
99
93
|
* The server's `fetchLimits`, or a `TypeError` naming the one that isn't a whole number above 0,
|
|
@@ -123,32 +117,24 @@ const boundOf = (most) => ({
|
|
|
123
117
|
bucket: most?.bucket ?? Number.POSITIVE_INFINITY,
|
|
124
118
|
subrequests: most?.subrequests ?? Number.POSITIVE_INFINITY
|
|
125
119
|
});
|
|
126
|
-
/** The
|
|
127
|
-
const
|
|
128
|
-
/**
|
|
129
|
-
* The groups a face names: every group less `topics`, which is the `Topics` service's, `tokens`
|
|
130
|
-
* unless `tokensOn`, and `queue` unless `queueOn`.
|
|
131
|
-
*/
|
|
132
|
-
const namesOf = (tokensOn, queueOn) => {
|
|
120
|
+
/** The groups a joined face names: every group less `topics`, which is the `Topics` service's. */
|
|
121
|
+
const joinedNamesOf = () => {
|
|
133
122
|
const names = { ...callNames };
|
|
134
123
|
delete names.topics;
|
|
135
|
-
if (!tokensOn) delete names.tokens;
|
|
136
|
-
if (!queueOn) delete names.queue;
|
|
137
124
|
return names;
|
|
138
125
|
};
|
|
139
126
|
/** Git's own wiring over the adapter's services, as the runtime's build runs it. */
|
|
140
127
|
const wireServer = (options, wiring) => {
|
|
141
128
|
const { adapter, fetchLimits, files, repo, deciders, grants, extensions, guard, through, closing } = wiring;
|
|
142
129
|
const runtimeClock = wiring.clock;
|
|
143
|
-
const {
|
|
144
|
-
const
|
|
130
|
+
const { jobs, records: store } = adapter;
|
|
131
|
+
const now = Effect.sync(() => runtimeClock.currentTimeMillisUnsafe());
|
|
145
132
|
const counted = adapter.bucket === void 0 ? void 0 : countedBucket(adapter.bucket);
|
|
146
133
|
const callLimits = lessBefore(checkedLimits(adapter.callLimits, "The adapter's callLimits."));
|
|
147
|
-
const jobLimits = jobLimitsOf(adapter.callLimits);
|
|
148
134
|
const opening = {
|
|
149
135
|
store: gitStore(store),
|
|
150
136
|
bucket: adapter.objectsBucket,
|
|
151
|
-
clock,
|
|
137
|
+
clock: runtimeClock,
|
|
152
138
|
fetchLimits,
|
|
153
139
|
callLimits
|
|
154
140
|
};
|
|
@@ -156,24 +142,31 @@ const wireServer = (options, wiring) => {
|
|
|
156
142
|
const indexed = wiring.access === void 0 ? void 0 : indexedOpen(options.objects, opening);
|
|
157
143
|
const objects = indexed ?? options.objects.open(opening);
|
|
158
144
|
const sealed = indexed === void 0 ? new SealedObjects(objects) : SealedObjects.indexed(indexed);
|
|
159
|
-
const cleanup = tokenCleanupJob(now);
|
|
145
|
+
const cleanup = tokenCleanupJob(store, now);
|
|
160
146
|
const { registry } = extensions;
|
|
161
147
|
const events = deliveryLog({
|
|
162
148
|
store,
|
|
163
149
|
now,
|
|
164
150
|
fetchLimits
|
|
165
151
|
});
|
|
166
|
-
|
|
167
|
-
|
|
152
|
+
const retired = options.events?.retired ?? [];
|
|
153
|
+
registry.bindDeliveries((registered) => {
|
|
154
|
+
checkRetired(registered.map((delivery) => delivery.name), retired);
|
|
155
|
+
return events.fill(registered);
|
|
156
|
+
});
|
|
157
|
+
const onFailure = workFailed(store, events, now);
|
|
168
158
|
const upkeep = upkeepsOf([...counted === void 0 ? [] : [pushUploadUpkeep(counted, adapter.uploads)], registry.upkeep]);
|
|
169
159
|
const index = objects.index === void 0 ? void 0 : indexJob({
|
|
160
|
+
store,
|
|
170
161
|
objects: sealed,
|
|
171
162
|
now,
|
|
172
163
|
events,
|
|
173
|
-
repackJobRow: () => repackJobRow(repack)
|
|
164
|
+
repackJobRow: () => repackJobRow(repack),
|
|
165
|
+
cpuMs: adapter.requestLimits.cpuMs
|
|
174
166
|
});
|
|
175
167
|
const indexRow = index === void 0 ? void 0 : (round) => indexJobRow(index, round);
|
|
176
168
|
const repack = repackJob({
|
|
169
|
+
store,
|
|
177
170
|
objects: sealed,
|
|
178
171
|
now,
|
|
179
172
|
fetchLimits,
|
|
@@ -183,8 +176,12 @@ const wireServer = (options, wiring) => {
|
|
|
183
176
|
indexJobRow: indexRow
|
|
184
177
|
});
|
|
185
178
|
const refIndex = refIndexOf(wiring.access, registry.hiddenRefs);
|
|
186
|
-
const rebuild = refIndex === void 0 ? void 0 : refIndexJob({
|
|
179
|
+
const rebuild = refIndex === void 0 ? void 0 : refIndexJob({
|
|
180
|
+
store,
|
|
181
|
+
index: refIndex
|
|
182
|
+
});
|
|
187
183
|
const purge = purgeJob({
|
|
184
|
+
store,
|
|
188
185
|
now,
|
|
189
186
|
fetchLimits,
|
|
190
187
|
parts: [registry.purge],
|
|
@@ -192,7 +189,7 @@ const wireServer = (options, wiring) => {
|
|
|
192
189
|
deliveries: events.deliveries
|
|
193
190
|
});
|
|
194
191
|
const own = [
|
|
195
|
-
listJob,
|
|
192
|
+
listJob(store),
|
|
196
193
|
repack,
|
|
197
194
|
purge
|
|
198
195
|
];
|
|
@@ -201,7 +198,6 @@ const wireServer = (options, wiring) => {
|
|
|
201
198
|
own.push(cleanup);
|
|
202
199
|
const gits = registry.bridge("git");
|
|
203
200
|
gits.knowJobs(own);
|
|
204
|
-
jobs.register(...jobsWithin(jobLimits, own));
|
|
205
201
|
const decides = {
|
|
206
202
|
policy: deciders.policy,
|
|
207
203
|
grants
|
|
@@ -266,24 +262,24 @@ const wireServer = (options, wiring) => {
|
|
|
266
262
|
files,
|
|
267
263
|
repo
|
|
268
264
|
}), Context.add(Objects, objectsOverViews), Context.add(Changes, changes));
|
|
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
|
|
265
|
+
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.Clock, runtimeClock), Context.merge(wiring.logging));
|
|
270
266
|
const viewed = Context.add(base, View, viewOver(base));
|
|
271
267
|
const needs = Context.add(viewed, Refs, providedCalls(refsCalls, viewed));
|
|
272
268
|
const streams = streamsOver({
|
|
273
|
-
clock,
|
|
269
|
+
clock: runtimeClock,
|
|
274
270
|
guard,
|
|
275
271
|
closing,
|
|
276
272
|
through
|
|
277
273
|
}, needs);
|
|
278
274
|
const queueHeld = wiring.queue;
|
|
279
275
|
const queueBase = QueueBase.of({
|
|
280
|
-
records:
|
|
276
|
+
records: store,
|
|
281
277
|
needs,
|
|
282
278
|
onFailure,
|
|
283
279
|
cpuMs: adapter.requestLimits.cpuMs,
|
|
284
|
-
attach: (
|
|
285
|
-
if (queueHeld.
|
|
286
|
-
queueHeld.
|
|
280
|
+
attach: (queue) => Effect.suspend(() => {
|
|
281
|
+
if (queueHeld.attached !== void 0) return Effect.die(/* @__PURE__ */ new TypeError("The server has a merge queue: provide MergeQueue.layer once"));
|
|
282
|
+
queueHeld.attached = queue;
|
|
287
283
|
return Effect.void;
|
|
288
284
|
})
|
|
289
285
|
});
|
|
@@ -318,14 +314,14 @@ const wireServer = (options, wiring) => {
|
|
|
318
314
|
}
|
|
319
315
|
})];
|
|
320
316
|
gits.knowJobs(stepJobs);
|
|
321
|
-
|
|
317
|
+
own.push(...stepJobs);
|
|
322
318
|
}
|
|
323
319
|
let uploadsAttached;
|
|
324
320
|
const uploadsBase = UploadsBase.of({
|
|
325
321
|
staging,
|
|
326
322
|
attach: (above) => Effect.suspend(() => {
|
|
327
323
|
if (staging === void 0 || uploadsAttached !== void 0) return Effect.die(/* @__PURE__ */ new TypeError("The server takes push uploads: provide Git.layerUploads once"));
|
|
328
|
-
uploadsAttached =
|
|
324
|
+
uploadsAttached = make$2(needs, staging, above, adapter.requestLimits.cpuMs);
|
|
329
325
|
return Effect.void;
|
|
330
326
|
})
|
|
331
327
|
});
|
|
@@ -335,15 +331,14 @@ const wireServer = (options, wiring) => {
|
|
|
335
331
|
}) });
|
|
336
332
|
const tokensHeld = wiring.tokens;
|
|
337
333
|
const tokensBase = TokensBase.of({
|
|
338
|
-
|
|
334
|
+
store,
|
|
335
|
+
now,
|
|
336
|
+
cleanup,
|
|
337
|
+
events,
|
|
338
|
+
attach: (calls) => Effect.suspend(() => {
|
|
339
339
|
if (tokensHeld.calls !== void 0) return Effect.die(/* @__PURE__ */ new TypeError("The server has Git's own tokens: provide Tokens.layer() once"));
|
|
340
|
-
tokensHeld.calls =
|
|
341
|
-
|
|
342
|
-
now,
|
|
343
|
-
cleanup,
|
|
344
|
-
events
|
|
345
|
-
});
|
|
346
|
-
return Effect.succeed(tokensHeld.calls);
|
|
340
|
+
tokensHeld.calls = calls;
|
|
341
|
+
return Effect.void;
|
|
347
342
|
}),
|
|
348
343
|
held: Effect.sync(() => tokensHeld.calls === void 0 ? void 0 : {
|
|
349
344
|
tokens: tokensHeld.calls,
|
|
@@ -361,11 +356,11 @@ const wireServer = (options, wiring) => {
|
|
|
361
356
|
held: grants,
|
|
362
357
|
now
|
|
363
358
|
});
|
|
364
|
-
const decided = Context.add(records, Authorize, decider).pipe(Context.add(Refs, Context.get(needs, Refs)), Context.add(Rules, wiring.rules), Context.add(Objects, objectsOverViews), Context.merge(callServices(needs)), Context.add(Events, { log: events }), Context.add(QueueBase, queueBase), Context.add(SyncBase, {
|
|
359
|
+
const decided = Context.add(records, Authorize, decider).pipe(Context.add(Refs, Context.get(needs, Refs)), Context.add(Rules, wiring.rules), Context.add(Objects, objectsOverViews), Context.merge(callServices(needs, (effect) => withAudienceMemo(guardedCall(wiring.through)(effect)))), Context.add(Events, { log: events }), Context.add(QueueBase, queueBase), Context.add(SyncBase, {
|
|
365
360
|
needs,
|
|
366
361
|
pushRefsMost: pushRefLimitOf(refIndex),
|
|
367
362
|
through: wiring.through
|
|
368
|
-
}), Context.add(SavedCallers, savedCallersOf(needs,
|
|
363
|
+
}), Context.add(SavedCallers, savedCallersOf(needs, (entry) => queueHeld.attached === void 0 ? Effect.succeed(void 0) : queueHeld.attached.entryAdder(entry))), Context.add(LfsBase, lfsBase), Context.add(UploadsBase, uploadsBase), Context.add(TopicsBase, topicsBase), Context.add(TokensBase, tokensBase));
|
|
369
364
|
const services = Context.add(decided, EventStreams, { feed: streams.feed });
|
|
370
365
|
/**
|
|
371
366
|
* Every group of the server's calls deciding for `bound`, over `needs`: the one list `callsAs`
|
|
@@ -388,8 +383,8 @@ const wireServer = (options, wiring) => {
|
|
|
388
383
|
merges: over(mergeCalls(bound)),
|
|
389
384
|
lfs: over(lfsCalls(() => lfsAttached?.read, bound))
|
|
390
385
|
};
|
|
391
|
-
const queue = queueHeld.
|
|
392
|
-
if (queue !== void 0) groups.queue = aroundCalls(
|
|
386
|
+
const queue = queueHeld.attached;
|
|
387
|
+
if (queue !== void 0) groups.queue = aroundCalls(queue.calls(bound), (effect) => Effect.provideContext(acting(bound, effect), queue.host.needs));
|
|
393
388
|
if (topicsAttached !== void 0) {
|
|
394
389
|
const topics = topicsAttached;
|
|
395
390
|
groups.topics = {
|
|
@@ -407,18 +402,18 @@ const wireServer = (options, wiring) => {
|
|
|
407
402
|
const callsAs = (bound) => groupsOf(bound);
|
|
408
403
|
const { basePath } = wiring;
|
|
409
404
|
const requestMost = boundOf(adapter.callLimits);
|
|
410
|
-
const
|
|
405
|
+
const clockedIdentify = (request) => Effect.provideService(identify(request), Clock.Clock, runtimeClock);
|
|
406
|
+
const rest = {
|
|
411
407
|
basePath,
|
|
412
|
-
needs,
|
|
413
408
|
callsFor: (caller) => aroundCalls(guardedCalls(callsAs(caller), through), withAudienceMemo),
|
|
414
|
-
tokensOn: Effect.sync(() => tokensHeld.calls !== void 0),
|
|
415
|
-
identify: (request) => through(
|
|
409
|
+
tokensOn: through(Effect.sync(() => tokensHeld.calls !== void 0)),
|
|
410
|
+
identify: (request) => through(clockedIdentify(request)),
|
|
416
411
|
authorize: (input) => through(Effect.provideContext(seamAuthorize(input), needs)),
|
|
417
412
|
renamedTo: (caller, repo) => through(Effect.provideContext(renamedTo(caller, repo), needs)),
|
|
418
413
|
listen: (caller, repo, after) => through(Effect.suspend(() => !keepsEvents(events) ? fail("FAILED_PRECONDITION", "This server keeps no events", { hostHint: "Its host registers a delivery, with Git.register, to keep them" }) : streams.open(caller, repo, after))),
|
|
419
414
|
requestMost
|
|
420
415
|
};
|
|
421
|
-
const httpOptions = { queue:
|
|
416
|
+
const httpOptions = { queue: (...push) => (queueHeld.attached?.push ?? noQueuePush)(...push) };
|
|
422
417
|
if (options.maxDuration !== void 0) httpOptions.maxDuration = millis(options.maxDuration);
|
|
423
418
|
if (objects.pushObjectsMost !== void 0) httpOptions.pushObjectsMost = objects.pushObjectsMost;
|
|
424
419
|
const fetchHooks = wiring.rules.fetch.length === 0 ? 0 : 1;
|
|
@@ -430,315 +425,179 @@ const wireServer = (options, wiring) => {
|
|
|
430
425
|
httpOptions.pushCalls = before(0)(callLimits);
|
|
431
426
|
httpOptions.lfs = () => lfsAttached?.service;
|
|
432
427
|
httpOptions.uploads = () => stepping ? uploadsAttached : void 0;
|
|
433
|
-
httpParts =
|
|
434
|
-
|
|
428
|
+
httpParts = make({
|
|
429
|
+
basePath,
|
|
430
|
+
identify: rest.identify,
|
|
431
|
+
renamedTo: rest.renamedTo
|
|
432
|
+
}, httpOptions);
|
|
433
|
+
const http = make$1(httpParts);
|
|
435
434
|
return {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
clock: adapter.clock
|
|
441
|
-
},
|
|
442
|
-
get calls() {
|
|
443
|
-
return callsAs();
|
|
444
|
-
},
|
|
435
|
+
rest,
|
|
436
|
+
needs,
|
|
437
|
+
requestMost,
|
|
438
|
+
adapter: { bucket: adapter.bucket },
|
|
445
439
|
callsAs,
|
|
446
440
|
get hostCalls() {
|
|
447
441
|
return groupsOf(host);
|
|
448
442
|
},
|
|
449
|
-
identify,
|
|
443
|
+
identify: clockedIdentify,
|
|
450
444
|
http,
|
|
451
445
|
services,
|
|
452
446
|
checkSources: () => {
|
|
453
|
-
if (queueHeld.
|
|
454
|
-
}
|
|
447
|
+
if (queueHeld.attached === void 0) servedSources(wiring.rules.push);
|
|
448
|
+
},
|
|
449
|
+
retire: Effect.map(newRetireStart(), (start) => writeRetired(store, retired, start)),
|
|
450
|
+
ownJobs: own
|
|
455
451
|
};
|
|
456
452
|
};
|
|
457
|
-
/**
|
|
458
|
-
const
|
|
453
|
+
/** Interrupts as `signal` aborts, as a client that went away or a server that closed stops its run. */
|
|
454
|
+
const interruptedBy = (signal) => Effect.callback((resume) => {
|
|
455
|
+
const interrupt = () => resume(Effect.interrupt);
|
|
456
|
+
if (signal.aborted) return interrupt();
|
|
457
|
+
signal.addEventListener("abort", interrupt, { once: true });
|
|
458
|
+
return Effect.sync(() => signal.removeEventListener("abort", interrupt));
|
|
459
|
+
});
|
|
459
460
|
/**
|
|
460
|
-
* The server
|
|
461
|
-
*
|
|
461
|
+
* The server, built in the host's own build: its wiring over the host's services, with no runtime
|
|
462
|
+
* of its own, so its build's failure is the host's, and its close is the host's scope's. A call in
|
|
463
|
+
* flight as the scope closes dies with the closed error, as a joined package's does.
|
|
462
464
|
*/
|
|
463
|
-
const
|
|
464
|
-
const setup = options;
|
|
465
|
+
const buildServer = /* @__PURE__ */ Effect.fnUntraced(function* (setup, decidersOf) {
|
|
465
466
|
const fetchLimits = fetchLimitsOf(setup.fetchLimits);
|
|
466
467
|
const files = pushFilesOf(setup.pushes?.files);
|
|
467
468
|
const repo = pushRepoOf(setup.pushes?.repo);
|
|
468
469
|
const grants = heldGrants();
|
|
469
470
|
const basePath = normalBase(setup.basePath ?? "");
|
|
470
|
-
const
|
|
471
|
-
const
|
|
472
|
-
|
|
471
|
+
const closer = new AbortController();
|
|
472
|
+
const closing = closer.signal;
|
|
473
|
+
yield* Effect.addFinalizer(() => Effect.sync(() => closer.abort(closedError())));
|
|
474
|
+
const isClosed = () => closing.aborted;
|
|
473
475
|
const guard = Effect.suspend(() => isClosed() ? Effect.die(closedError()) : Effect.void);
|
|
474
476
|
const door = {
|
|
475
|
-
refusal: () =>
|
|
476
|
-
closing
|
|
477
|
+
refusal: () => isClosed() ? closedError() : void 0,
|
|
478
|
+
closing
|
|
477
479
|
};
|
|
478
|
-
const through =
|
|
479
|
-
const closingWith = (signal) => signal === void 0 ?
|
|
480
|
+
const through = throughBridge(door);
|
|
481
|
+
const closingWith = (signal) => signal === void 0 ? closing : AbortSignal.any([signal, closing]);
|
|
480
482
|
const tokensHeld = { calls: void 0 };
|
|
481
|
-
const queueHeld = {
|
|
482
|
-
const
|
|
483
|
-
const
|
|
484
|
-
const queueOn = () => queueHeld.host !== void 0;
|
|
483
|
+
const queueHeld = { attached: void 0 };
|
|
484
|
+
const joinedNames = joinedNamesOf();
|
|
485
|
+
const queueOn = () => queueHeld.attached !== void 0;
|
|
485
486
|
const joinedCall = (calls, group, name) => callOrMissing(calls, group, name, () => Effect.fail(noTokens));
|
|
486
|
-
const
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
let registerLater;
|
|
494
|
-
let checkLater;
|
|
495
|
-
const seal = Effect.suspend(() => {
|
|
496
|
-
const register = registerLater;
|
|
497
|
-
const check = checkLater;
|
|
498
|
-
if (register === void 0 || check === void 0) return Effect.die(/* @__PURE__ */ new Error("Git's registry seals after the server's build"));
|
|
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)))));
|
|
487
|
+
const records = yield* Records.Records;
|
|
488
|
+
const queue = yield* JobQueue.JobQueue;
|
|
489
|
+
const callLimits = yield* CallLimits.CallLimits;
|
|
490
|
+
const extensions = openExtensions({
|
|
491
|
+
basePath,
|
|
492
|
+
fetchWindow: Duration.millis(fetchLimits.milliseconds),
|
|
493
|
+
requestMost: boundOf(callLimits)
|
|
500
494
|
});
|
|
501
|
-
const
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
objectsBucket: Option.isSome(bucket) ? doorBucket(bucket.value, context, door) : void 0,
|
|
521
|
-
links: Option.isSome(links) ? doorLinks(hostLinks(links.value), context, door) : void 0,
|
|
522
|
-
uploads: Option.isSome(uploads) ? doorUploads(hostUploads(uploads.value), context, door) : void 0,
|
|
523
|
-
clock: promisesClock(clock, context, door),
|
|
524
|
-
callLimits,
|
|
525
|
-
requestLimits: Option.getOrElse(requestLimits, () => ({}))
|
|
526
|
-
};
|
|
527
|
-
const given = {
|
|
528
|
-
adapter,
|
|
529
|
-
rules,
|
|
530
|
-
tokens: tokensHeld,
|
|
531
|
-
queue: queueHeld,
|
|
532
|
-
fetchLimits,
|
|
533
|
-
files,
|
|
534
|
-
repo,
|
|
535
|
-
deciders: decidersOf(),
|
|
536
|
-
grants,
|
|
537
|
-
extensions,
|
|
538
|
-
basePath,
|
|
539
|
-
clock,
|
|
540
|
-
logging,
|
|
541
|
-
access: Option.getOrUndefined(yield* Effect.serviceOption(PrivateRefs))
|
|
542
|
-
};
|
|
543
|
-
const wired = yield* Effect.sync(() => wireServer(setup, {
|
|
544
|
-
...given,
|
|
545
|
-
guard,
|
|
546
|
-
closing: life.closing,
|
|
547
|
-
through,
|
|
548
|
-
runtime
|
|
549
|
-
}));
|
|
550
|
-
const jobLimits = jobLimitsOf(callLimits);
|
|
551
|
-
const register = (jobs) => adapter.jobs.register(...jobsWithin(jobLimits, jobs));
|
|
552
|
-
registerLater = register;
|
|
553
|
-
checkLater = wired.checkSources;
|
|
554
|
-
return Context.add(wired.services, Wired, wired);
|
|
555
|
-
}));
|
|
556
|
-
const { adapter } = setup;
|
|
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
|
-
});
|
|
563
|
-
return Layer.provideMerge(wiring, host);
|
|
564
|
-
}).pipe(Layer.tap((built) => Effect.sync(() => {
|
|
565
|
-
life.move({
|
|
566
|
-
kind: "built",
|
|
567
|
-
wired: Context.get(built, Wired)
|
|
568
|
-
});
|
|
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();
|
|
495
|
+
const requestLimits = yield* Effect.serviceOption(RequestLimits.RequestLimits);
|
|
496
|
+
const bucket = yield* Effect.serviceOption(Bucket.Bucket);
|
|
497
|
+
const links = yield* Effect.serviceOption(BucketLinks.BucketLinks);
|
|
498
|
+
const uploads = yield* Effect.serviceOption(BucketUploads.BucketUploads);
|
|
499
|
+
const clock = yield* Effect.clockWith(Effect.succeed);
|
|
500
|
+
const logging = Context.make(References.CurrentLoggers, yield* References.CurrentLoggers).pipe(Context.add(References.MinimumLogLevel, yield* References.MinimumLogLevel));
|
|
501
|
+
const rules = yield* rulesOf(setup.rules ?? []);
|
|
502
|
+
const host = Context.omit(Rules)(yield* Effect.context());
|
|
503
|
+
const guardedRecords = doorRecords(records, host, door);
|
|
504
|
+
extensions.registry.bindRecords(guardedRecords);
|
|
505
|
+
const adapter = {
|
|
506
|
+
records: guardedRecords,
|
|
507
|
+
jobs: doorQueue(queue, host, door, () => clock.currentTimeMillisUnsafe()),
|
|
508
|
+
bucket: Option.isSome(bucket) ? doorBucket(hostFailures(bucket.value), host, door) : void 0,
|
|
509
|
+
objectsBucket: Option.isSome(bucket) ? doorBucket(bucket.value, host, door) : void 0,
|
|
510
|
+
links: Option.isSome(links) ? doorLinks(hostLinks(links.value), host, door) : void 0,
|
|
511
|
+
uploads: Option.isSome(uploads) ? doorUploads(hostUploads(uploads.value), host, door) : void 0,
|
|
512
|
+
callLimits,
|
|
513
|
+
requestLimits: Option.getOrElse(requestLimits, () => ({}))
|
|
597
514
|
};
|
|
515
|
+
const access = Option.getOrUndefined(yield* Effect.serviceOption(PrivateRefs));
|
|
516
|
+
const wired = yield* Effect.sync(() => wireServer(setup, {
|
|
517
|
+
adapter,
|
|
518
|
+
rules,
|
|
519
|
+
tokens: tokensHeld,
|
|
520
|
+
queue: queueHeld,
|
|
521
|
+
fetchLimits,
|
|
522
|
+
files,
|
|
523
|
+
repo,
|
|
524
|
+
deciders: decidersOf(),
|
|
525
|
+
grants,
|
|
526
|
+
extensions,
|
|
527
|
+
basePath,
|
|
528
|
+
clock,
|
|
529
|
+
logging,
|
|
530
|
+
access,
|
|
531
|
+
guard,
|
|
532
|
+
closing,
|
|
533
|
+
through
|
|
534
|
+
}));
|
|
535
|
+
const jobLimits = jobLimitsOf(callLimits);
|
|
536
|
+
yield* Effect.orDie(adapter.jobs.addJobs(...jobsWithin(jobLimits, wired.ownJobs)));
|
|
537
|
+
const seal = Effect.flatMap(extensions.registry.seal(), (jobs) => Effect.sync(wired.checkSources).pipe(Effect.andThen(Effect.all(extensions.registry.sealChecks(), { discard: true })), Effect.andThen(Effect.orDie(adapter.jobs.addJobs(...jobsWithin(jobLimits, jobs))))));
|
|
598
538
|
/**
|
|
599
|
-
*
|
|
600
|
-
*
|
|
601
|
-
* server
|
|
602
|
-
|
|
603
|
-
const enter = async () => {
|
|
604
|
-
const settled = () => {
|
|
605
|
-
const admitted = life.admit("call");
|
|
606
|
-
if (admitted === "closed") throw closedError();
|
|
607
|
-
const now = life.now();
|
|
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
|
-
};
|
|
617
|
-
};
|
|
618
|
-
const before = settled();
|
|
619
|
-
if (before !== void 0) return before;
|
|
620
|
-
rebuild();
|
|
621
|
-
const exit = await exitOn(runtime, Effect.service(Wired), noCall);
|
|
622
|
-
return settled() ?? (Exit.isSuccess(exit) ? {
|
|
623
|
-
kind: "success",
|
|
624
|
-
value: exit.value
|
|
625
|
-
} : {
|
|
626
|
-
kind: "error",
|
|
627
|
-
error: unavailable(exit.cause)
|
|
628
|
-
});
|
|
629
|
-
};
|
|
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. */
|
|
632
|
-
const run = async (use, crossing, signal) => {
|
|
633
|
-
const built = await enter();
|
|
634
|
-
if (built.kind === "error") return built;
|
|
635
|
-
return runCall(use(built.value), crossing, signal);
|
|
636
|
-
};
|
|
637
|
-
/**
|
|
638
|
-
* The calls over the built server's `calls`, made before it's built: a host's, each counted into
|
|
639
|
-
* `budget` when given, and into no request's scope otherwise.
|
|
640
|
-
*/
|
|
641
|
-
const callsOver = (calls, budget, given = names) => lazyGroups(given, (group, name, args) => run((built) => joinedCall(calls(built), group, name)(...args), budget === void 0 ? noScope : {
|
|
642
|
-
calls: void 0,
|
|
643
|
-
budget
|
|
644
|
-
}, signalOf(args)));
|
|
645
|
-
/**
|
|
646
|
-
* `answering`'s answer to `request`. A client that went away, by its signal or mid-body, gets an
|
|
647
|
-
* empty 499, as Effect's HTTP server answers one, logged once at info with the path alone: an
|
|
648
|
-
* archive's link carries its token in the query. Any other interrupt throws, as it did before.
|
|
539
|
+
* `answering`'s answer to `request`, in the caller's fiber, stopped as the client goes away or the
|
|
540
|
+
* server closes. A client that went away, by its signal or mid-body, gets an empty 499, as
|
|
541
|
+
* Effect's HTTP server answers one, logged once at info with the path alone: an archive's link
|
|
542
|
+
* carries its token in the query. A closed server dies with the closed error.
|
|
649
543
|
*/
|
|
650
|
-
const
|
|
651
|
-
|
|
652
|
-
const exit = await exitOn(runtime, withAudienceMemo(answering), uncounted("a request: each Git route sets its own count, and sign-in's and the event stream's none"), closingWith(request.signal));
|
|
653
|
-
if (isClosed()) throw closedError();
|
|
654
|
-
if (Exit.isSuccess(exit)) return exit.value;
|
|
655
|
-
if (!Cause.hasInterruptsOnly(exit.cause) || !clientWentAway(request)) throw Cause.squash(exit.cause);
|
|
656
|
-
const path = new URL(request.url).pathname;
|
|
657
|
-
syncIn(Effect.logInfo("The client went away before its answer").pipe(Effect.annotateLogs({
|
|
544
|
+
const answering = (request, effect) => {
|
|
545
|
+
const gone = Effect.suspend(() => Effect.logInfo("The client went away before its answer").pipe(Effect.annotateLogs({
|
|
658
546
|
method: request.method,
|
|
659
|
-
path
|
|
660
|
-
}))
|
|
661
|
-
return
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
if (built.kind === "error") {
|
|
667
|
-
const url = new URL(request.url);
|
|
668
|
-
return gitUrlOf(url, basePath) !== void 0 || extensions.registry.routeOf(/* @__PURE__ */ new Set([
|
|
669
|
-
"pre",
|
|
670
|
-
"plain",
|
|
671
|
-
"post"
|
|
672
|
-
]), request, url.pathname) !== void 0 ? refusal(built.error) : void 0;
|
|
673
|
-
}
|
|
674
|
-
const path = new URL(request.url).pathname;
|
|
675
|
-
const first = extensions.registry.routeOf(/* @__PURE__ */ new Set(["pre", "plain"]), request, path);
|
|
676
|
-
if (first !== void 0) return answerTo(request, first.handle(first.request));
|
|
677
|
-
const { http } = built.value;
|
|
678
|
-
const answered = await answerTo(request, http.route(request));
|
|
679
|
-
if (answered !== void 0) return answered;
|
|
680
|
-
const last = extensions.registry.routeOf(/* @__PURE__ */ new Set(["post"]), request, path);
|
|
681
|
-
return last === void 0 ? void 0 : answerTo(request, last.handle(last.request));
|
|
547
|
+
path: new URL(request.url).pathname
|
|
548
|
+
})));
|
|
549
|
+
return Effect.suspend(() => isClosed() ? Effect.die(closedError()) : Effect.void).pipe(Effect.andThen(Effect.raceFirst(withAudienceMemo(effect), interruptedBy(closingWith(request.signal)))), Effect.catchCause((cause) => {
|
|
550
|
+
if (isClosed()) return Effect.die(closedError());
|
|
551
|
+
if (!Cause.hasInterruptsOnly(cause) || !clientWentAway(request)) return Effect.die(Cause.squash(cause));
|
|
552
|
+
return Effect.as(gone, new Response(null, { status: 499 }));
|
|
553
|
+
}), Effect.onInterrupt(() => Effect.andThen(Effect.yieldNow, Effect.suspend(() => !isClosed() && clientWentAway(request) ? gone : Effect.void))), Effect.tap(() => isClosed() ? Effect.die(closedError()) : Effect.void));
|
|
682
554
|
};
|
|
683
|
-
const
|
|
684
|
-
...callsOver((built) => built.calls),
|
|
685
|
-
fetch: async (request) => await route(request) ?? new Response("Not found", { status: 404 }),
|
|
686
|
-
route,
|
|
687
|
-
identify: (request) => run((built) => built.identify(request), uncounted("a host's identify: no Git request"), request.signal),
|
|
688
|
-
get runtime() {
|
|
689
|
-
return runtime;
|
|
690
|
-
},
|
|
691
|
-
close: async () => {
|
|
692
|
-
life.move({ kind: "closed" });
|
|
693
|
-
await runtime.dispose();
|
|
694
|
-
}
|
|
695
|
-
};
|
|
696
|
-
attachJoins(server, {
|
|
697
|
-
admit: life.admit,
|
|
555
|
+
const joined = joinedOf({
|
|
698
556
|
addSealCheck: extensions.registry.addSealCheck,
|
|
699
557
|
basePath,
|
|
700
558
|
fetchLimits,
|
|
701
559
|
get queueKeys() {
|
|
702
|
-
return queueHeld.host
|
|
560
|
+
return queueHeld.attached?.host.keys;
|
|
703
561
|
},
|
|
704
|
-
built: wired,
|
|
705
562
|
through,
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
return heldGroup(callsOver((built) => {
|
|
710
|
-
const tokens = tokensHeld.calls !== void 0;
|
|
711
|
-
const queue = queueOn();
|
|
712
|
-
if (calls?.tokens !== tokens || calls.queue !== queue) calls = {
|
|
713
|
-
tokens,
|
|
714
|
-
queue,
|
|
715
|
-
made: built.callsAs(caller)
|
|
716
|
-
};
|
|
717
|
-
return calls.made;
|
|
718
|
-
}, budget, joinedNames), "queue", queueOn);
|
|
719
|
-
},
|
|
720
|
-
hostCalls: heldGroup(callsOver((built) => built.hostCalls, void 0, joinedNames), "queue", queueOn),
|
|
721
|
-
effectHostCalls: heldGroup(aroundCalls(guardedCalls(lazyGroups(joinedNames, (group, name, args) => Effect.flatMap(wired, (built) => joinedCall(built.hostCalls, group, name)(...args))), through), withAudienceMemo), "queue", queueOn),
|
|
722
|
-
identify: (request, budget) => run((built) => built.identify(request), {
|
|
723
|
-
calls: void 0,
|
|
724
|
-
budget
|
|
725
|
-
}, request.signal)
|
|
726
|
-
});
|
|
727
|
-
attachParts(server, {
|
|
728
|
-
basePath,
|
|
729
|
-
names: joinedNames,
|
|
730
|
-
queueOn,
|
|
731
|
-
door,
|
|
732
|
-
parts: Effect.map(wired, (built) => built.parts)
|
|
733
|
-
});
|
|
734
|
-
queueMicrotask(() => {
|
|
735
|
-
if (life.now().kind === "unbuilt") exitOn(runtime, Effect.void, noCall);
|
|
736
|
-
});
|
|
563
|
+
effectHostCalls: heldGroup(aroundCalls(guardedCalls(lazyGroups(joinedNames, (group, name, args) => Effect.suspend(() => joinedCall(wired.hostCalls, group, name)(...args))), through), withAudienceMemo), "queue", queueOn),
|
|
564
|
+
effectCallsFor: (caller) => heldGroup(lazyGroups(joinedNames, (group, name, args) => guardedCall(through)(Effect.suspend(() => joinedCall(wired.rest.callsFor(caller), group, name)(...args)))), "queue", queueOn)
|
|
565
|
+
}, wired);
|
|
737
566
|
return {
|
|
738
|
-
|
|
739
|
-
built: wired,
|
|
567
|
+
services: wired.services,
|
|
740
568
|
registry: extensions.registry,
|
|
741
|
-
seal
|
|
569
|
+
seal,
|
|
570
|
+
retire: Effect.flatMap(wired.retire, retiring),
|
|
571
|
+
rest: wired.rest,
|
|
572
|
+
needs: wired.needs,
|
|
573
|
+
checkFetch: (repo, input) => through(checkFetchOver(wired.needs)(repo, input)),
|
|
574
|
+
bucket: wired.adapter.bucket,
|
|
575
|
+
joined,
|
|
576
|
+
answer: (request) => answering(request, Effect.provideContext(wired.http.route(request), wired.needs)),
|
|
577
|
+
identify: (request) => guardedCall(through)(withAudienceMemo(wired.identify(request)))
|
|
742
578
|
};
|
|
743
|
-
};
|
|
744
|
-
|
|
579
|
+
});
|
|
580
|
+
/**
|
|
581
|
+
* `write`, the host's `events.retired` as rows for one start, till it lands or a later start's
|
|
582
|
+
* has, which is logged once. A failure is logged with its error, a warning, or
|
|
583
|
+
* an error as `retireErrors` picks, and tried again `retryDelay` later, with no end. A defect, a
|
|
584
|
+
* spent call bound among them, isn't a failure to try again: it ends the write, and `Git.layer`'s
|
|
585
|
+
* fork logs it.
|
|
586
|
+
*/
|
|
587
|
+
const retiring = /* @__PURE__ */ Effect.fnUntraced(function* (write) {
|
|
588
|
+
for (let failures = 1;; failures += 1) {
|
|
589
|
+
const result = yield* Effect.result(write);
|
|
590
|
+
if (EffectResult.isSuccess(result)) {
|
|
591
|
+
if (result.success !== "superseded") return;
|
|
592
|
+
return yield* Effect.logInfo("events.retired's rows weren't written: a later start wrote its own");
|
|
593
|
+
}
|
|
594
|
+
const next = retryDelay(failures);
|
|
595
|
+
const loud = (failures - retireErrors.first) % retireErrors.every === 0;
|
|
596
|
+
yield* (failures >= retireErrors.first && loud ? Effect.logError : Effect.logWarning)("events.retired's rows weren't written, and are written again", Cause.fail(result.failure)).pipe(Effect.annotateLogs({
|
|
597
|
+
failures,
|
|
598
|
+
next
|
|
599
|
+
}));
|
|
600
|
+
yield* Effect.sleep(next);
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
export { buildServer };
|