@ref0/git 0.6.0 → 0.7.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/namespace.d.mts +2 -0
- package/dist/access/private-refs.d.mts +6 -29
- package/dist/access/private-refs.mjs +28 -13
- package/dist/access/public.d.mts +6 -0
- package/dist/access/public.mjs +9 -0
- package/dist/auth/access-jwt.d.mts +10 -6
- package/dist/auth/access-jwt.mjs +59 -40
- package/dist/auth/auth-namespace.d.mts +6 -0
- package/dist/auth/auth-namespace.mjs +12 -0
- package/dist/auth/auth.d.mts +3 -6
- package/dist/auth/auth.mjs +2 -9
- package/dist/auth/authorize.mjs +4 -5
- package/dist/auth/fences.d.mts +1 -1
- package/dist/auth/host-function.mjs +17 -8
- package/dist/auth/identify.mjs +2 -1
- package/dist/auth/namespaces.d.mts +2 -2
- package/dist/auth/token-rows.mjs +1 -1
- package/dist/auth/tokens-layer.d.mts +42 -0
- package/dist/auth/tokens-layer.mjs +29 -0
- package/dist/auth/tokens-namespace.d.mts +2 -0
- package/dist/auth/tokens-public.d.mts +6 -0
- package/dist/auth/tokens-public.mjs +29 -0
- package/dist/auth/tokens.d.mts +13 -6
- package/dist/auth/tokens.mjs +5 -5
- package/dist/auth.d.mts +2 -2
- package/dist/auth.mjs +2 -2
- package/dist/client/git-http.mjs +1 -1
- package/dist/client/local.mjs +4 -3
- package/dist/client/remote-helper.mjs +3 -8
- package/dist/client/remote.mjs +26 -7
- package/dist/client/run-remote-helper.d.mts +1 -1
- package/dist/client/run-remote-helper.mjs +2 -2
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/contracts/access.d.mts +18 -10
- package/dist/contracts/access.mjs +17 -0
- package/dist/contracts/actors.d.mts +17 -1
- package/dist/contracts/actors.mjs +8 -1
- package/dist/contracts/authorize.d.mts +7 -4
- package/dist/contracts/blobs.d.mts +1 -1
- package/dist/contracts/blobs.mjs +1 -1
- package/dist/contracts/calls-spent.d.mts +6 -4
- package/dist/contracts/calls-spent.mjs +10 -8
- package/dist/contracts/commits.d.mts +2 -2
- package/dist/contracts/commits.mjs +1 -1
- package/dist/contracts/engine.d.mts +1 -1
- package/dist/contracts/events.d.mts +33 -22
- package/dist/contracts/events.mjs +13 -4
- package/dist/contracts/files.d.mts +2 -2
- package/dist/contracts/files.mjs +1 -1
- package/dist/contracts/forks.d.mts +58 -58
- package/dist/contracts/forks.mjs +1 -1
- package/dist/contracts/git-events.d.mts +50 -0
- package/dist/contracts/git-events.mjs +23 -0
- package/dist/contracts/git-hooks.d.mts +37 -0
- package/dist/contracts/git-hooks.mjs +10 -0
- package/dist/contracts/git.d.mts +93 -42
- package/dist/contracts/git.mjs +6 -5
- package/dist/contracts/ids.d.mts +16 -0
- package/dist/contracts/ids.mjs +19 -4
- package/dist/contracts/lfs.d.mts +2 -0
- package/dist/contracts/namespaces.d.mts +2 -2
- package/dist/contracts/objects.d.mts +1 -1
- package/dist/contracts/opaque.mjs +9 -0
- package/dist/contracts/operations.d.mts +293 -100
- package/dist/contracts/promises.d.mts +2 -0
- package/dist/contracts/push-uploads.d.mts +4 -1
- package/dist/contracts/push-uploads.mjs +9 -4
- package/dist/contracts/queue.d.mts +218 -47
- package/dist/contracts/queue.mjs +81 -6
- package/dist/contracts/refs.d.mts +30 -8
- package/dist/contracts/refs.mjs +1 -1
- package/dist/contracts/remote.d.mts +42 -21
- package/dist/contracts/remote.mjs +22 -0
- package/dist/contracts/repo-records.d.mts +2 -2
- package/dist/contracts/repos.d.mts +126 -79
- package/dist/contracts/repos.mjs +43 -5
- package/dist/contracts/result.d.mts +46 -31
- package/dist/contracts/result.mjs +43 -16
- package/dist/contracts/rules.d.mts +50 -44
- package/dist/contracts/rules.mjs +5 -1
- package/dist/contracts/server.d.mts +282 -198
- package/dist/contracts/services.d.mts +1 -7
- package/dist/contracts/services.mjs +1 -3
- package/dist/contracts/signin.d.mts +140 -43
- package/dist/contracts/signin.mjs +35 -1
- package/dist/contracts/store.d.mts +1 -1
- package/dist/contracts/sync.d.mts +112 -90
- package/dist/contracts/sync.mjs +34 -7
- package/dist/contracts/tags.d.mts +1 -1
- package/dist/contracts/tags.mjs +1 -1
- package/dist/contracts/tokens.d.mts +232 -57
- package/dist/contracts/tokens.mjs +80 -19
- package/dist/contracts/topics.d.mts +22 -10
- package/dist/contracts/topics.mjs +6 -3
- package/dist/contracts/trees.d.mts +2 -2
- package/dist/contracts/trees.mjs +1 -1
- package/dist/contracts/work.d.mts +2 -2
- package/dist/contracts/work.mjs +2 -2
- package/dist/core/access.d.mts +10 -10
- package/dist/core/access.mjs +31 -8
- package/dist/core/clock.mjs +1 -1
- package/dist/core/events/deliver.d.mts +3 -2
- package/dist/core/events/deliver.mjs +170 -92
- package/dist/core/forks.mjs +49 -24
- package/dist/core/hooks/groups.d.mts +27 -0
- package/dist/core/hooks/groups.mjs +74 -0
- package/dist/core/hooks/namespace.d.mts +2 -0
- package/dist/core/hooks/order.d.mts +2 -2
- package/dist/core/hooks/order.mjs +6 -6
- package/dist/core/hooks/public.d.mts +7 -0
- package/dist/core/hooks/public.mjs +5 -0
- package/dist/core/imports.mjs +94 -10
- package/dist/core/index-job.mjs +11 -8
- package/dist/core/merge-parts.d.mts +1 -1
- package/dist/core/merge-parts.mjs +1 -1
- package/dist/core/mirror-rows.mjs +18 -0
- package/dist/core/names.mjs +1 -1
- package/dist/core/namespaces.d.mts +2 -1
- package/dist/core/objects/commit-writes.mjs +5 -5
- package/dist/core/objects/merges.mjs +1 -1
- package/dist/core/objects/objects-layer.mjs +1 -1
- package/dist/core/objects/reading.mjs +52 -7
- package/dist/core/objects/tree-edits.mjs +13 -28
- package/dist/core/objects/trees.mjs +4 -4
- package/dist/core/objects/writing.mjs +3 -3
- package/dist/core/own-writes.mjs +1 -1
- package/dist/core/parts.d.mts +22 -3
- package/dist/core/parts.mjs +5 -3
- package/dist/core/promise.mjs +23 -3
- package/dist/core/purge.d.mts +2 -2
- package/dist/core/purge.mjs +80 -30
- package/dist/core/push.mjs +55 -74
- package/dist/core/receipts.d.mts +2 -2
- package/dist/core/receipts.mjs +28 -4
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +2 -2
- package/dist/core/refs.mjs +41 -10
- package/dist/core/registered-records.mjs +30 -0
- package/dist/core/{claim-rows.mjs → registered-rows.mjs} +6 -6
- package/dist/core/repack.d.mts +2 -2
- package/dist/core/repack.mjs +11 -9
- package/dist/core/repo-info.mjs +59 -25
- package/dist/core/repos.mjs +17 -11
- package/dist/core/rules/changes.mjs +2 -2
- package/dist/core/rules/commit-changes.mjs +1 -1
- package/dist/core/rules/context.d.mts +4 -5
- package/dist/core/rules/context.mjs +3 -4
- package/dist/core/rules/fetch.mjs +74 -21
- package/dist/core/saved-caller-views.d.mts +72 -0
- package/dist/core/saved-caller-views.mjs +123 -0
- package/dist/core/saved-callers-public.d.mts +5 -0
- package/dist/core/saved-callers-public.mjs +10 -0
- package/dist/core/saved-callers.mjs +95 -0
- package/dist/core/seam.d.mts +12 -1
- package/dist/core/seam.mjs +4 -2
- package/dist/core/tokens.mjs +5 -1
- package/dist/core/view.d.mts +1 -1
- package/dist/core/view.mjs +1 -1
- package/dist/core/work.mjs +6 -5
- package/dist/effect.d.mts +2 -2
- package/dist/effect.mjs +2 -2
- package/dist/engine/content.d.mts +2 -2
- package/dist/engine/content.mjs +1 -1
- package/dist/engine/diff.mjs +2 -2
- package/dist/engine/merge-base-walk.d.mts +2 -2
- package/dist/engine/merge-base-walk.mjs +1 -1
- package/dist/engine/merge-renames.mjs +1 -1
- package/dist/engine/reads.d.mts +2 -2
- package/dist/engine/reads.mjs +1 -1
- package/dist/engine/xdiff.d.mts +1 -1
- package/dist/engine/xdiff.mjs +2 -2
- package/dist/event-streams/event-streams.d.mts +6 -2
- package/dist/event-streams/event-streams.mjs +6 -2
- package/dist/event-streams/stream.mjs +5 -2
- package/dist/extend.d.mts +3 -3
- package/dist/extend.mjs +3 -2
- package/dist/http/answers.mjs +4 -3
- package/dist/http/core-parts.mjs +2 -2
- package/dist/http/handler.mjs +1 -1
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-uploads.mjs +7 -5
- package/dist/http/receive-pack.mjs +3 -3
- package/dist/http/upload-pack.mjs +6 -5
- package/dist/index.d.mts +33 -20
- package/dist/index.mjs +13 -7
- package/dist/lfs/base.d.mts +2 -2
- package/dist/lfs/calls.mjs +3 -2
- package/dist/lfs/layer.d.mts +5 -4
- package/dist/lfs/layer.mjs +17 -16
- package/dist/lfs/locks.mjs +3 -3
- package/dist/lfs/objects.d.mts +3 -2
- package/dist/lfs/objects.mjs +149 -34
- package/dist/lfs/pointers.mjs +1 -1
- package/dist/lfs/purge.mjs +1 -1
- package/dist/lfs/rows.mjs +1 -1
- package/dist/lfs/upkeep.mjs +13 -9
- package/dist/lfs/wire.mjs +1 -1
- package/dist/protocol/bytes/buffers.d.mts +1 -1
- package/dist/protocol/bytes/buffers.mjs +1 -1
- package/dist/protocol/bytes/deflate.d.mts +1 -1
- package/dist/protocol/bytes/deflate.mjs +1 -1
- package/dist/protocol/bytes/hmac-sha256.mjs +3 -6
- package/dist/protocol/bytes/inflate.d.mts +1 -1
- package/dist/protocol/bytes/inflate.mjs +1 -1
- package/dist/protocol/bytes/sha1.d.mts +1 -1
- package/dist/protocol/bytes/sha1.mjs +2 -2
- package/dist/protocol/diff/read.d.mts +1 -1
- package/dist/protocol/diff/read.mjs +1 -1
- package/dist/protocol/diff/tree-diff.d.mts +1 -1
- package/dist/protocol/diff/tree-diff.mjs +11 -11
- package/dist/protocol/objects/lfs-pointer.mjs +6 -1
- package/dist/protocol/objects/tag.mjs +1 -1
- package/dist/protocol/objects/tree.mjs +1 -1
- package/dist/protocol/packs/graph.mjs +1 -1
- package/dist/protocol/packs/idx.d.mts +1 -1
- package/dist/protocol/packs/idx.mjs +1 -1
- package/dist/protocol/packs/parts.mjs +1 -1
- package/dist/protocol/packs/reader.d.mts +1 -1
- package/dist/protocol/packs/reader.mjs +2 -2
- package/dist/protocol/packs/write-error.d.mts +1 -1
- package/dist/protocol/packs/write-error.mjs +1 -1
- package/dist/protocol/packs/writer.mjs +4 -4
- package/dist/protocol/wire/advertisement.d.mts +1 -1
- package/dist/protocol/wire/advertisement.mjs +1 -1
- package/dist/protocol/wire/fetch.d.mts +1 -1
- package/dist/protocol/wire/fetch.mjs +1 -1
- package/dist/protocol/wire/lines.d.mts +1 -1
- package/dist/protocol/wire/lines.mjs +2 -2
- package/dist/protocol/wire/push-uploads.mjs +4 -2
- package/dist/protocol/wire/receive-pack.d.mts +1 -1
- package/dist/protocol/wire/receive-pack.mjs +1 -1
- package/dist/protocol/wire/report-status.d.mts +1 -1
- package/dist/protocol/wire/report-status.mjs +1 -1
- package/dist/protocol/wire/v2.d.mts +2 -2
- package/dist/protocol/wire/v2.mjs +2 -2
- package/dist/queue/advance.mjs +155 -63
- package/dist/queue/callers.mjs +56 -69
- package/dist/queue/calls.mjs +20 -11
- package/dist/queue/commit.mjs +28 -22
- package/dist/queue/host.d.mts +10 -11
- package/dist/queue/host.mjs +15 -7
- package/dist/queue/lanes.mjs +9 -18
- package/dist/queue/layer.d.mts +3 -3
- package/dist/queue/layer.mjs +11 -10
- package/dist/queue/limits.mjs +17 -5
- package/dist/queue/rows.mjs +5 -10
- package/dist/queue/schedule.mjs +6 -5
- package/dist/queue/search.mjs +8 -13
- package/dist/queue/state.mjs +7 -2
- package/dist/queue/trim.mjs +10 -5
- package/dist/rest/api.d.mts +1 -1
- package/dist/rest/blobs.d.mts +20 -20
- package/dist/rest/caller.d.mts +22 -20
- package/dist/rest/client.mjs +6 -6
- package/dist/rest/commits.d.mts +335 -335
- package/dist/rest/errors.d.mts +10 -10
- package/dist/rest/errors.mjs +1 -1
- package/dist/rest/events.d.mts +13 -11
- package/dist/rest/events.mjs +3 -1
- package/dist/rest/files.d.mts +30 -30
- package/dist/rest/forks.d.mts +150 -150
- package/dist/rest/handler.mjs +4 -3
- package/dist/rest/handlers.mjs +13 -7
- package/dist/rest/layer.d.mts +3 -3
- package/dist/rest/layer.mjs +8 -7
- package/dist/rest/listen.mjs +2 -2
- package/dist/rest/me.d.mts +18 -20
- package/dist/rest/me.mjs +1 -1
- package/dist/rest/merges.d.mts +10 -10
- package/dist/rest/queue.d.mts +140 -140
- package/dist/rest/queue.mjs +1 -1
- package/dist/rest/refs.d.mts +95 -95
- package/dist/rest/refs.mjs +1 -1
- package/dist/rest/repos.d.mts +127 -127
- package/dist/rest/tags.d.mts +30 -30
- package/dist/rest/tokens.d.mts +250 -260
- package/dist/rest/tokens.mjs +10 -42
- package/dist/rest/topics.d.mts +63 -63
- package/dist/rest/topics.mjs +1 -1
- package/dist/rest/trees.d.mts +106 -106
- package/dist/rest/wire.d.mts +6 -4
- package/dist/rest/wire.mjs +4 -3
- package/dist/rest/work.d.mts +69 -69
- package/dist/rest/work.mjs +1 -1
- package/dist/server/check-fetch.mjs +9 -0
- package/dist/server/extension.mjs +3 -115
- package/dist/server/git-layer.d.mts +20 -3
- package/dist/server/git-layer.mjs +30 -19
- package/dist/server/git-namespace.d.mts +4 -4
- package/dist/server/git-namespace.mjs +6 -4
- package/dist/server/joined.d.mts +83 -0
- package/dist/server/joined.mjs +91 -0
- package/dist/server/registry.d.mts +7 -3
- package/dist/server/registry.mjs +135 -31
- package/dist/server/routes.mjs +2 -2
- package/dist/server/server.d.mts +9 -2
- package/dist/server/server.mjs +279 -191
- package/dist/signin/context.d.mts +2 -1
- package/dist/signin/context.mjs +32 -37
- package/dist/signin/device.mjs +5 -5
- package/dist/signin/forms.mjs +1 -1
- package/dist/signin/grants.d.mts +2 -3
- package/dist/signin/grants.mjs +5 -5
- package/dist/signin/layer.d.mts +9 -0
- package/dist/signin/layer.mjs +41 -0
- package/dist/signin/namespace.d.mts +2 -0
- package/dist/signin/public.d.mts +6 -0
- package/dist/signin/public.mjs +5 -0
- package/dist/signin/route.mjs +47 -21
- package/dist/signin/web.mjs +3 -3
- package/dist/signin/wire.mjs +1 -1
- package/dist/storage/calls.d.mts +1 -1
- package/dist/storage/calls.mjs +4 -4
- package/dist/storage/clean-up.mjs +12 -5
- package/dist/storage/counted-bucket.mjs +34 -51
- package/dist/storage/fetch.mjs +1 -1
- package/dist/storage/host-bucket.mjs +1 -1
- package/dist/storage/index-build.d.mts +2 -2
- package/dist/storage/index-build.mjs +3 -3
- package/dist/storage/index-fetch.mjs +10 -6
- package/dist/storage/index-graph.mjs +1 -1
- package/dist/storage/index-layers.mjs +1 -1
- package/dist/storage/index-visible.mjs +1 -1
- package/dist/storage/memory-budget.mjs +7 -1
- package/dist/storage/merge-cut.mjs +24 -1
- package/dist/storage/merge-fence.mjs +1 -1
- package/dist/storage/merge-plan.mjs +5 -2
- package/dist/storage/merge-row.mjs +1 -1
- package/dist/storage/merge-stream.mjs +16 -7
- package/dist/storage/merge-write.mjs +1 -1
- package/dist/storage/merge.d.mts +2 -2
- package/dist/storage/merge.mjs +1 -1
- package/dist/storage/object-rows.d.mts +2 -2
- package/dist/storage/object-rows.mjs +3 -3
- package/dist/storage/pack-ranges.d.mts +3 -1
- package/dist/storage/pack-ranges.mjs +168 -69
- package/dist/storage/pack-reads.mjs +4 -4
- package/dist/storage/pack-receive.d.mts +1 -1
- package/dist/storage/pack-receive.mjs +7 -9
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +45 -52
- package/dist/storage/placed-reads.mjs +81 -15
- package/dist/storage/prune-seen.mjs +126 -0
- package/dist/storage/prune-walk.mjs +87 -99
- package/dist/storage/prune.mjs +49 -14
- package/dist/storage/push-uploads.mjs +4 -2
- package/dist/storage/quarantine.d.mts +2 -2
- package/dist/storage/ready.d.mts +2 -2
- package/dist/storage/ready.mjs +3 -3
- package/dist/storage/receive-files.mjs +1 -1
- package/dist/storage/receive-links.mjs +1 -1
- package/dist/storage/receive-state.d.mts +2 -2
- package/dist/storage/receive-state.mjs +1 -1
- package/dist/storage/receive-steps.mjs +1 -1
- package/dist/storage/repack-contained.mjs +2 -2
- package/dist/storage/repack-job.d.mts +2 -2
- package/dist/storage/repack-job.mjs +5 -4
- package/dist/storage/repack.d.mts +1 -1
- package/dist/storage/repack.mjs +9 -3
- package/dist/storage/rows.d.mts +2 -2
- package/dist/storage/rows.mjs +1 -1
- package/dist/storage/runs.d.mts +2 -2
- package/dist/storage/runs.mjs +15 -6
- package/dist/storage/send-list.mjs +6 -6
- package/dist/storage/single-flight.mjs +2 -2
- package/dist/storage/swap-walk.mjs +1 -1
- package/dist/storage/unpack.mjs +1 -1
- package/dist/store/call-count.d.mts +1 -1
- package/dist/store/call-count.mjs +125 -34
- package/dist/store/catalogue.d.mts +1 -1
- package/dist/store/catalogue.mjs +2 -2
- package/dist/store/crossing.mjs +2 -6
- package/dist/store/cursor-seal.mjs +1 -1
- package/dist/store/errors.d.mts +7 -3
- package/dist/store/errors.mjs +41 -13
- package/dist/store/job-try.mjs +119 -15
- package/dist/store/list-job.mjs +5 -5
- package/dist/store/outbox.d.mts +2 -2
- package/dist/store/outbox.mjs +75 -16
- package/dist/store/promises.d.mts +2 -2
- package/dist/store/promises.mjs +31 -6
- package/dist/store/queue-jobs.mjs +1 -1
- package/dist/store/records.d.mts +2 -2
- package/dist/store/records.mjs +16 -24
- package/dist/store/ref-rows.d.mts +2 -2
- package/dist/store/ref-rows.mjs +6 -6
- package/dist/store/reservations.mjs +35 -8
- package/dist/store/scopes.mjs +6 -4
- package/dist/store/topic-jobs.mjs +8 -8
- package/dist/sync/bound.d.mts +1 -3
- package/dist/sync/bound.mjs +30 -42
- package/dist/sync/bridge.d.mts +6 -0
- package/dist/sync/bridge.mjs +29 -0
- package/dist/sync/github.d.mts +5 -6
- package/dist/sync/github.mjs +37 -42
- package/dist/sync/http.mjs +15 -0
- package/dist/sync/import.mjs +17 -18
- package/dist/sync/layer.d.mts +9 -0
- package/dist/sync/layer.mjs +68 -0
- package/dist/sync/mirror.mjs +137 -58
- package/dist/sync/publish.mjs +3 -6
- package/dist/sync/step.mjs +217 -79
- package/dist/sync/tries.mjs +22 -15
- package/dist/sync.d.mts +3 -6
- package/dist/sync.mjs +3 -6
- package/dist/topics/advance.mjs +205 -90
- package/dist/topics/calls.mjs +8 -8
- package/dist/topics/directory.mjs +35 -12
- package/dist/topics/host.d.mts +5 -8
- package/dist/topics/host.mjs +42 -19
- package/dist/topics/layer.d.mts +381 -0
- package/dist/topics/layer.mjs +62 -0
- package/dist/topics/members.mjs +1 -1
- package/dist/topics/namespace.d.mts +2 -0
- package/dist/topics/public.d.mts +6 -0
- package/dist/topics/public.mjs +13 -0
- package/dist/topics/rows.mjs +12 -3
- package/dist/topics/topic.mjs +11 -10
- package/package.json +8 -13
- package/dist/access.d.mts +0 -2
- package/dist/access.mjs +0 -1
- package/dist/core/hooks/post-receive.mjs +0 -216
- package/dist/core/hooks/pre-receive.d.mts +0 -12
- package/dist/core/hooks/pre-receive.mjs +0 -36
- package/dist/server/extension.d.mts +0 -21
- package/dist/sync/import.d.mts +0 -10
- package/dist/sync/jobs.d.mts +0 -9
- package/dist/sync/jobs.mjs +0 -75
- package/dist/sync/mirror.d.mts +0 -13
- package/dist/sync/publish.d.mts +0 -6
- /package/dist/core/{claim-rows.d.mts → registered-rows.d.mts} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CallsSpent } from "../contracts/calls-spent.mjs";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
|
-
import * as Context from "effect/Context";
|
|
4
|
-
import * as Predicate from "effect/Predicate";
|
|
5
3
|
import * as Option from "effect/Option";
|
|
4
|
+
import * as Predicate from "effect/Predicate";
|
|
5
|
+
import * as Context from "effect/Context";
|
|
6
6
|
import * as Layer from "effect/Layer";
|
|
7
7
|
// src/store/call-count.ts
|
|
8
8
|
/**
|
|
@@ -11,18 +11,34 @@ import * as Layer from "effect/Layer";
|
|
|
11
11
|
* call. Every call from the serve on counts on the request's one count, the repo's record, its
|
|
12
12
|
* refs, its haves and its tags' peels with its pack's (#709). Measured locally, not at a colo, by
|
|
13
13
|
* negotiation-calls.test.ts: a token's request refused at its bound made 1 call more than it
|
|
14
|
-
* counted. The host's own `auth
|
|
15
|
-
*
|
|
14
|
+
* counted. The host's own `auth` and grants aren't Git's calls: a host whose run subrequests sets
|
|
15
|
+
* `callLimits` lower by them. Its `resolve` and fetch rules are `hookCallsBefore`'s.
|
|
16
16
|
*/
|
|
17
17
|
const requestCallsBefore = {
|
|
18
18
|
bucket: 0,
|
|
19
19
|
subrequests: 1
|
|
20
20
|
};
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
/**
|
|
22
|
+
* The calls one of the host's hooks makes before a Git request's count starts, beside
|
|
23
|
+
* `requestCallsBefore`'s: `resolve`, on any, and the fetch rules, on a fetch. B1a's K read measured
|
|
24
|
+
* it on Workers, 2 calls before the count with either hook against 1 with neither. A hook that
|
|
25
|
+
* makes more sets `callLimits` lower by them.
|
|
26
|
+
*/
|
|
27
|
+
const hookCallsBefore = {
|
|
28
|
+
bucket: 0,
|
|
29
|
+
subrequests: 1
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The store calls a job's try makes outside its handler, which its job budget leaves room for: the
|
|
33
|
+
* claim its invocation takes, or the settle an earlier one left, and the settle that ends it, which
|
|
34
|
+
* takes the next claim in the same call, as a Worker's job object runs a try through infra's
|
|
35
|
+
* `tryOnce`, one try an invocation. No bucket call. A try's progress, written at most once a
|
|
36
|
+
* second, isn't counted: a host whose tries run long sets `callLimits` lower by it.
|
|
37
|
+
*/
|
|
38
|
+
const jobCallsAround = {
|
|
39
|
+
bucket: 0,
|
|
40
|
+
subrequests: 2
|
|
41
|
+
};
|
|
26
42
|
/** The kind of `counted`'s calls `kind` would pass `most` of, if any. */
|
|
27
43
|
const spentOf = (counted, most, kind, calls = 1, of = "request", budget) => {
|
|
28
44
|
if (most === void 0) return void 0;
|
|
@@ -76,12 +92,17 @@ const requestCount = Effect.map(Effect.serviceOption(RequestCount), Option.getOr
|
|
|
76
92
|
* `effect`, run after its request's deciding commit, as `AfterCommit` says, the request in scope
|
|
77
93
|
* marked `committed` too, so its later Git calls, each a run of its own, are refused no more.
|
|
78
94
|
*/
|
|
79
|
-
const afterCommit = (effect) => Effect.flatMap(requestCount, (request) => {
|
|
95
|
+
const afterCommit = (effect) => Effect.flatMap(Effect.all([requestCount, inScope]), ([request, budget]) => {
|
|
80
96
|
if (request !== void 0) request.committed = true;
|
|
97
|
+
for (const at of chainOf(budget)) markCommitted(at);
|
|
81
98
|
return Effect.provideService(effect, AfterCommit, true);
|
|
82
99
|
});
|
|
83
100
|
/** Whether a call in scope runs after its request's deciding commit, as `afterCommit` marks it. */
|
|
84
|
-
const committedNow = Effect.map(Effect.all([
|
|
101
|
+
const committedNow = Effect.suspend(() => Effect.map(Effect.all([
|
|
102
|
+
requestCount,
|
|
103
|
+
inScope,
|
|
104
|
+
AfterCommit
|
|
105
|
+
]), ([request, budget, marked]) => marked || request?.committed === true || committedIn(budget)));
|
|
85
106
|
/**
|
|
86
107
|
* A lost commit's `resends`, counted into the request and its budgets but never refused, and the
|
|
87
108
|
* request left unmarked: each may have landed, and none decided anything yet.
|
|
@@ -90,6 +111,10 @@ const chargeResends = (resends) => resends === 0 ? Effect.void : Effect.provideS
|
|
|
90
111
|
/** A budget's calls so far, and the budget it nests in, read only in this module. */
|
|
91
112
|
let madeOf;
|
|
92
113
|
let parentOf;
|
|
114
|
+
/** Marks `budget` past its request's deciding commit, when it's a request's: others it leaves. */
|
|
115
|
+
let markCommitted;
|
|
116
|
+
/** Whether `budget` is a request's, past its deciding commit. */
|
|
117
|
+
let committedOf;
|
|
93
118
|
let budgetOf;
|
|
94
119
|
/** What `CallAllowance`'s constructor takes to make one: module-private, so only `make` can. */
|
|
95
120
|
const madeHere = Symbol("ref0/git CallAllowance");
|
|
@@ -102,23 +127,39 @@ var CallAllowance = class CallAllowance {
|
|
|
102
127
|
limits;
|
|
103
128
|
/** The name its spent refusal gives it, as `CallBudget.make` was given it, if any. */
|
|
104
129
|
name;
|
|
105
|
-
#made
|
|
106
|
-
bucket: 0,
|
|
107
|
-
subrequests: 0
|
|
108
|
-
};
|
|
130
|
+
#made;
|
|
109
131
|
#parent;
|
|
132
|
+
/** Whether it's a request's, as `requestBudget` makes one, whose commit mark outlasts a run. */
|
|
133
|
+
#request;
|
|
134
|
+
#committed = false;
|
|
110
135
|
static {
|
|
111
136
|
madeOf = (budget) => budget.#made;
|
|
112
137
|
parentOf = (budget) => budget.#parent;
|
|
113
|
-
|
|
138
|
+
markCommitted = (budget) => {
|
|
139
|
+
if (budget.#request) budget.#committed = true;
|
|
140
|
+
};
|
|
141
|
+
committedOf = (budget) => budget.#committed;
|
|
142
|
+
budgetOf = (limits, parent, name, request = false, shared) => new CallAllowance(madeHere, limits, parent, name, request, shared === void 0 ? void 0 : shared.#made);
|
|
114
143
|
}
|
|
115
|
-
constructor(token, limits, parent, name
|
|
144
|
+
constructor(token, limits, parent, name, request, made = {
|
|
145
|
+
bucket: 0,
|
|
146
|
+
subrequests: 0
|
|
147
|
+
}) {
|
|
116
148
|
if (token !== madeHere) throw new TypeError("A CallAllowance is made only by CallBudget.make");
|
|
117
149
|
this.limits = limits;
|
|
118
150
|
this.name = name;
|
|
151
|
+
this.#made = made;
|
|
119
152
|
this.#parent = parent;
|
|
153
|
+
this.#request = request;
|
|
120
154
|
}
|
|
121
155
|
};
|
|
156
|
+
/** Whether `budget`, or one it nests in, is a request's past its deciding commit. */
|
|
157
|
+
const committedIn = (budget) => chainOf(budget).some(committedOf);
|
|
158
|
+
/**
|
|
159
|
+
* The counts of `chain`'s budgets, each once: a part's budget from `budgetWithin` keeps its step's
|
|
160
|
+
* count, so a call counted into both counts once.
|
|
161
|
+
*/
|
|
162
|
+
const countsOf = (chain) => new Set(chain.map((at) => madeOf(at)));
|
|
122
163
|
/** `budget` and the budgets it nests in, the innermost first. */
|
|
123
164
|
const chainOf = (budget) => {
|
|
124
165
|
const chain = [];
|
|
@@ -142,11 +183,11 @@ const checkedLimits = (limits, what = "A CallBudget's ") => {
|
|
|
142
183
|
}
|
|
143
184
|
return Object.freeze(copied);
|
|
144
185
|
};
|
|
145
|
-
/** `limits` less `
|
|
146
|
-
const lessBefore = (limits) => {
|
|
147
|
-
const less = (most,
|
|
148
|
-
const bucket = less(limits.bucket,
|
|
149
|
-
const subrequests = less(limits.subrequests,
|
|
186
|
+
/** `limits` less `before`, `requestCallsBefore` unless given, never below none. */
|
|
187
|
+
const lessBefore = (limits, before = requestCallsBefore) => {
|
|
188
|
+
const less = (most, made) => most === void 0 ? void 0 : Math.max(0, most - made);
|
|
189
|
+
const bucket = less(limits.bucket, before.bucket);
|
|
190
|
+
const subrequests = less(limits.subrequests, before.subrequests);
|
|
150
191
|
const lessened = {};
|
|
151
192
|
if (bucket !== void 0) lessened.bucket = bucket;
|
|
152
193
|
if (subrequests !== void 0) lessened.subrequests = subrequests;
|
|
@@ -188,6 +229,64 @@ var CallBudget = class CallBudget extends (/* @__PURE__ */ Context.Service()("@r
|
|
|
188
229
|
*/
|
|
189
230
|
static isSpent = Effect.map(inScope, (budget) => chainOf(budget).some((at) => spentOf(madeOf(at), at.limits, "bucket") !== void 0));
|
|
190
231
|
};
|
|
232
|
+
/**
|
|
233
|
+
* A request's budget of `limits`, as `CallBudget.make` makes one named `'request'`, that the
|
|
234
|
+
* request's deciding commit marks, as `afterCommit` marks a `RequestCalls`: no bound refuses a
|
|
235
|
+
* call in it after that, each Git call its answer makes later in a run of its own included (Q855).
|
|
236
|
+
* Internal: a joined package's request is the one that has it.
|
|
237
|
+
*/
|
|
238
|
+
const requestBudget = (limits) => Effect.map(inScope, (parent) => budgetOf(checkedLimits(limits), parent, "request", true));
|
|
239
|
+
/** Whether `inner` is `outer`, or nests in it, however deep. */
|
|
240
|
+
const nestsIn = (inner, outer) => chainOf(inner).includes(outer);
|
|
241
|
+
/** `budget`'s calls so far. */
|
|
242
|
+
const budgetMade = (budget) => ({ ...madeOf(budget) });
|
|
243
|
+
/** `budget`'s limits as a count: a kind it leaves unbounded, `Infinity`. */
|
|
244
|
+
const budgetMost = (budget) => ({
|
|
245
|
+
bucket: budget.limits.bucket ?? Number.POSITIVE_INFINITY,
|
|
246
|
+
subrequests: budget.limits.subrequests ?? Number.POSITIVE_INFINITY
|
|
247
|
+
});
|
|
248
|
+
/** `most` of `kind`, no more than what each budget of `chain` has left of it. */
|
|
249
|
+
const leftOf = (most, chain, kind) => chain.reduce((least, at) => {
|
|
250
|
+
const limit = at.limits[kind];
|
|
251
|
+
return limit === void 0 ? least : Math.min(least, Math.max(0, limit - madeOf(at)[kind]));
|
|
252
|
+
}, most);
|
|
253
|
+
/**
|
|
254
|
+
* A step's own budget, named `name`, nested in the budget in scope, a job's try's: of `most`, or
|
|
255
|
+
* of what that one and each it nests in have left, if less, so a step that cuts its work at its
|
|
256
|
+
* bound cuts it where its calls really stop.
|
|
257
|
+
*/
|
|
258
|
+
const stepBudget = (most, name) => Effect.map(inScope, (parent) => {
|
|
259
|
+
const chain = chainOf(parent);
|
|
260
|
+
const limits = {
|
|
261
|
+
bucket: leftOf(most.bucket, chain, "bucket"),
|
|
262
|
+
subrequests: leftOf(most.subrequests, chain, "subrequests")
|
|
263
|
+
};
|
|
264
|
+
return budgetOf(checkedLimits(limits), parent, name);
|
|
265
|
+
});
|
|
266
|
+
/**
|
|
267
|
+
* A budget nested in `budget`, under its name, that keeps `budget`'s count and stops where it
|
|
268
|
+
* reaches `bound`: for a step's part that leaves room under its bound for what follows it, as a
|
|
269
|
+
* save's calls. A call made through `budget` alone counts against `bound` too, so the room the
|
|
270
|
+
* part leaves holds wherever the step makes its other calls.
|
|
271
|
+
*/
|
|
272
|
+
const budgetWithin = (budget, bound) => {
|
|
273
|
+
const limits = {
|
|
274
|
+
bucket: Math.max(0, bound.bucket),
|
|
275
|
+
subrequests: Math.max(0, bound.subrequests)
|
|
276
|
+
};
|
|
277
|
+
return budgetOf(checkedLimits(limits), budget, budget.name, false, budget);
|
|
278
|
+
};
|
|
279
|
+
/**
|
|
280
|
+
* `calls` of `kind` counted into `budget` alone, never refused: calls the budgets it nests in
|
|
281
|
+
* counted already, made for its step outside its scope, as a recheck's reread.
|
|
282
|
+
*/
|
|
283
|
+
const countInto = (budget, kind, calls) => Effect.sync(() => add(madeOf(budget), kind, calls));
|
|
284
|
+
/**
|
|
285
|
+
* `input` with the budget in scope on it, as `budgetedOn` puts one, or as it is with none: for a
|
|
286
|
+
* call across a Promise a host may wrap, as `git.index`'s step, so the call counts into the
|
|
287
|
+
* budget of the try that made it.
|
|
288
|
+
*/
|
|
289
|
+
const budgetedInput = (input) => Effect.map(inScope, (budget) => budget === void 0 ? input : budgetedOn(input, budget));
|
|
191
290
|
/** `effect`, run with `calls` as its request's count, or as it is with none. */
|
|
192
291
|
const countedAs = (effect, calls) => calls === void 0 ? effect : Effect.provideService(effect, RequestCount, calls);
|
|
193
292
|
/**
|
|
@@ -219,14 +318,6 @@ const withRequestHold = (effect) => Effect.suspend(() => {
|
|
|
219
318
|
const hold = new RequestHold();
|
|
220
319
|
return effect.pipe(Effect.provideService(RequestHolding, hold), Effect.ensuring(hold.close));
|
|
221
320
|
});
|
|
222
|
-
/**
|
|
223
|
-
* `scope`, counting into `calls` too when it holds no request's count of its own: a call a host's
|
|
224
|
-
* code makes for one request, as a package built on Git makes each of its routes' (#725).
|
|
225
|
-
*/
|
|
226
|
-
const countedScope = (scope, calls) => calls === void 0 || scope.calls !== void 0 ? scope : {
|
|
227
|
-
...scope,
|
|
228
|
-
calls
|
|
229
|
-
};
|
|
230
321
|
/** A scope with neither part: what a call taken with nothing in scope counts into. */
|
|
231
322
|
const noScope = {
|
|
232
323
|
calls: void 0,
|
|
@@ -273,7 +364,7 @@ const chargeCalls = (kind, calls) => Effect.flatMap(Effect.all([
|
|
|
273
364
|
inScope,
|
|
274
365
|
AfterCommit
|
|
275
366
|
]), ([request, budget, marked]) => {
|
|
276
|
-
const after = marked || request?.committed === true;
|
|
367
|
+
const after = marked || request?.committed === true || committedIn(budget);
|
|
277
368
|
const spent = request === void 0 || after ? void 0 : spentOf(request, request.most, kind, calls);
|
|
278
369
|
if (spent !== void 0) return Effect.die(spent);
|
|
279
370
|
const chain = chainOf(budget);
|
|
@@ -284,7 +375,7 @@ const chargeCalls = (kind, calls) => Effect.flatMap(Effect.all([
|
|
|
284
375
|
return Effect.die(over);
|
|
285
376
|
}
|
|
286
377
|
if (request !== void 0) add(request, kind, calls);
|
|
287
|
-
for (const
|
|
378
|
+
for (const made of countsOf(chain)) add(made, kind, calls);
|
|
288
379
|
return Effect.void;
|
|
289
380
|
});
|
|
290
381
|
/**
|
|
@@ -298,7 +389,7 @@ const heldCall = (kind) => Effect.flatMap(Effect.all([requestCount, inScope]), (
|
|
|
298
389
|
if (!held) return;
|
|
299
390
|
held = false;
|
|
300
391
|
if (request !== void 0) add(request, kind, -1);
|
|
301
|
-
for (const
|
|
392
|
+
for (const made of countsOf(chainOf(budget))) add(made, kind, -1);
|
|
302
393
|
});
|
|
303
394
|
return Effect.as(chargeCall(kind), given);
|
|
304
395
|
});
|
|
@@ -346,4 +437,4 @@ const withBound = (objects, most) => {
|
|
|
346
437
|
};
|
|
347
438
|
/** The bound `withBound` kept for `objects`, or `undefined` for objects with none, a host's own. */
|
|
348
439
|
const countedMost = (objects) => objectsBounds.get(objects);
|
|
349
|
-
export { CallAllowance, CallBudget, RequestCalls, RequestCount, RequestHold, RequestHolding, afterCommit, budgetedOn, callScope, chargeCall, chargeCalls, chargeResends, checkedLimits, committedNow, countedAs, countedMost,
|
|
440
|
+
export { CallAllowance, CallBudget, RequestCalls, RequestCount, RequestHold, RequestHolding, afterCommit, budgetMade, budgetMost, budgetWithin, budgetedInput, budgetedOn, callScope, chargeCall, chargeCalls, chargeResends, checkedLimits, committedNow, countInto, countedAs, countedMost, heldCall, hookCallsBefore, inCallScope, jobCallsAround, lessBefore, nestsIn, noScope, readScope, requestBudget, requestCallsBefore, requestCount, scopedContext, spentBudget, stepBudget, withBound, withRequestHold };
|
|
@@ -4,8 +4,8 @@ import "../contracts/repos.mjs";
|
|
|
4
4
|
import "../contracts/result.mjs";
|
|
5
5
|
import { SettledName } from "./outbox.mjs";
|
|
6
6
|
import { CatalogueEntry, StoredRepo } from "./records.mjs";
|
|
7
|
-
import { Key, Listing, Page, Read, Row, Snapshot } from "@ref0/infra";
|
|
8
7
|
import "effect/Effect";
|
|
8
|
+
import { Key, Listing, Page, Read, Row, Snapshot } from "@ref0/infra";
|
|
9
9
|
import "effect/Types";
|
|
10
10
|
/**
|
|
11
11
|
* A repo found by name: its entry, its record, and its scope's snapshot, self first. Its `name` is
|
package/dist/store/catalogue.mjs
CHANGED
|
@@ -3,8 +3,8 @@ import { fail } from "../contracts/result.mjs";
|
|
|
3
3
|
import { decodeDerivedRow, decodeRow, storeCall } from "./errors.mjs";
|
|
4
4
|
import { CatalogueEntry, CreatedRow, ForkRow, StoredRepo, keyKept, takenBack } from "./records.mjs";
|
|
5
5
|
import { catalogueScope, collections, forkId, newChangeId, repoScope, selfKey } from "./scopes.mjs";
|
|
6
|
-
import { limits } from "@ref0/infra";
|
|
7
6
|
import * as Effect from "effect/Effect";
|
|
7
|
+
import { limits } from "@ref0/infra";
|
|
8
8
|
// src/store/catalogue.ts
|
|
9
9
|
/** How many times a projection reads and commits again when another name's write moved first. */
|
|
10
10
|
const projectTries = 8;
|
|
@@ -474,7 +474,7 @@ const heldNameAt = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalI
|
|
|
474
474
|
/** How many times `hostRecordOf` reads again when a write moved the repo between its reads. */
|
|
475
475
|
const hostReadTries = 5;
|
|
476
476
|
/**
|
|
477
|
-
* A repo's record as host code reads it, by internal ID: `
|
|
477
|
+
* A repo's record as host code reads it, by internal ID: `RepoRecords.record`'s answer, `undefined`
|
|
478
478
|
* once it's deleted. Its name is the one the catalogue gives it, read between two reads of its
|
|
479
479
|
* record at one version, so it's never a name another repo holds. When the catalogue gives it
|
|
480
480
|
* neither name, its projection is finished as `git.list` would, and it's read again; still none at
|
package/dist/store/crossing.mjs
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { inCallScope } from "./call-count.mjs";
|
|
2
2
|
import { answerOf } from "../contracts/calls-spent.mjs";
|
|
3
|
-
import { thrownError } from "./errors.mjs";
|
|
4
3
|
import * as Effect from "effect/Effect";
|
|
5
4
|
import * as Stream from "effect/Stream";
|
|
6
5
|
// src/store/crossing.ts
|
|
7
6
|
/**
|
|
8
|
-
* Why a run takes no call scope: a
|
|
9
|
-
* it, host code and a client make no call through Git's doors, and a timer or an interrupt makes
|
|
7
|
+
* Why a run takes no call scope: host code and a client make no call through Git's doors, and a timer or an interrupt makes
|
|
10
8
|
* no call at all. Read by review, so short and true.
|
|
11
9
|
*/
|
|
12
10
|
var Uncounted = class {
|
|
@@ -47,8 +45,6 @@ const runnerIn = (context) => (effect, signal) => Effect.runPromiseWith(context)
|
|
|
47
45
|
* waits for a read, so a body no one reads yet holds no chunk of the bucket's.
|
|
48
46
|
*/
|
|
49
47
|
const readableIn = (stream, context) => Stream.toReadableStreamWith(stream, context, { strategy: { highWaterMark: 0 } });
|
|
50
|
-
/** A job's try as a Promise: Git's error, thrown with it as the cause, so the queue retries. */
|
|
51
|
-
const runJobTry = (effect) => runIn(Effect.mapError(effect, thrownError), uncounted("a job's try: no request's, so only the platform's cap bounds it"));
|
|
52
48
|
/**
|
|
53
49
|
* `effect`, interrupted when `signal` aborts: it then dies with the signal's reason. For a job's
|
|
54
50
|
* part that holds no signal of its own, as a repack's upkeep, so its calls stop at the try's
|
|
@@ -64,4 +60,4 @@ const untilAborted = (effect, signal) => {
|
|
|
64
60
|
});
|
|
65
61
|
return Effect.raceFirst(effect, aborted);
|
|
66
62
|
};
|
|
67
|
-
export { Uncounted, exitIn, exitOn, forkIn, noCall, readableIn, resultIn, runIn,
|
|
63
|
+
export { Uncounted, exitIn, exitOn, forkIn, noCall, readableIn, resultIn, runIn, runnerIn, syncIn, uncounted, untilAborted };
|
|
@@ -2,8 +2,8 @@ import { fail } from "../contracts/result.mjs";
|
|
|
2
2
|
import { decodeRow, storeCall } from "./errors.mjs";
|
|
3
3
|
import { bytesFromBase64Url, randomText, toBase64Url, utf8Of } from "./random.mjs";
|
|
4
4
|
import { catalogueScope, collections } from "./scopes.mjs";
|
|
5
|
-
import * as Schema from "effect/Schema";
|
|
6
5
|
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
7
7
|
import * as Semaphore from "effect/Semaphore";
|
|
8
8
|
// src/store/cursor-seal.ts
|
|
9
9
|
/** The row in `git/repos` that holds the key every list cursor is sealed with. */
|
package/dist/store/errors.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { GitError } from "../contracts/result.mjs";
|
|
2
|
-
import { Committed, Row } from "@ref0/infra";
|
|
3
|
-
import "effect/Schema";
|
|
4
2
|
import * as Effect from "effect/Effect";
|
|
3
|
+
import "effect/Schema";
|
|
4
|
+
import { Committed, Row } from "@ref0/infra";
|
|
5
|
+
import "effect/Stream";
|
|
5
6
|
/**
|
|
6
7
|
* A store call, its refusal as Git's error: one of the two doors every call Git makes goes
|
|
7
8
|
* through, with `bucketCall`, and every call a package built on Git makes, as `@ref0/github`'s
|
|
@@ -9,4 +10,7 @@ import * as Effect from "effect/Effect";
|
|
|
9
10
|
* either's bound (Q799): past one, it dies with `CallsSpent`, which an edge answers, as
|
|
10
11
|
* `spentRefusalOf` does.
|
|
11
12
|
*/
|
|
12
|
-
export declare
|
|
13
|
+
export declare function storeCall<A>(run: () => Promise<A>): Effect.Effect<A, GitError>;
|
|
14
|
+
export declare function storeCall<A, E, R>(run: Effect.Effect<A, E, R>, options?: {
|
|
15
|
+
readonly resend?: boolean;
|
|
16
|
+
}): Effect.Effect<A, GitError, R>;
|
package/dist/store/errors.mjs
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { fail, gitError, gitErrorFrom } from "../contracts/result.mjs";
|
|
2
|
-
import { callLimitIn, callLimitTry, catchSpent, fromAnswer, spentRefusal } from "../contracts/calls-spent.mjs";
|
|
2
|
+
import { callLimitIn, callLimitTry, catchSpent, fromAnswer, spentAt, spentRefusal } from "../contracts/calls-spent.mjs";
|
|
3
3
|
import { chargeCall, chargeResends, committedNow } from "./call-count.mjs";
|
|
4
4
|
import { isServerClosed, tryClosing } from "./closed.mjs";
|
|
5
|
-
import { isInfraError } from "@ref0/infra";
|
|
6
|
-
import * as Schema from "effect/Schema";
|
|
7
5
|
import * as Effect from "effect/Effect";
|
|
8
|
-
import * as Predicate from "effect/Predicate";
|
|
9
6
|
import * as Option from "effect/Option";
|
|
7
|
+
import * as Schema from "effect/Schema";
|
|
8
|
+
import * as Cause from "effect/Cause";
|
|
9
|
+
import * as Exit from "effect/Exit";
|
|
10
|
+
import { isInfraError } from "@ref0/infra";
|
|
11
|
+
import * as Predicate from "effect/Predicate";
|
|
12
|
+
import * as Stream from "effect/Stream";
|
|
10
13
|
import * as Data from "effect/Data";
|
|
11
14
|
// src/store/errors.ts
|
|
12
15
|
const savedHint = "Read it back before you try again";
|
|
@@ -100,14 +103,39 @@ const routeEdge = (effect, refused) => Effect.catch(answerSpent(effect), (error)
|
|
|
100
103
|
* `spentRefusal`'s, and any other defect a defect still.
|
|
101
104
|
*/
|
|
102
105
|
const answerSpent = (effect) => catchSpent(effect, (spent) => Effect.fail(spentRefusal(spent)));
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const
|
|
106
|
+
function storeCall(run, options) {
|
|
107
|
+
if (Effect.isEffect(run)) return effectStoreCall(run, options?.resend === true);
|
|
108
|
+
return Effect.andThen(chargeCall("store"), Effect.flatMap(committedNow, (after) => tryClosing(run, (cause) => fromInfra(cause, after)).pipe(Effect.tap((answer) => chargeResends(Predicate.isObject(answer) ? resent.get(answer) ?? 0 : 0)), Effect.tapError(({ cause }) => chargeResends(cause instanceof Unsettled ? 1 : 0)))));
|
|
109
|
+
}
|
|
110
|
+
/** A store failure: preserve interruption, spent bounds, closed servers and code defects. */
|
|
111
|
+
const effectStoreFailure = (cause, after) => {
|
|
112
|
+
if (Cause.hasInterrupts(cause)) return Effect.failCause(Cause.map(cause, (error) => fromInfra(error, after)));
|
|
113
|
+
const error = Cause.squash(cause);
|
|
114
|
+
const spent = spentAt(error);
|
|
115
|
+
if (spent !== void 0) return Effect.die(spent);
|
|
116
|
+
if (isServerClosed(error) || codeErrors.some((code) => error instanceof code)) return Effect.die(error);
|
|
117
|
+
return Effect.fail(fromInfra(error, after));
|
|
118
|
+
};
|
|
119
|
+
/** A watch, charged once at subscription, with the same failure classification as a store call. */
|
|
120
|
+
const storeWatch = (run) => Stream.unwrap(storeCall(Effect.map(committedNow, (after) => run().pipe(Stream.catchCause((cause) => Stream.fromEffect(effectStoreFailure(cause, after)))))));
|
|
121
|
+
/** An Effect store call, with a commit's resends under the same ID when requested. */
|
|
122
|
+
const effectStoreCall = /* @__PURE__ */ Effect.fnUntraced(function* (run, resend) {
|
|
123
|
+
yield* chargeCall("store");
|
|
124
|
+
const after = yield* committedNow;
|
|
125
|
+
let lost;
|
|
126
|
+
for (let resends = 0;; resends += 1) {
|
|
127
|
+
const exit = yield* Effect.exit(run);
|
|
128
|
+
if (Exit.isSuccess(exit)) return exit.value;
|
|
129
|
+
if (Cause.hasInterrupts(exit.cause)) return yield* effectStoreFailure(exit.cause, after);
|
|
130
|
+
const cause = Cause.squash(exit.cause);
|
|
131
|
+
if (spentAt(cause) !== void 0 && lost === void 0) return yield* effectStoreFailure(exit.cause, after);
|
|
132
|
+
if (isServerClosed(cause)) return yield* effectStoreFailure(exit.cause, after);
|
|
133
|
+
if (!resend || (resends === 0 ? !isLostReply(cause) : isAnswered(cause))) return yield* effectStoreFailure(exit.cause, after);
|
|
134
|
+
lost ??= cause;
|
|
135
|
+
if (resends === 1 || !isLostReply(cause)) return yield* Effect.fail(fromInfra(new Unsettled("No reply came to a commit", { cause: lost }), after));
|
|
136
|
+
yield* chargeResends(1);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
111
139
|
/** What a commit sent `commitResendsMost` times again, with no reply, throws: it may have landed. */
|
|
112
140
|
var Unsettled = class extends Error {
|
|
113
141
|
name = "Unsettled";
|
|
@@ -220,4 +248,4 @@ const endedEarly = (cause) => {
|
|
|
220
248
|
cause
|
|
221
249
|
});
|
|
222
250
|
};
|
|
223
|
-
export { Unsettled, afterWrites, answerSpent, bestEffort, brokenRead, clientWentAway, decodeDerivedRow, decodeRow, endedEarly, fetchLess, fromInfra, isLimitRefusal, pastCallLimit, readBody, resending, resultCall, routeEdge, storeCall, thrownError };
|
|
251
|
+
export { Unsettled, afterWrites, answerSpent, bestEffort, brokenRead, clientWentAway, decodeDerivedRow, decodeRow, endedEarly, fetchLess, fromInfra, isLimitRefusal, pastCallLimit, readBody, resending, resultCall, routeEdge, storeCall, storeWatch, thrownError };
|
package/dist/store/job-try.mjs
CHANGED
|
@@ -1,26 +1,130 @@
|
|
|
1
|
+
import { ownSpentOf } from "../contracts/calls-spent.mjs";
|
|
2
|
+
import { gitError } from "../contracts/result.mjs";
|
|
3
|
+
import { CallBudget, checkedLimits, inCallScope, jobCallsAround, lessBefore, nestsIn, noScope, spentBudget } from "./call-count.mjs";
|
|
1
4
|
import { noCall, syncIn } from "./crossing.mjs";
|
|
2
5
|
import { jobRepo } from "./scopes.mjs";
|
|
3
|
-
import { CurrentJob } from "@ref0/infra";
|
|
4
6
|
import * as Effect from "effect/Effect";
|
|
7
|
+
import { CurrentJob } from "@ref0/infra";
|
|
5
8
|
// src/store/job-try.ts
|
|
9
|
+
/** A try's `JobLimits` under the adapter's `limits`, checked as a request's are. */
|
|
10
|
+
const jobLimitsOf = (limits) => lessBefore(checkedLimits(limits, "The adapter's callLimits."), jobCallsAround);
|
|
11
|
+
/** The step `jobStep` named, by each spent bound that ended it. */
|
|
12
|
+
const stepNames = /* @__PURE__ */ new WeakMap();
|
|
13
|
+
/** The step `spent` ended: `jobStep`'s name, or the spent budget's, or `whole` for the try's own. */
|
|
14
|
+
const stepOf = (spent, whole) => {
|
|
15
|
+
const bound = spentBudget(spent)?.name;
|
|
16
|
+
return stepNames.get(spent) ?? (bound === void 0 || bound === "job" ? whole : bound);
|
|
17
|
+
};
|
|
18
|
+
/** The `RESOURCE_EXHAUSTED` a try's spend fails with: `reason` and `message` say which. */
|
|
19
|
+
const stepSpent = (reason, message, job, step, spent) => gitError("RESOURCE_EXHAUSTED", message, {
|
|
20
|
+
hostHint: "Raise the adapter's callLimits",
|
|
21
|
+
context: {
|
|
22
|
+
reason,
|
|
23
|
+
job,
|
|
24
|
+
step,
|
|
25
|
+
bound: spent.bound,
|
|
26
|
+
most: spent.most
|
|
27
|
+
},
|
|
28
|
+
cause: spent
|
|
29
|
+
});
|
|
30
|
+
/** What a try's `spent` calls were: subrequests, or bucket calls. */
|
|
31
|
+
const callsOf = (spent) => `${spent.most} ${spent.bound === "bucket" ? "bucket calls" : "subrequests"}`;
|
|
6
32
|
/**
|
|
7
|
-
* A
|
|
8
|
-
*
|
|
33
|
+
* A job's step that can't fit one try's calls: it saved nothing before they were spent, so the
|
|
34
|
+
* next try, on a fresh count, would spend them at the same place. The step is `jobStep`'s name, or
|
|
35
|
+
* the spent budget's, a step's own nested in the try's, or `whole`, the job's or its `onFailure`.
|
|
36
|
+
* The queue tries it again by the job's policy, as a commit's resends vary a step's calls, and its
|
|
37
|
+
* last failure is the job's.
|
|
9
38
|
*/
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
39
|
+
const stepTooLarge = (job, spent, whole = job) => {
|
|
40
|
+
const step = stepOf(spent, whole);
|
|
41
|
+
return stepSpent("job-step-calls", `${job}'s ${step} step needs more than one try's ${callsOf(spent)}`, job, step, spent);
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* A try that spent its calls once a write of its own landed: the queue tries it again by the job's
|
|
45
|
+
* policy, and the next try goes on from what it saved. A failure, not a `more`, since a `more`
|
|
46
|
+
* counts the job's attempts from 1 again: a step whose every try lands a write that saves no
|
|
47
|
+
* progress, such as a hold, would yield forever. So the job's attempts and `within` bound it, and a
|
|
48
|
+
* step that needs many tries spends one attempt for each.
|
|
49
|
+
*/
|
|
50
|
+
const stepYielded = (job, spent) => {
|
|
51
|
+
const step = stepOf(spent, job);
|
|
52
|
+
return stepSpent("job-step-yielded", `${job}'s ${step} step spent a try's ${callsOf(spent)} after a write landed: the next try goes on from it`, job, step, spent);
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* `store`, marking `saved` once a write through it lands: a commit that took, an add, a job's
|
|
56
|
+
* discard or retry. A try's store is a plain object of calls, the claim's fence, so its spread
|
|
57
|
+
* keeps them all.
|
|
58
|
+
*/
|
|
59
|
+
const marking = (store, saved) => ({
|
|
60
|
+
...store,
|
|
61
|
+
commit: async (scope, change) => {
|
|
62
|
+
const committed = await store.commit(scope, change);
|
|
63
|
+
if (committed.ok) saved.landed = true;
|
|
64
|
+
return committed;
|
|
65
|
+
},
|
|
66
|
+
add: async (scope, addition) => {
|
|
67
|
+
await store.add(scope, addition);
|
|
68
|
+
saved.landed = true;
|
|
69
|
+
},
|
|
70
|
+
discard: async (scope, job) => {
|
|
71
|
+
await store.discard(scope, job);
|
|
72
|
+
saved.landed = true;
|
|
73
|
+
},
|
|
74
|
+
retry: async (scope, job, input) => {
|
|
75
|
+
await store.retry(scope, job, input);
|
|
76
|
+
saved.landed = true;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
13
79
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* retry runs beside it. A call that outlives the lease can run beside the next try's: the store
|
|
17
|
-
* refuses the expired try's writes, but the host's own writes have no fence. A rejection is a
|
|
18
|
-
* defect, the try's error.
|
|
80
|
+
* `run` in a fresh budget of `limits`, named `'job'`, nested in nothing, with the try's store
|
|
81
|
+
* marking what lands: so a request's budget and a job's never count each other's calls (#2015).
|
|
19
82
|
*/
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
83
|
+
const inJobBudget = (limits, run, spent) => Effect.flatMap(inCallScope(CallBudget.make(limits, { name: "job" }), noScope), (budget) => {
|
|
84
|
+
const saved = { landed: false };
|
|
85
|
+
const marked = run(saved).pipe(Effect.updateService(CurrentJob.CurrentJob, (job) => ({
|
|
86
|
+
...job,
|
|
87
|
+
store: marking(job.store, saved)
|
|
88
|
+
})));
|
|
89
|
+
const owns = (each) => nestsIn(spentBudget(each), budget);
|
|
90
|
+
return Effect.catchCause(inCallScope(marked, {
|
|
91
|
+
calls: void 0,
|
|
92
|
+
budget
|
|
93
|
+
}), (cause) => {
|
|
94
|
+
const own = ownSpentOf(cause, owns);
|
|
95
|
+
return own === void 0 ? Effect.failCause(cause) : spent(own, saved);
|
|
96
|
+
});
|
|
23
97
|
});
|
|
98
|
+
/**
|
|
99
|
+
* A try of `name` in a budget of `limits`: one that spends it after a write landed fails as
|
|
100
|
+
* `stepYielded`, and the next try goes on from what it saved on a fresh count; one that saved
|
|
101
|
+
* nothing fails as `stepTooLarge`. Either way the job's retry policy bounds its tries. A spend
|
|
102
|
+
* never runs anything again within the try.
|
|
103
|
+
*/
|
|
104
|
+
const budgetedTry = (limits, name, handler) => (data) => inJobBudget(limits, () => handler(data), (spent, saved) => Effect.fail(saved.landed ? stepYielded(name, spent) : stepTooLarge(name, spent)));
|
|
105
|
+
/** Each `gitJob`'s definition, remade in other limits by `jobsWithin`. */
|
|
106
|
+
const remakes = /* @__PURE__ */ new WeakMap();
|
|
107
|
+
/**
|
|
108
|
+
* `job`'s `JobDefinition`, `handler` its try and `onFailure` its last failure's, each run in a
|
|
109
|
+
* budget of its own, made fresh for each run: the job's calls, `JobLimits`, once `jobsWithin` gave
|
|
110
|
+
* them, or no bound till then. An `onFailure` that spends its budget fails as `stepTooLarge`, its
|
|
111
|
+
* step `onFailure`, which the queue logs before it settles the job failed with the try's failure. Every Git job is made here, which `lint/call-crossings.test.ts`
|
|
112
|
+
* holds, with no service but `CurrentJob`: Git's jobs close over the parts they run with.
|
|
113
|
+
*/
|
|
114
|
+
const gitJob = (job, handler, options = {}) => {
|
|
115
|
+
const { onFailure } = options;
|
|
116
|
+
const made = (limits) => syncIn(job.definition(budgetedTry(limits, job.name, handler), { ...onFailure && { onFailure: (data, failure) => inJobBudget(limits, () => onFailure(data, failure), (spent) => Effect.fail(stepTooLarge(job.name, spent, "onFailure"))) } }), noCall);
|
|
117
|
+
const definition = made({});
|
|
118
|
+
remakes.set(definition, made);
|
|
119
|
+
return definition;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* `jobs`, each `gitJob` made remade in `limits`, a server's, and any other as it is: what a server
|
|
123
|
+
* registers, so each try counts its calls against the adapter's bound.
|
|
124
|
+
*/
|
|
125
|
+
const jobsWithin = (limits, jobs) => jobs.map((job) => remakes.get(job)?.(limits) ?? job);
|
|
126
|
+
/** The repo whose scope the try runs in: in any other scope, it's a defect, as `jobRepo` says. */
|
|
127
|
+
const currentRepo = Effect.map(CurrentJob.current, jobRepo);
|
|
24
128
|
/** `step` over the try's store, fenced by its claim and gated by the server's door, and its repo. */
|
|
25
129
|
const repoTry = (step) => Effect.flatMap(Effect.all([CurrentJob.store, currentRepo]), ([store, repo]) => step(store, repo));
|
|
26
|
-
export { currentRepo,
|
|
130
|
+
export { currentRepo, gitJob, jobLimitsOf, jobsWithin, repoTry, stepTooLarge };
|
package/dist/store/list-job.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { reconcile } from "./catalogue.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { Job, defineJob } from "@ref0/infra";
|
|
4
|
-
import * as Schema from "effect/Schema";
|
|
2
|
+
import { gitJob, repoTry } from "./job-try.mjs";
|
|
5
3
|
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Schema from "effect/Schema";
|
|
5
|
+
import { Job, defineJob } from "@ref0/infra";
|
|
6
6
|
// src/store/list-job.ts
|
|
7
7
|
const ListData = /* @__PURE__ */ Schema.Struct({});
|
|
8
8
|
const listJobName = "git.list";
|
|
@@ -13,7 +13,7 @@ const listJobKey = "list";
|
|
|
13
13
|
* writing an entry only when its revision is newer. Every repo write saves it in the same commit.
|
|
14
14
|
* Its try stops at its timeout, which interrupts it.
|
|
15
15
|
*/
|
|
16
|
-
const listJob = /* @__PURE__ */
|
|
16
|
+
const listJob = /* @__PURE__ */ gitJob(/* @__PURE__ */ Job.make(listJobName, {
|
|
17
17
|
payload: ListData,
|
|
18
18
|
retry: {
|
|
19
19
|
limit: 10,
|
|
@@ -21,7 +21,7 @@ const listJob = /* @__PURE__ */ madeJob(/* @__PURE__ */ (/* @__PURE__ */ Job.mak
|
|
|
21
21
|
backoff: "exponential",
|
|
22
22
|
maxDelay: "5 minutes"
|
|
23
23
|
}
|
|
24
|
-
})
|
|
24
|
+
}), () => Effect.asVoid(repoTry(reconcile)));
|
|
25
25
|
/**
|
|
26
26
|
* `git.list`'s rows, by `defineJob`, as `ListJob.encodedJob` makes them: a write saves one beside
|
|
27
27
|
* its record without `Job.make`'s runtime, which only the server that runs `listJob` needs.
|
package/dist/store/outbox.d.mts
CHANGED
|
@@ -2,9 +2,9 @@ import "../contracts/events.mjs";
|
|
|
2
2
|
import "../contracts/actors.mjs";
|
|
3
3
|
import { RepoName } from "../contracts/ids.mjs";
|
|
4
4
|
import "../contracts/result.mjs";
|
|
5
|
-
import { JobInput, Key, Moment, Read, Row, Scope } from "@ref0/infra";
|
|
6
|
-
import "effect/Schema";
|
|
7
5
|
import "effect/Effect";
|
|
6
|
+
import "effect/Schema";
|
|
7
|
+
import { JobInput, Key, Moment, Read, Row, Scope } from "@ref0/infra";
|
|
8
8
|
import "effect/Types";
|
|
9
9
|
declare const settledBrand: unique symbol;
|
|
10
10
|
/**
|