@rikalabs/akter 0.1.0-alpha.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/CHANGELOG.md +15 -0
- package/LICENSE +202 -0
- package/NOTICE +8 -0
- package/README.md +116 -0
- package/dist/actor/codecs.d.ts +77 -0
- package/dist/actor/codecs.js +87 -0
- package/dist/actor/connections.d.ts +34 -0
- package/dist/actor/connections.js +145 -0
- package/dist/actor/definition.d.ts +893 -0
- package/dist/actor/definition.js +147 -0
- package/dist/actor/descriptor.d.ts +172 -0
- package/dist/actor/descriptor.js +367 -0
- package/dist/actor/handles.d.ts +77 -0
- package/dist/actor/handles.js +265 -0
- package/dist/actor/jobs.d.ts +10 -0
- package/dist/actor/jobs.js +137 -0
- package/dist/actor/layers.d.ts +41 -0
- package/dist/actor/layers.js +177 -0
- package/dist/actor/reads.d.ts +47 -0
- package/dist/actor/reads.js +224 -0
- package/dist/actor/served.d.ts +120 -0
- package/dist/actor/served.js +72 -0
- package/dist/actor/turns.d.ts +13 -0
- package/dist/actor/turns.js +332 -0
- package/dist/actor/workflows.d.ts +16 -0
- package/dist/actor/workflows.js +37 -0
- package/dist/client/calls.d.ts +47 -0
- package/dist/client/calls.js +425 -0
- package/dist/client/clock.d.ts +56 -0
- package/dist/client/clock.js +119 -0
- package/dist/client/fleet-page.d.ts +15 -0
- package/dist/client/fleet-page.js +13 -0
- package/dist/client/fleet.d.ts +29 -0
- package/dist/client/fleet.js +51 -0
- package/dist/client/index.d.ts +17 -0
- package/dist/client/index.js +6 -0
- package/dist/client/make.d.ts +157 -0
- package/dist/client/make.js +221 -0
- package/dist/client/offline/queue.d.ts +118 -0
- package/dist/client/offline/queue.js +292 -0
- package/dist/client/offline/store.d.ts +74 -0
- package/dist/client/offline/store.js +78 -0
- package/dist/client/optimistic.d.ts +57 -0
- package/dist/client/optimistic.js +136 -0
- package/dist/client/report.d.ts +2 -0
- package/dist/client/report.js +8 -0
- package/dist/client/sessions/connection.d.ts +118 -0
- package/dist/client/sessions/connection.js +162 -0
- package/dist/client/sessions/feed.d.ts +42 -0
- package/dist/client/sessions/feed.js +43 -0
- package/dist/client/sessions/sse.d.ts +47 -0
- package/dist/client/sessions/sse.js +112 -0
- package/dist/client/sessions/stream.d.ts +28 -0
- package/dist/client/sessions/stream.js +35 -0
- package/dist/client/sessions/watch.d.ts +34 -0
- package/dist/client/sessions/watch.js +40 -0
- package/dist/client/transport.d.ts +37 -0
- package/dist/client/transport.js +66 -0
- package/dist/contexts/command.d.ts +132 -0
- package/dist/contexts/command.js +20 -0
- package/dist/contexts/connection.d.ts +68 -0
- package/dist/contexts/connection.js +0 -0
- package/dist/contexts/job.d.ts +49 -0
- package/dist/contexts/job.js +0 -0
- package/dist/contexts/workflow.d.ts +147 -0
- package/dist/contexts/workflow.js +22 -0
- package/dist/errors/actor.d.ts +200 -0
- package/dist/errors/actor.js +271 -0
- package/dist/errors/content.d.ts +19 -0
- package/dist/errors/content.js +14 -0
- package/dist/errors/database.d.ts +22 -0
- package/dist/errors/database.js +23 -0
- package/dist/errors/events.d.ts +17 -0
- package/dist/errors/events.js +14 -0
- package/dist/errors/subscription.d.ts +12 -0
- package/dist/errors/subscription.js +8 -0
- package/dist/errors/workflow.d.ts +28 -0
- package/dist/errors/workflow.js +17 -0
- package/dist/handles/actors.d.ts +17 -0
- package/dist/handles/actors.js +7 -0
- package/dist/handles/content.d.ts +59 -0
- package/dist/handles/content.js +36 -0
- package/dist/handles/intents.d.ts +164 -0
- package/dist/handles/intents.js +214 -0
- package/dist/handles/run.d.ts +31 -0
- package/dist/handles/run.js +21 -0
- package/dist/handles/workflow.d.ts +27 -0
- package/dist/handles/workflow.js +23 -0
- package/dist/identity/caller.d.ts +105 -0
- package/dist/identity/caller.js +68 -0
- package/dist/identity/child.d.ts +18 -0
- package/dist/identity/child.js +39 -0
- package/dist/identity/command.d.ts +19 -0
- package/dist/identity/command.js +21 -0
- package/dist/identity/connection.d.ts +24 -0
- package/dist/identity/connection.js +29 -0
- package/dist/identity/content.d.ts +18 -0
- package/dist/identity/content.js +12 -0
- package/dist/identity/digest.d.ts +4 -0
- package/dist/identity/digest.js +5 -0
- package/dist/identity/execution.d.ts +32 -0
- package/dist/identity/execution.js +63 -0
- package/dist/identity/mint.d.ts +51 -0
- package/dist/identity/mint.js +76 -0
- package/dist/identity/version.d.ts +2 -0
- package/dist/identity/version.js +3 -0
- package/dist/index.d.ts +159 -0
- package/dist/index.js +97 -0
- package/dist/members/blob.d.ts +43 -0
- package/dist/members/blob.js +29 -0
- package/dist/members/command.d.ts +109 -0
- package/dist/members/command.js +61 -0
- package/dist/members/connection.d.ts +55 -0
- package/dist/members/connection.js +49 -0
- package/dist/members/event.d.ts +36 -0
- package/dist/members/event.js +24 -0
- package/dist/members/job.d.ts +157 -0
- package/dist/members/job.js +67 -0
- package/dist/members/payload.d.ts +93 -0
- package/dist/members/payload.js +145 -0
- package/dist/members/reducer.d.ts +64 -0
- package/dist/members/reducer.js +27 -0
- package/dist/members/stream.d.ts +36 -0
- package/dist/members/stream.js +14 -0
- package/dist/members/subscription.d.ts +182 -0
- package/dist/members/subscription.js +91 -0
- package/dist/members/workflow.d.ts +99 -0
- package/dist/members/workflow.js +2 -0
- package/dist/policies/access.d.ts +35 -0
- package/dist/policies/access.js +6 -0
- package/dist/policies/command.d.ts +127 -0
- package/dist/policies/command.js +45 -0
- package/dist/policies/job.d.ts +28 -0
- package/dist/policies/job.js +60 -0
- package/dist/policies/schedules.d.ts +33 -0
- package/dist/policies/schedules.js +131 -0
- package/dist/protocol/frames.d.ts +66 -0
- package/dist/protocol/frames.js +55 -0
- package/dist/protocol/inspection.d.ts +807 -0
- package/dist/protocol/inspection.js +243 -0
- package/dist/protocol/wire.d.ts +184 -0
- package/dist/protocol/wire.js +150 -0
- package/dist/runtime/actors.d.ts +155 -0
- package/dist/runtime/actors.js +4 -0
- package/dist/runtime/admission.d.ts +34 -0
- package/dist/runtime/admission.js +72 -0
- package/dist/runtime/adoption/backfill.d.ts +27 -0
- package/dist/runtime/adoption/backfill.js +144 -0
- package/dist/runtime/adoption/enforce.d.ts +55 -0
- package/dist/runtime/adoption/enforce.js +241 -0
- package/dist/runtime/adoption/observe.d.ts +43 -0
- package/dist/runtime/adoption/observe.js +139 -0
- package/dist/runtime/adoption/plan.d.ts +45 -0
- package/dist/runtime/adoption/plan.js +192 -0
- package/dist/runtime/adoption/startup.d.ts +32 -0
- package/dist/runtime/adoption/startup.js +76 -0
- package/dist/runtime/adoption/status.d.ts +23 -0
- package/dist/runtime/adoption/status.js +47 -0
- package/dist/runtime/adoption/target.d.ts +33 -0
- package/dist/runtime/adoption/target.js +49 -0
- package/dist/runtime/connections/holder.d.ts +221 -0
- package/dist/runtime/connections/holder.js +816 -0
- package/dist/runtime/connections/owner.d.ts +263 -0
- package/dist/runtime/connections/owner.js +896 -0
- package/dist/runtime/connections/protocol.d.ts +441 -0
- package/dist/runtime/connections/protocol.js +222 -0
- package/dist/runtime/connections/reads.d.ts +24 -0
- package/dist/runtime/connections/reads.js +19 -0
- package/dist/runtime/connections/streams.d.ts +62 -0
- package/dist/runtime/connections/streams.js +128 -0
- package/dist/runtime/connections/transport.d.ts +40 -0
- package/dist/runtime/connections/transport.js +68 -0
- package/dist/runtime/connections/watch.d.ts +52 -0
- package/dist/runtime/connections/watch.js +159 -0
- package/dist/runtime/content/grant.d.ts +34 -0
- package/dist/runtime/content/grant.js +58 -0
- package/dist/runtime/content/store.d.ts +63 -0
- package/dist/runtime/content/store.js +294 -0
- package/dist/runtime/cron/key.d.ts +2 -0
- package/dist/runtime/cron/key.js +2 -0
- package/dist/runtime/cron/schedule.d.ts +69 -0
- package/dist/runtime/cron/schedule.js +144 -0
- package/dist/runtime/database/bounded.d.ts +43 -0
- package/dist/runtime/database/bounded.js +108 -0
- package/dist/runtime/database/connection.d.ts +8 -0
- package/dist/runtime/database/connection.js +18 -0
- package/dist/runtime/database/coordination.d.ts +19 -0
- package/dist/runtime/database/coordination.js +72 -0
- package/dist/runtime/database/flock.d.ts +10 -0
- package/dist/runtime/database/flock.js +60 -0
- package/dist/runtime/database/gate.d.ts +26 -0
- package/dist/runtime/database/gate.js +54 -0
- package/dist/runtime/database/keepalive.d.ts +11 -0
- package/dist/runtime/database/keepalive.js +22 -0
- package/dist/runtime/database/migrations.d.ts +177 -0
- package/dist/runtime/database/migrations.js +1018 -0
- package/dist/runtime/database/neki/migrations.d.ts +31 -0
- package/dist/runtime/database/neki/migrations.js +276 -0
- package/dist/runtime/database/neki/session.d.ts +23 -0
- package/dist/runtime/database/neki/session.js +31 -0
- package/dist/runtime/database/pglite.d.ts +21 -0
- package/dist/runtime/database/pglite.js +74 -0
- package/dist/runtime/database/replica.d.ts +41 -0
- package/dist/runtime/database/replica.js +51 -0
- package/dist/runtime/database/shards.d.ts +21 -0
- package/dist/runtime/database/shards.js +37 -0
- package/dist/runtime/database/snapshot.d.ts +7 -0
- package/dist/runtime/database/snapshot.js +7 -0
- package/dist/runtime/database/tenancy.d.ts +69 -0
- package/dist/runtime/database/tenancy.js +145 -0
- package/dist/runtime/database/transient.d.ts +10 -0
- package/dist/runtime/database/transient.js +25 -0
- package/dist/runtime/drain.d.ts +132 -0
- package/dist/runtime/drain.js +109 -0
- package/dist/runtime/entity/mailbox.d.ts +86 -0
- package/dist/runtime/entity/mailbox.js +121 -0
- package/dist/runtime/entity/register.d.ts +424 -0
- package/dist/runtime/entity/register.js +669 -0
- package/dist/runtime/events/append.d.ts +192 -0
- package/dist/runtime/events/append.js +128 -0
- package/dist/runtime/events/cursor.d.ts +2 -0
- package/dist/runtime/events/cursor.js +5 -0
- package/dist/runtime/events/replay.d.ts +20 -0
- package/dist/runtime/events/replay.js +45 -0
- package/dist/runtime/feeds.d.ts +26 -0
- package/dist/runtime/feeds.js +100 -0
- package/dist/runtime/fleet/checks.d.ts +17 -0
- package/dist/runtime/fleet/checks.js +106 -0
- package/dist/runtime/fleet/maintainer.d.ts +38 -0
- package/dist/runtime/fleet/maintainer.js +383 -0
- package/dist/runtime/fleet/pgoutput.d.ts +41 -0
- package/dist/runtime/fleet/pgoutput.js +102 -0
- package/dist/runtime/fleet/setup.d.ts +36 -0
- package/dist/runtime/fleet/setup.js +58 -0
- package/dist/runtime/fleet/subscribe.d.ts +42 -0
- package/dist/runtime/fleet/subscribe.js +147 -0
- package/dist/runtime/index.d.ts +66 -0
- package/dist/runtime/index.js +37 -0
- package/dist/runtime/inspector/http.d.ts +19 -0
- package/dist/runtime/inspector/http.js +36 -0
- package/dist/runtime/inspector/layer.d.ts +46 -0
- package/dist/runtime/inspector/layer.js +180 -0
- package/dist/runtime/inspector/queries.d.ts +711 -0
- package/dist/runtime/inspector/queries.js +494 -0
- package/dist/runtime/jobs/attempt.d.ts +254 -0
- package/dist/runtime/jobs/attempt.js +413 -0
- package/dist/runtime/jobs/isolation.d.ts +20 -0
- package/dist/runtime/jobs/isolation.js +10 -0
- package/dist/runtime/jobs/progress.d.ts +95 -0
- package/dist/runtime/jobs/progress.js +144 -0
- package/dist/runtime/layer.d.ts +260 -0
- package/dist/runtime/layer.js +876 -0
- package/dist/runtime/members.d.ts +381 -0
- package/dist/runtime/members.js +8 -0
- package/dist/runtime/operators/audit.d.ts +64 -0
- package/dist/runtime/operators/audit.js +56 -0
- package/dist/runtime/operators/auth.d.ts +29 -0
- package/dist/runtime/operators/auth.js +42 -0
- package/dist/runtime/operators/export.d.ts +68 -0
- package/dist/runtime/operators/export.js +137 -0
- package/dist/runtime/operators/grants.d.ts +45 -0
- package/dist/runtime/operators/grants.js +40 -0
- package/dist/runtime/operators/repair.d.ts +206 -0
- package/dist/runtime/operators/repair.js +226 -0
- package/dist/runtime/operators/routes.d.ts +35 -0
- package/dist/runtime/operators/routes.js +190 -0
- package/dist/runtime/operators/seed.d.ts +123 -0
- package/dist/runtime/operators/seed.js +123 -0
- package/dist/runtime/payloads/versions.d.ts +65 -0
- package/dist/runtime/payloads/versions.js +240 -0
- package/dist/runtime/peering/authority.d.ts +42 -0
- package/dist/runtime/peering/authority.js +132 -0
- package/dist/runtime/peering/credentials.d.ts +21 -0
- package/dist/runtime/peering/credentials.js +13 -0
- package/dist/runtime/peering/transport.d.ts +51 -0
- package/dist/runtime/peering/transport.js +175 -0
- package/dist/runtime/queries.d.ts +18 -0
- package/dist/runtime/queries.js +169 -0
- package/dist/runtime/readiness.d.ts +36 -0
- package/dist/runtime/readiness.js +44 -0
- package/dist/runtime/registration.d.ts +58 -0
- package/dist/runtime/registration.js +186 -0
- package/dist/runtime/request.d.ts +158 -0
- package/dist/runtime/request.js +102 -0
- package/dist/runtime/retry.d.ts +8 -0
- package/dist/runtime/retry.js +11 -0
- package/dist/runtime/runner.d.ts +93 -0
- package/dist/runtime/runner.js +122 -0
- package/dist/runtime/storage/codec.d.ts +39 -0
- package/dist/runtime/storage/codec.js +41 -0
- package/dist/runtime/storage/generation.d.ts +69 -0
- package/dist/runtime/storage/generation.js +49 -0
- package/dist/runtime/storage/placements.d.ts +15 -0
- package/dist/runtime/storage/placements.js +38 -0
- package/dist/runtime/storage/platform.d.ts +6 -0
- package/dist/runtime/storage/platform.js +9 -0
- package/dist/runtime/storage/retention.d.ts +73 -0
- package/dist/runtime/storage/retention.js +158 -0
- package/dist/runtime/subscriptions/identity.d.ts +31 -0
- package/dist/runtime/subscriptions/identity.js +45 -0
- package/dist/runtime/subscriptions/relay.d.ts +175 -0
- package/dist/runtime/subscriptions/relay.js +763 -0
- package/dist/runtime/subscriptions/storage.d.ts +40 -0
- package/dist/runtime/subscriptions/storage.js +98 -0
- package/dist/runtime/sweeps.d.ts +39 -0
- package/dist/runtime/sweeps.js +54 -0
- package/dist/runtime/telemetry/defects.d.ts +57 -0
- package/dist/runtime/telemetry/defects.js +43 -0
- package/dist/runtime/telemetry/metrics.d.ts +52 -0
- package/dist/runtime/telemetry/metrics.js +138 -0
- package/dist/runtime/telemetry/routes.d.ts +19 -0
- package/dist/runtime/telemetry/routes.js +18 -0
- package/dist/runtime/telemetry/sampler.d.ts +26 -0
- package/dist/runtime/telemetry/sampler.js +101 -0
- package/dist/runtime/telemetry/spans.d.ts +38 -0
- package/dist/runtime/telemetry/spans.js +44 -0
- package/dist/runtime/telemetry/usage.d.ts +52 -0
- package/dist/runtime/telemetry/usage.js +30 -0
- package/dist/runtime/topology/admission.d.ts +13 -0
- package/dist/runtime/topology/admission.js +36 -0
- package/dist/runtime/topology/locks.d.ts +56 -0
- package/dist/runtime/topology/locks.js +81 -0
- package/dist/runtime/topology/messages.d.ts +15 -0
- package/dist/runtime/topology/messages.js +32 -0
- package/dist/runtime/turn/admission.d.ts +22 -0
- package/dist/runtime/turn/admission.js +41 -0
- package/dist/runtime/turn/blobs.d.ts +38 -0
- package/dist/runtime/turn/blobs.js +215 -0
- package/dist/runtime/turn/execute.d.ts +208 -0
- package/dist/runtime/turn/execute.js +972 -0
- package/dist/runtime/turn/group.d.ts +165 -0
- package/dist/runtime/turn/group.js +326 -0
- package/dist/runtime/turn/hooks.d.ts +44 -0
- package/dist/runtime/turn/hooks.js +28 -0
- package/dist/runtime/turn/outbox.d.ts +159 -0
- package/dist/runtime/turn/outbox.js +269 -0
- package/dist/runtime/turn/pipeline.d.ts +68 -0
- package/dist/runtime/turn/pipeline.js +83 -0
- package/dist/runtime/turn/receipt.d.ts +81 -0
- package/dist/runtime/turn/receipt.js +32 -0
- package/dist/runtime/turn/relay.d.ts +179 -0
- package/dist/runtime/turn/relay.js +685 -0
- package/dist/runtime/turn/rows.d.ts +43 -0
- package/dist/runtime/turn/rows.js +592 -0
- package/dist/runtime/workflows/compatibility.d.ts +125 -0
- package/dist/runtime/workflows/compatibility.js +285 -0
- package/dist/runtime/workflows/engine.d.ts +107 -0
- package/dist/runtime/workflows/engine.js +826 -0
- package/dist/runtime/workflows/manifest.d.ts +34 -0
- package/dist/runtime/workflows/manifest.js +39 -0
- package/dist/runtime/workflows/steps.d.ts +33 -0
- package/dist/runtime/workflows/steps.js +152 -0
- package/dist/serve/api.d.ts +99 -0
- package/dist/serve/api.js +403 -0
- package/dist/serve/assertion/binding.d.ts +41 -0
- package/dist/serve/assertion/binding.js +92 -0
- package/dist/serve/assertion/verify.d.ts +93 -0
- package/dist/serve/assertion/verify.js +189 -0
- package/dist/serve/auth.d.ts +200 -0
- package/dist/serve/auth.js +92 -0
- package/dist/serve/clock.d.ts +10 -0
- package/dist/serve/clock.js +25 -0
- package/dist/serve/jwt.d.ts +65 -0
- package/dist/serve/jwt.js +202 -0
- package/dist/serve/layer.d.ts +98 -0
- package/dist/serve/layer.js +809 -0
- package/dist/serve/mcp/endpoint.d.ts +39 -0
- package/dist/serve/mcp/endpoint.js +187 -0
- package/dist/serve/mcp/tools.d.ts +37 -0
- package/dist/serve/mcp/tools.js +125 -0
- package/dist/serve/origin.d.ts +6 -0
- package/dist/serve/origin.js +21 -0
- package/dist/serve/sessions/feed.d.ts +79 -0
- package/dist/serve/sessions/feed.js +115 -0
- package/dist/serve/sessions/socket.d.ts +56 -0
- package/dist/serve/sessions/socket.js +212 -0
- package/dist/serve/sessions/sse.d.ts +27 -0
- package/dist/serve/sessions/sse.js +26 -0
- package/dist/serve/sessions/stream.d.ts +9 -0
- package/dist/serve/sessions/stream.js +9 -0
- package/dist/serve/sessions/watch.d.ts +12 -0
- package/dist/serve/sessions/watch.js +11 -0
- package/dist/serve/wire.d.ts +16 -0
- package/dist/serve/wire.js +50 -0
- package/dist/state/blob.d.ts +71 -0
- package/dist/state/blob.js +0 -0
- package/dist/state/migration.d.ts +53 -0
- package/dist/state/migration.js +29 -0
- package/dist/tables/fleet.d.ts +170 -0
- package/dist/tables/fleet.js +214 -0
- package/dist/tables/owned.d.ts +250 -0
- package/dist/tables/owned.js +233 -0
- package/dist/testing/actor-test.d.ts +360 -0
- package/dist/testing/actor-test.js +337 -0
- package/dist/testing/cluster.d.ts +93 -0
- package/dist/testing/cluster.js +296 -0
- package/dist/testing/conformance/access.d.ts +5 -0
- package/dist/testing/conformance/access.js +531 -0
- package/dist/testing/conformance/admission.d.ts +11 -0
- package/dist/testing/conformance/admission.js +182 -0
- package/dist/testing/conformance/adoption.d.ts +2 -0
- package/dist/testing/conformance/adoption.js +1019 -0
- package/dist/testing/conformance/assertions.d.ts +202 -0
- package/dist/testing/conformance/assertions.js +849 -0
- package/dist/testing/conformance/batches.d.ts +41 -0
- package/dist/testing/conformance/batches.js +388 -0
- package/dist/testing/conformance/blobs.d.ts +14 -0
- package/dist/testing/conformance/blobs.js +405 -0
- package/dist/testing/conformance/capacity.d.ts +8 -0
- package/dist/testing/conformance/capacity.js +433 -0
- package/dist/testing/conformance/client.d.ts +5 -0
- package/dist/testing/conformance/client.js +719 -0
- package/dist/testing/conformance/cold-serve.d.ts +16 -0
- package/dist/testing/conformance/cold-serve.js +254 -0
- package/dist/testing/conformance/connections/actors.d.ts +1143 -0
- package/dist/testing/conformance/connections/actors.js +180 -0
- package/dist/testing/conformance/connections/harness.d.ts +1754 -0
- package/dist/testing/conformance/connections/harness.js +142 -0
- package/dist/testing/conformance/connections/holders.d.ts +4 -0
- package/dist/testing/conformance/connections/holders.js +165 -0
- package/dist/testing/conformance/connections/lifecycle.d.ts +4 -0
- package/dist/testing/conformance/connections/lifecycle.js +113 -0
- package/dist/testing/conformance/connections/limits.d.ts +4 -0
- package/dist/testing/conformance/connections/limits.js +127 -0
- package/dist/testing/conformance/connections/reauthorization.d.ts +4 -0
- package/dist/testing/conformance/connections/reauthorization.js +170 -0
- package/dist/testing/conformance/connections/resync.d.ts +4 -0
- package/dist/testing/conformance/connections/resync.js +360 -0
- package/dist/testing/conformance/connections/takeover.d.ts +4 -0
- package/dist/testing/conformance/connections/takeover.js +287 -0
- package/dist/testing/conformance/connections.d.ts +4 -0
- package/dist/testing/conformance/connections.js +15 -0
- package/dist/testing/conformance/content-blobs.d.ts +16 -0
- package/dist/testing/conformance/content-blobs.js +534 -0
- package/dist/testing/conformance/counter.d.ts +16 -0
- package/dist/testing/conformance/counter.js +813 -0
- package/dist/testing/conformance/cron.d.ts +5 -0
- package/dist/testing/conformance/cron.js +665 -0
- package/dist/testing/conformance/drain.d.ts +26 -0
- package/dist/testing/conformance/drain.js +540 -0
- package/dist/testing/conformance/effect-control.d.ts +38 -0
- package/dist/testing/conformance/effect-control.js +1059 -0
- package/dist/testing/conformance/effects.d.ts +23 -0
- package/dist/testing/conformance/effects.js +432 -0
- package/dist/testing/conformance/events.d.ts +28 -0
- package/dist/testing/conformance/events.js +335 -0
- package/dist/testing/conformance/export.d.ts +2 -0
- package/dist/testing/conformance/export.js +368 -0
- package/dist/testing/conformance/fleet.d.ts +444 -0
- package/dist/testing/conformance/fleet.js +1009 -0
- package/dist/testing/conformance/groups.d.ts +7 -0
- package/dist/testing/conformance/groups.js +353 -0
- package/dist/testing/conformance/heap.d.ts +3 -0
- package/dist/testing/conformance/heap.js +149 -0
- package/dist/testing/conformance/http.d.ts +2809 -0
- package/dist/testing/conformance/http.js +1234 -0
- package/dist/testing/conformance/inspection-views.d.ts +8 -0
- package/dist/testing/conformance/inspection-views.js +272 -0
- package/dist/testing/conformance/inspector.d.ts +7 -0
- package/dist/testing/conformance/inspector.js +650 -0
- package/dist/testing/conformance/mint.d.ts +58 -0
- package/dist/testing/conformance/mint.js +692 -0
- package/dist/testing/conformance/multi-runner.d.ts +8 -0
- package/dist/testing/conformance/multi-runner.js +403 -0
- package/dist/testing/conformance/neki/plan.d.ts +19 -0
- package/dist/testing/conformance/neki/plan.js +30 -0
- package/dist/testing/conformance/observability.d.ts +3 -0
- package/dist/testing/conformance/observability.js +343 -0
- package/dist/testing/conformance/offline.d.ts +4 -0
- package/dist/testing/conformance/offline.js +474 -0
- package/dist/testing/conformance/operator-harness.d.ts +57 -0
- package/dist/testing/conformance/operator-harness.js +78 -0
- package/dist/testing/conformance/operator.d.ts +3 -0
- package/dist/testing/conformance/operator.js +379 -0
- package/dist/testing/conformance/outbox-cross-shard.d.ts +14 -0
- package/dist/testing/conformance/outbox-cross-shard.js +160 -0
- package/dist/testing/conformance/outbox.d.ts +36 -0
- package/dist/testing/conformance/outbox.js +437 -0
- package/dist/testing/conformance/payload-migrations.d.ts +3 -0
- package/dist/testing/conformance/payload-migrations.js +612 -0
- package/dist/testing/conformance/pipeline.d.ts +3 -0
- package/dist/testing/conformance/pipeline.js +1040 -0
- package/dist/testing/conformance/placement.d.ts +22 -0
- package/dist/testing/conformance/placement.js +539 -0
- package/dist/testing/conformance/platform.d.ts +40 -0
- package/dist/testing/conformance/platform.js +101 -0
- package/dist/testing/conformance/progress.d.ts +39 -0
- package/dist/testing/conformance/progress.js +666 -0
- package/dist/testing/conformance/properties.d.ts +6 -0
- package/dist/testing/conformance/properties.js +295 -0
- package/dist/testing/conformance/protocols.d.ts +4 -0
- package/dist/testing/conformance/protocols.js +618 -0
- package/dist/testing/conformance/provider/advertise.d.ts +21 -0
- package/dist/testing/conformance/provider/advertise.js +44 -0
- package/dist/testing/conformance/read-your-writes.d.ts +20 -0
- package/dist/testing/conformance/read-your-writes.js +192 -0
- package/dist/testing/conformance/reducers.d.ts +8 -0
- package/dist/testing/conformance/reducers.js +258 -0
- package/dist/testing/conformance/relay.d.ts +42 -0
- package/dist/testing/conformance/relay.js +1115 -0
- package/dist/testing/conformance/restore.d.ts +43 -0
- package/dist/testing/conformance/restore.js +341 -0
- package/dist/testing/conformance/retention.d.ts +14 -0
- package/dist/testing/conformance/retention.js +463 -0
- package/dist/testing/conformance/rls.d.ts +24 -0
- package/dist/testing/conformance/rls.js +576 -0
- package/dist/testing/conformance/simulation.d.ts +31 -0
- package/dist/testing/conformance/simulation.js +167 -0
- package/dist/testing/conformance/single-shard.d.ts +2 -0
- package/dist/testing/conformance/single-shard.js +125 -0
- package/dist/testing/conformance/singleton.d.ts +3 -0
- package/dist/testing/conformance/singleton.js +293 -0
- package/dist/testing/conformance/statements.d.ts +60 -0
- package/dist/testing/conformance/statements.js +108 -0
- package/dist/testing/conformance/streams.d.ts +7 -0
- package/dist/testing/conformance/streams.js +280 -0
- package/dist/testing/conformance/subscriptions/access.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/access.js +98 -0
- package/dist/testing/conformance/subscriptions/actors.d.ts +4910 -0
- package/dist/testing/conformance/subscriptions/actors.js +372 -0
- package/dist/testing/conformance/subscriptions/cluster.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/cluster.js +89 -0
- package/dist/testing/conformance/subscriptions/delivery.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/delivery.js +253 -0
- package/dist/testing/conformance/subscriptions/deploys.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/deploys.js +162 -0
- package/dist/testing/conformance/subscriptions/epochs.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/epochs.js +169 -0
- package/dist/testing/conformance/subscriptions/failures.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/failures.js +108 -0
- package/dist/testing/conformance/subscriptions/feeds.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/feeds.js +218 -0
- package/dist/testing/conformance/subscriptions/harness.d.ts +124 -0
- package/dist/testing/conformance/subscriptions/harness.js +143 -0
- package/dist/testing/conformance/subscriptions/operator.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/operator.js +128 -0
- package/dist/testing/conformance/subscriptions/retention.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/retention.js +288 -0
- package/dist/testing/conformance/subscriptions/routing.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/routing.js +179 -0
- package/dist/testing/conformance/subscriptions.d.ts +4 -0
- package/dist/testing/conformance/subscriptions.js +19 -0
- package/dist/testing/conformance/tables.d.ts +125 -0
- package/dist/testing/conformance/tables.js +664 -0
- package/dist/testing/conformance/transports/actors.d.ts +1907 -0
- package/dist/testing/conformance/transports/actors.js +163 -0
- package/dist/testing/conformance/transports/client.d.ts +3 -0
- package/dist/testing/conformance/transports/client.js +237 -0
- package/dist/testing/conformance/transports/feeds.d.ts +3 -0
- package/dist/testing/conformance/transports/feeds.js +232 -0
- package/dist/testing/conformance/transports/harness.d.ts +93 -0
- package/dist/testing/conformance/transports/harness.js +84 -0
- package/dist/testing/conformance/transports/streams.d.ts +3 -0
- package/dist/testing/conformance/transports/streams.js +96 -0
- package/dist/testing/conformance/transports/websocket.d.ts +3 -0
- package/dist/testing/conformance/transports/websocket.js +384 -0
- package/dist/testing/conformance/transports/wire.d.ts +141 -0
- package/dist/testing/conformance/transports/wire.js +204 -0
- package/dist/testing/conformance/transports.d.ts +3 -0
- package/dist/testing/conformance/transports.js +11 -0
- package/dist/testing/conformance/watch.d.ts +59 -0
- package/dist/testing/conformance/watch.js +879 -0
- package/dist/testing/conformance/workflow-engine.d.ts +97 -0
- package/dist/testing/conformance/workflow-engine.js +253 -0
- package/dist/testing/conformance/workflow-versions.d.ts +3 -0
- package/dist/testing/conformance/workflow-versions.js +545 -0
- package/dist/testing/conformance/workflows/access.d.ts +4 -0
- package/dist/testing/conformance/workflows/access.js +147 -0
- package/dist/testing/conformance/workflows/actors.d.ts +2317 -0
- package/dist/testing/conformance/workflows/actors.js +305 -0
- package/dist/testing/conformance/workflows/basics.d.ts +4 -0
- package/dist/testing/conformance/workflows/basics.js +144 -0
- package/dist/testing/conformance/workflows/engine.d.ts +4 -0
- package/dist/testing/conformance/workflows/engine.js +80 -0
- package/dist/testing/conformance/workflows/guards.d.ts +4 -0
- package/dist/testing/conformance/workflows/guards.js +172 -0
- package/dist/testing/conformance/workflows/harness.d.ts +14 -0
- package/dist/testing/conformance/workflows/harness.js +44 -0
- package/dist/testing/conformance/workflows/recovery.d.ts +4 -0
- package/dist/testing/conformance/workflows/recovery.js +181 -0
- package/dist/testing/conformance/workflows/starts.d.ts +4 -0
- package/dist/testing/conformance/workflows/starts.js +57 -0
- package/dist/testing/conformance/workflows/suspension.d.ts +4 -0
- package/dist/testing/conformance/workflows/suspension.js +106 -0
- package/dist/testing/conformance/workflows/waits.d.ts +4 -0
- package/dist/testing/conformance/workflows/waits.js +284 -0
- package/dist/testing/conformance/workflows.d.ts +4 -0
- package/dist/testing/conformance/workflows.js +19 -0
- package/dist/testing/conformance.d.ts +330 -0
- package/dist/testing/conformance.js +364 -0
- package/dist/testing/database.d.ts +31 -0
- package/dist/testing/database.js +70 -0
- package/dist/testing/foundation.d.ts +41 -0
- package/dist/testing/foundation.js +517 -0
- package/dist/testing/index.d.ts +20 -0
- package/dist/testing/index.js +12 -0
- package/dist/testing/property.d.ts +40 -0
- package/dist/testing/property.js +95 -0
- package/dist/testing/simulate-cluster.d.ts +112 -0
- package/dist/testing/simulate-cluster.js +257 -0
- package/dist/testing/simulate.d.ts +90 -0
- package/dist/testing/simulate.js +127 -0
- package/package.json +1 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PgClient } from "@effect/sql-pg";
|
|
2
|
+
import { PgliteClient } from "@effect/sql-pglite";
|
|
3
|
+
import { Context, Effect } from "effect";
|
|
4
|
+
import { SqlClient } from "effect/sql";
|
|
5
|
+
import { ContentStore } from "../../handles/content.ts";
|
|
6
|
+
/**
|
|
7
|
+
* Makes a job layer unassignable when its executors or its build need a
|
|
8
|
+
* SQL client or the content store, since a capability captured at build time
|
|
9
|
+
* would reach executors.
|
|
10
|
+
*/
|
|
11
|
+
export type NoDatabase<R> = [
|
|
12
|
+
Extract<R, SqlClient.SqlClient | PgClient.PgClient | PgliteClient.PgliteClient | ContentStore>
|
|
13
|
+
] extends [never] ? unknown : {
|
|
14
|
+
readonly "Executors have no database capability": never;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Runs an executor attempt in its layer's build context without the SQL
|
|
18
|
+
* client or the content store, even when that layer was built where they are provided.
|
|
19
|
+
*/
|
|
20
|
+
export declare const withoutDatabase: (services: Context.Context<never>) => <A, E>(attempt: Effect.Effect<A, E>) => Effect.Effect<A, E>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PgClient } from "@effect/sql-pg";
|
|
2
|
+
import { PgliteClient } from "@effect/sql-pglite";
|
|
3
|
+
import { Context, Effect } from "effect";
|
|
4
|
+
import { SqlClient } from "effect/sql";
|
|
5
|
+
import { ContentStore } from "../../handles/content.js";
|
|
6
|
+
/**
|
|
7
|
+
* Runs an executor attempt in its layer's build context without the SQL
|
|
8
|
+
* client or the content store, even when that layer was built where they are provided.
|
|
9
|
+
*/
|
|
10
|
+
export const withoutDatabase = (services) => (attempt) => attempt.pipe(Effect.updateContext(() => Context.omit(SqlClient.SqlClient, PgClient.PgClient, PgliteClient.PgliteClient, ContentStore)(services)));
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Context, Effect } from "effect";
|
|
2
|
+
import type { ActorRef } from "../../identity/caller.ts";
|
|
3
|
+
/** An encoded frame is at most this many bytes. */
|
|
4
|
+
export declare const MAX_PROGRESS_BYTES = 4096;
|
|
5
|
+
/** How long closing an attempt's progress waits on the sink before settling without it. */
|
|
6
|
+
export declare const PROGRESS_CLOSE_WAIT_MS = 100;
|
|
7
|
+
/** Progress messages one runner's executor pool sends per second at most. */
|
|
8
|
+
export declare const RUNNER_PROGRESS_PER_SECOND = 2000;
|
|
9
|
+
/** One progress frame on its way from an executor attempt to the owner. */
|
|
10
|
+
export interface ProgressMessage {
|
|
11
|
+
readonly ref: ActorRef;
|
|
12
|
+
readonly jobId: string;
|
|
13
|
+
readonly job: string;
|
|
14
|
+
/** The attempt number of the job, from 1. */
|
|
15
|
+
readonly attempt: number;
|
|
16
|
+
/** Per attempt, from 1; counts the attempt's accepted `progress` calls. */
|
|
17
|
+
readonly seq: number;
|
|
18
|
+
/** The attempt's lease deadline on the database clock, as last claimed or renewed. */
|
|
19
|
+
readonly leaseUntil: number;
|
|
20
|
+
readonly frame: Uint8Array;
|
|
21
|
+
}
|
|
22
|
+
/** Sent after a job's terminal settle commits; no attempt of it reports again. */
|
|
23
|
+
export interface ProgressClosed {
|
|
24
|
+
readonly ref: ActorRef;
|
|
25
|
+
readonly jobId: string;
|
|
26
|
+
readonly attempt: number;
|
|
27
|
+
}
|
|
28
|
+
declare const ProgressSink_base: Context.ServiceClass<ProgressSink, "@rikalabs/akter/runtime/jobs/progress/ProgressSink", {
|
|
29
|
+
readonly wants: (actor: string, job: string) => boolean;
|
|
30
|
+
readonly send: (message: ProgressMessage) => Effect.Effect<void>;
|
|
31
|
+
readonly closed: (message: ProgressClosed) => Effect.Effect<void>;
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* Where an executor pool sends progress. Sends are fire-and-forget: there is
|
|
35
|
+
* no acknowledgment or resend, and a lost message is a lost frame. Without a
|
|
36
|
+
* sink, or for a job `wants` rejects, the pool sends nothing.
|
|
37
|
+
*/
|
|
38
|
+
export declare class ProgressSink extends ProgressSink_base {
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Sees every message a runner's pool sends before the runtime delivers it;
|
|
42
|
+
* `false` drops it. Tests record and drop progress here, between the pool and
|
|
43
|
+
* the owner.
|
|
44
|
+
*/
|
|
45
|
+
export declare const ProgressTap: Context.Reference<{
|
|
46
|
+
readonly send: (message: ProgressMessage) => Effect.Effect<boolean>;
|
|
47
|
+
readonly closed: (message: ProgressClosed) => Effect.Effect<boolean>;
|
|
48
|
+
}>;
|
|
49
|
+
/** One attempt's progress slot: latest wins, sent at most once per `everyMs`. */
|
|
50
|
+
interface ProgressSlot {
|
|
51
|
+
/** False once nothing more will be sent, so a caller can skip encoding frames. */
|
|
52
|
+
readonly active: () => boolean;
|
|
53
|
+
/** Replaces the pending frame; ignored once closed. */
|
|
54
|
+
readonly offer: (frame: Uint8Array) => Effect.Effect<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Ignores every later offer, then sends the pending frame, borrowing a
|
|
57
|
+
* token when none is free. It never fails with the sink and waits on it
|
|
58
|
+
* only briefly.
|
|
59
|
+
*/
|
|
60
|
+
readonly close: Effect.Effect<void>;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A runner's progress pool. It holds one slot per running attempt and a
|
|
64
|
+
* runner-wide token bucket; a frame that finds no token stays in its slot,
|
|
65
|
+
* where newer frames replace it, until one is free. A closing slot's last
|
|
66
|
+
* frame borrows a token instead of waiting, so the debt delays later sends and
|
|
67
|
+
* the runner still averages `perSecond`. The bucket refills at `perSecond` up
|
|
68
|
+
* to a burst of one second's worth. Closing waits on the sink at most
|
|
69
|
+
* `PROGRESS_CLOSE_WAIT_MS`; a final frame still sending then finishes on its
|
|
70
|
+
* own. Closing sends the last frame even if a send was interrupted, and the
|
|
71
|
+
* closed message follows that attempt's last flush. Only jobs that could
|
|
72
|
+
* have opened a slot are closed, and an attempt that ends without a terminal
|
|
73
|
+
* settle keeps no flush (`forget`).
|
|
74
|
+
*/
|
|
75
|
+
export declare const progressPool: (options?: {
|
|
76
|
+
readonly perSecond?: number;
|
|
77
|
+
} | undefined) => Effect.Effect<{
|
|
78
|
+
open: (attempt: {
|
|
79
|
+
readonly ref: ActorRef;
|
|
80
|
+
readonly jobId: string;
|
|
81
|
+
readonly job: string;
|
|
82
|
+
readonly attempt: number;
|
|
83
|
+
readonly everyMs: number | undefined;
|
|
84
|
+
readonly leaseUntil: () => number;
|
|
85
|
+
}) => Effect.Effect<ProgressSlot, never, never>;
|
|
86
|
+
closed: (attempt: {
|
|
87
|
+
readonly ref: ActorRef;
|
|
88
|
+
readonly jobId: string;
|
|
89
|
+
readonly job: string;
|
|
90
|
+
readonly attempt: number;
|
|
91
|
+
readonly everyMs: number | undefined;
|
|
92
|
+
}) => Effect.Effect<void, never, never>;
|
|
93
|
+
forget: (jobId: string) => Effect.Effect<boolean, never, never>;
|
|
94
|
+
}, never, import("effect/Scope").Scope>;
|
|
95
|
+
export {};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { Clock, Context, Effect, Fiber, Option, Queue } from "effect";
|
|
2
|
+
/** An encoded frame is at most this many bytes. */
|
|
3
|
+
export const MAX_PROGRESS_BYTES = 4096;
|
|
4
|
+
/** How long closing an attempt's progress waits on the sink before settling without it. */
|
|
5
|
+
export const PROGRESS_CLOSE_WAIT_MS = 100;
|
|
6
|
+
/** Progress messages one runner's executor pool sends per second at most. */
|
|
7
|
+
export const RUNNER_PROGRESS_PER_SECOND = 2000;
|
|
8
|
+
/**
|
|
9
|
+
* Where an executor pool sends progress. Sends are fire-and-forget: there is
|
|
10
|
+
* no acknowledgment or resend, and a lost message is a lost frame. Without a
|
|
11
|
+
* sink, or for a job `wants` rejects, the pool sends nothing.
|
|
12
|
+
*/
|
|
13
|
+
export class ProgressSink extends Context.Service()("@rikalabs/akter/runtime/jobs/progress/ProgressSink") {
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Sees every message a runner's pool sends before the runtime delivers it;
|
|
17
|
+
* `false` drops it. Tests record and drop progress here, between the pool and
|
|
18
|
+
* the owner.
|
|
19
|
+
*/
|
|
20
|
+
export const ProgressTap = Context.Reference("@rikalabs/akter/runtime/jobs/progress/ProgressTap", {
|
|
21
|
+
defaultValue: () => ({ send: () => Effect.succeed(true), closed: () => Effect.succeed(true) }),
|
|
22
|
+
});
|
|
23
|
+
const closedSlot = {
|
|
24
|
+
active: () => false,
|
|
25
|
+
offer: () => Effect.void,
|
|
26
|
+
close: Effect.void,
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* A runner's progress pool. It holds one slot per running attempt and a
|
|
30
|
+
* runner-wide token bucket; a frame that finds no token stays in its slot,
|
|
31
|
+
* where newer frames replace it, until one is free. A closing slot's last
|
|
32
|
+
* frame borrows a token instead of waiting, so the debt delays later sends and
|
|
33
|
+
* the runner still averages `perSecond`. The bucket refills at `perSecond` up
|
|
34
|
+
* to a burst of one second's worth. Closing waits on the sink at most
|
|
35
|
+
* `PROGRESS_CLOSE_WAIT_MS`; a final frame still sending then finishes on its
|
|
36
|
+
* own. Closing sends the last frame even if a send was interrupted, and the
|
|
37
|
+
* closed message follows that attempt's last flush. Only jobs that could
|
|
38
|
+
* have opened a slot are closed, and an attempt that ends without a terminal
|
|
39
|
+
* settle keeps no flush (`forget`).
|
|
40
|
+
*/
|
|
41
|
+
export const progressPool = Effect.fnUntraced(function* (options) {
|
|
42
|
+
const sink = Option.getOrUndefined(yield* Effect.serviceOption(ProgressSink));
|
|
43
|
+
const scope = yield* Effect.scope;
|
|
44
|
+
const perSecond = options?.perSecond ?? RUNNER_PROGRESS_PER_SECOND;
|
|
45
|
+
let tokens = perSecond;
|
|
46
|
+
let refilledAt = yield* Clock.currentTimeMillis;
|
|
47
|
+
const refill = Effect.map(Clock.currentTimeMillis, (now) => {
|
|
48
|
+
tokens = Math.min(perSecond, tokens + ((now - refilledAt) * perSecond) / 1000);
|
|
49
|
+
refilledAt = now;
|
|
50
|
+
});
|
|
51
|
+
/** Takes a token if one is free, or always when `borrow` is set, going into debt. */
|
|
52
|
+
const take = (borrow) => Effect.map(refill, () => {
|
|
53
|
+
if (tokens < 1 && !borrow)
|
|
54
|
+
return false;
|
|
55
|
+
tokens -= 1;
|
|
56
|
+
return true;
|
|
57
|
+
});
|
|
58
|
+
const awaitBriefly = (fiber) => Fiber.await(fiber).pipe(Effect.timeoutOption(PROGRESS_CLOSE_WAIT_MS), Effect.asVoid);
|
|
59
|
+
const detached = (effect) => effect.pipe(Effect.ignoreCause, Effect.forkIn(scope), Effect.tap(awaitBriefly));
|
|
60
|
+
const flushes = new Map();
|
|
61
|
+
const token = Effect.gen(function* () {
|
|
62
|
+
while (!(yield* take(false)))
|
|
63
|
+
yield* Effect.sleep(Math.ceil(((1 - tokens) * 1000) / perSecond));
|
|
64
|
+
});
|
|
65
|
+
const open = Effect.fnUntraced(function* (attempt) {
|
|
66
|
+
if (sink === undefined ||
|
|
67
|
+
attempt.everyMs === undefined ||
|
|
68
|
+
!sink.wants(attempt.ref.actor, attempt.job))
|
|
69
|
+
return closedSlot;
|
|
70
|
+
const everyMs = attempt.everyMs;
|
|
71
|
+
const signal = yield* Queue.sliding(1);
|
|
72
|
+
let seq = 0;
|
|
73
|
+
let closed = false;
|
|
74
|
+
let pending;
|
|
75
|
+
let inflight;
|
|
76
|
+
let sentAt;
|
|
77
|
+
const send = (frame) => sink
|
|
78
|
+
.send({
|
|
79
|
+
ref: attempt.ref,
|
|
80
|
+
jobId: attempt.jobId,
|
|
81
|
+
job: attempt.job,
|
|
82
|
+
attempt: attempt.attempt,
|
|
83
|
+
seq: frame.seq,
|
|
84
|
+
leaseUntil: attempt.leaseUntil(),
|
|
85
|
+
frame: frame.frame,
|
|
86
|
+
})
|
|
87
|
+
.pipe(Effect.ignoreCause);
|
|
88
|
+
const sender = yield* Effect.gen(function* () {
|
|
89
|
+
while (true) {
|
|
90
|
+
yield* Queue.take(signal);
|
|
91
|
+
if (sentAt !== undefined) {
|
|
92
|
+
const wait = sentAt + everyMs - (yield* Clock.currentTimeMillis);
|
|
93
|
+
if (wait > 0)
|
|
94
|
+
yield* Effect.sleep(wait);
|
|
95
|
+
}
|
|
96
|
+
if (pending === undefined)
|
|
97
|
+
continue;
|
|
98
|
+
yield* token;
|
|
99
|
+
const next = pending;
|
|
100
|
+
pending = undefined;
|
|
101
|
+
sentAt = yield* Clock.currentTimeMillis;
|
|
102
|
+
inflight = next;
|
|
103
|
+
yield* send(next);
|
|
104
|
+
inflight = undefined;
|
|
105
|
+
}
|
|
106
|
+
}).pipe(Effect.forkIn(scope));
|
|
107
|
+
return {
|
|
108
|
+
active: () => !closed,
|
|
109
|
+
offer: (frame) => Effect.suspend(() => {
|
|
110
|
+
if (closed)
|
|
111
|
+
return Effect.void;
|
|
112
|
+
seq += 1;
|
|
113
|
+
pending = { seq, frame };
|
|
114
|
+
return Queue.offer(signal, undefined).pipe(Effect.asVoid);
|
|
115
|
+
}),
|
|
116
|
+
close: Effect.suspend(() => {
|
|
117
|
+
if (closed)
|
|
118
|
+
return Effect.void;
|
|
119
|
+
closed = true;
|
|
120
|
+
return Fiber.interrupt(sender).pipe(Effect.andThen(Effect.suspend(() => {
|
|
121
|
+
const last = pending ?? inflight;
|
|
122
|
+
pending = undefined;
|
|
123
|
+
inflight = undefined;
|
|
124
|
+
if (last === undefined)
|
|
125
|
+
return Effect.void;
|
|
126
|
+
return Effect.andThen(take(true), send(last));
|
|
127
|
+
})), detached, Effect.map((flush) => {
|
|
128
|
+
flushes.set(attempt.jobId, flush);
|
|
129
|
+
}));
|
|
130
|
+
}),
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
const closed = (attempt) => Effect.suspend(() => {
|
|
134
|
+
const flush = flushes.get(attempt.jobId);
|
|
135
|
+
flushes.delete(attempt.jobId);
|
|
136
|
+
if (sink === undefined ||
|
|
137
|
+
attempt.everyMs === undefined ||
|
|
138
|
+
!sink.wants(attempt.ref.actor, attempt.job))
|
|
139
|
+
return Effect.void;
|
|
140
|
+
return (flush === undefined ? Effect.void : awaitBriefly(flush)).pipe(Effect.andThen(sink.closed({ ref: attempt.ref, jobId: attempt.jobId, attempt: attempt.attempt })), detached, Effect.asVoid);
|
|
141
|
+
});
|
|
142
|
+
const forget = (jobId) => Effect.sync(() => flushes.delete(jobId));
|
|
143
|
+
return { open, closed, forget };
|
|
144
|
+
});
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { PgClient } from "@effect/sql-pg";
|
|
2
|
+
import { Crypto, Duration, Effect, Layer } from "effect";
|
|
3
|
+
import { SqlClient, SqlError } from "effect/sql";
|
|
4
|
+
import { Actors } from "../handles/actors.ts";
|
|
5
|
+
import { InternalActors } from "./actors.ts";
|
|
6
|
+
import type { AccessRequest } from "../policies/access.ts";
|
|
7
|
+
import { pglite } from "./database/pglite.ts";
|
|
8
|
+
import { DefectLog } from "./telemetry/defects.ts";
|
|
9
|
+
import { OperatorRuntime } from "./operators/repair.ts";
|
|
10
|
+
import { TelemetrySampler } from "./telemetry/sampler.ts";
|
|
11
|
+
import { TurnConnections } from "./turn/pipeline.ts";
|
|
12
|
+
import { ContentStore } from "../handles/content.ts";
|
|
13
|
+
import { type GrantKey } from "./content/grant.ts";
|
|
14
|
+
import { RuntimeControl } from "./drain.ts";
|
|
15
|
+
import type { AnyFleetView } from "../tables/fleet.ts";
|
|
16
|
+
/** Configuration for `Actors.layer`: authorization, actor and effect layers, timing, retention, and row-level security. */
|
|
17
|
+
export interface Options {
|
|
18
|
+
/**
|
|
19
|
+
* The global authorization hook, asked about every external request beside
|
|
20
|
+
* the actor's own `access` policy; when both exist both must allow. With
|
|
21
|
+
* neither, `System` callers are allowed and `User` and `Anonymous` callers,
|
|
22
|
+
* which only arrive through `Actor.serve` or the client, are denied. Hooks
|
|
23
|
+
* should deny kinds they do not know.
|
|
24
|
+
*/
|
|
25
|
+
readonly authorize?: (request: AccessRequest) => Effect.Effect<boolean>;
|
|
26
|
+
readonly retryWindowMs?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Activations this runner keeps in memory at once. A command that needs a
|
|
29
|
+
* new activation past the limit fails `RunnerAtCapacity` and is retried
|
|
30
|
+
* until an idle actor hibernates or the delivery timeout passes. Default
|
|
31
|
+
* 10,000, which bounds runner memory; raise it with the memory you give the
|
|
32
|
+
* process.
|
|
33
|
+
*/
|
|
34
|
+
readonly maxResidentActors?: number;
|
|
35
|
+
/**
|
|
36
|
+
* How this runner refuses external commands it cannot serve promptly. A
|
|
37
|
+
* refused command gets `ActorUnavailable` with a `retryAfter` before any of
|
|
38
|
+
* it runs, so load past capacity waits in callers' retries under the same
|
|
39
|
+
* command id instead of in this runner's queues.
|
|
40
|
+
*/
|
|
41
|
+
readonly admission?: {
|
|
42
|
+
/** External commands worked on at once, from admission to reply. Default 64. */
|
|
43
|
+
readonly concurrency?: number;
|
|
44
|
+
/**
|
|
45
|
+
* How long a command past `concurrency` waits for a slot, in arrival
|
|
46
|
+
* order, before it is refused; at most `concurrency` commands wait.
|
|
47
|
+
* Default 100 milliseconds.
|
|
48
|
+
*/
|
|
49
|
+
readonly wait?: Duration.Input;
|
|
50
|
+
/**
|
|
51
|
+
* Served command requests processed at once, including authentication and
|
|
52
|
+
* body parsing. The next is refused before either starts. Shared across
|
|
53
|
+
* this runtime's serve layers. Default 64.
|
|
54
|
+
*/
|
|
55
|
+
readonly requests?: number;
|
|
56
|
+
};
|
|
57
|
+
/** The outbox relay of this runner; every default equals the single-runner M1 behaviour. */
|
|
58
|
+
readonly relay?: {
|
|
59
|
+
/** Durable polling interval, jittered by ±10% per wait. Default 1 second. */
|
|
60
|
+
readonly poll?: Duration.Input;
|
|
61
|
+
/** Intent rows one claim takes at most. Default 256. */
|
|
62
|
+
readonly passLimit?: number;
|
|
63
|
+
/** Intents delivered at once. Default 16. */
|
|
64
|
+
readonly deliveryConcurrency?: number;
|
|
65
|
+
/**
|
|
66
|
+
* How long a claimed intent stays out of every runner's scans. Default:
|
|
67
|
+
* the largest `commandTimeout + lockWait` of the registered actor types,
|
|
68
|
+
* plus 5 seconds.
|
|
69
|
+
*/
|
|
70
|
+
readonly claimLease?: Duration.Input;
|
|
71
|
+
/** Cap on intent and subscription redelivery backoff. Default 256 seconds. */
|
|
72
|
+
readonly maxBackoff?: Duration.Input;
|
|
73
|
+
/**
|
|
74
|
+
* Subscription deliveries in flight at once, separate from intent
|
|
75
|
+
* slots; feed expansions and control registrations each get as many.
|
|
76
|
+
* Default 16.
|
|
77
|
+
*/
|
|
78
|
+
readonly subscriptionConcurrency?: number;
|
|
79
|
+
/** Matching events one claimed subscription row delivers before it settles. Default 16. */
|
|
80
|
+
readonly subscriptionBatch?: number;
|
|
81
|
+
};
|
|
82
|
+
/** Telemetry this runner keeps beside the spans and metrics it reports. */
|
|
83
|
+
readonly observability?: {
|
|
84
|
+
/** Defect spans the runner keeps for `durable defects list`, newest last. Default 1,000. */
|
|
85
|
+
readonly defects?: number;
|
|
86
|
+
/**
|
|
87
|
+
* How often one runner of the deployment samples the database gauges
|
|
88
|
+
* (outbox rows, relay lag, stuck rows, subscription lag, pinned events).
|
|
89
|
+
* Default 15 seconds.
|
|
90
|
+
*/
|
|
91
|
+
readonly sampleEvery?: Duration.Input;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* How long this runtime keeps writing event and effect payload versions
|
|
95
|
+
* without refreshing its writer rows; it refreshes every half window and
|
|
96
|
+
* refuses new turns once a window passes without a refresh, so
|
|
97
|
+
* `durable payloads clear` can tell when no turn still writes an old
|
|
98
|
+
* version. Default 2 minutes, at least 1 second.
|
|
99
|
+
*/
|
|
100
|
+
readonly payloadWriterWindow?: Duration.Input;
|
|
101
|
+
/**
|
|
102
|
+
* Shared content (`Actor.content`). Required when an actor type declares
|
|
103
|
+
* content or code uploads it.
|
|
104
|
+
*/
|
|
105
|
+
readonly content?: {
|
|
106
|
+
/**
|
|
107
|
+
* Grant keys. The first signs; every listed key verifies. To rotate, put
|
|
108
|
+
* the new key first, keep the old one listed for one grant lifetime (an
|
|
109
|
+
* hour), then remove it.
|
|
110
|
+
*/
|
|
111
|
+
readonly keys: ReadonlyArray<GrantKey>;
|
|
112
|
+
/** How long unreferenced content is kept after its last grant expires. Default 24 hours. */
|
|
113
|
+
readonly grace?: Duration.Input;
|
|
114
|
+
/**
|
|
115
|
+
* The most any two shards' database clocks may differ; attaches demand
|
|
116
|
+
* this much remaining grant validity and the sweep waits it out. Default 60 seconds.
|
|
117
|
+
*/
|
|
118
|
+
readonly skew?: Duration.Input;
|
|
119
|
+
};
|
|
120
|
+
/** The job executor pool of this runner. */
|
|
121
|
+
readonly executors?: {
|
|
122
|
+
/** Job attempts running at once. Default 64. */
|
|
123
|
+
readonly concurrency?: number;
|
|
124
|
+
/** An attempt's claim, renewed every third of it; at least 3 seconds. Default 60 seconds. */
|
|
125
|
+
readonly lease?: Duration.Input;
|
|
126
|
+
/**
|
|
127
|
+
* How often a running attempt checks whether a turn on another runner
|
|
128
|
+
* cancelled its job; at least 1 second, at most a third of the lease.
|
|
129
|
+
* Default a third of the lease. A cancellation committed on the attempt's
|
|
130
|
+
* own runner reaches it at once.
|
|
131
|
+
*/
|
|
132
|
+
readonly cancelCheck?: Duration.Input;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Opt-in row-level security. Command turns and queries run as `role` with
|
|
136
|
+
* the `durable.tenant` setting of the actor they serve, so the
|
|
137
|
+
* `durable_tenant` policies admit no other tenant's rows. The role must not
|
|
138
|
+
* be a superuser or bypass row-level security, this login must be able to
|
|
139
|
+
* `SET ROLE` to it, and it must read and write every framework and owned
|
|
140
|
+
* table. Every `durable` inspection view must belong to a separate
|
|
141
|
+
* view-owner role that the policies bind and that `role` is not a member
|
|
142
|
+
* of. The runtime refuses to start otherwise. Framework work that spans tenants, such as the relay,
|
|
143
|
+
* executors, and retention, keeps the connecting role, which the policies exempt.
|
|
144
|
+
*/
|
|
145
|
+
readonly rowLevelSecurity?: {
|
|
146
|
+
readonly role: string;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* The writer role of enforced adopted tables. A turn of an actor type that
|
|
150
|
+
* owns one runs as `role`, which the table's guard trigger admits and every
|
|
151
|
+
* other login is refused, so it needs read and write on every framework and
|
|
152
|
+
* owned table and must own none of them. This login must be able to `SET
|
|
153
|
+
* ROLE` to it. Set together with `rowLevelSecurity`, both must name the same
|
|
154
|
+
* role, because a turn takes one role. The runtime refuses to start an
|
|
155
|
+
* enforced table without it.
|
|
156
|
+
*/
|
|
157
|
+
readonly adoption?: {
|
|
158
|
+
readonly role: string;
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* The fleet views this runtime maintains and serves. They need Postgres with
|
|
162
|
+
* `wal_level=logical`, a login with `REPLICATION`, and `durable fleet setup`;
|
|
163
|
+
* startup refuses otherwise, and PGlite refuses any view. One runner at a
|
|
164
|
+
* time maintains them, off the turn path.
|
|
165
|
+
*/
|
|
166
|
+
readonly fleet?: ReadonlyArray<AnyFleetView>;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Builds the runtime: migrates and checks the database, registers every actor,
|
|
170
|
+
* effect, query, and subscription layer, and starts the relay and background
|
|
171
|
+
* sweeps. The returned layer provides `RuntimeControl`, and fails to build when
|
|
172
|
+
* the schema or declared payloads are incompatible.
|
|
173
|
+
*
|
|
174
|
+
* Constraints the wiring keeps:
|
|
175
|
+
* - Turns run through the drain gate, so a drain refuses new turns and
|
|
176
|
+
* interrupts the rest. The runtime scope, not the caller, owns an in-flight
|
|
177
|
+
* turn: interrupting a waiter never cancels it.
|
|
178
|
+
* - Commands are direct, so Cluster keeps no messages and the receipt is the
|
|
179
|
+
* only admission record; a restarted activation or lost runner drops the
|
|
180
|
+
* uncommitted attempt, the handle retries with the same command id, and the
|
|
181
|
+
* receipt replays anything that committed. Durable intents use the
|
|
182
|
+
* actor-shard outbox. Retries wait from the error's own `retryAfter`, bounded
|
|
183
|
+
* in total by the delivery timeout.
|
|
184
|
+
* - Intents are admitted by their sending turn, so internal delivery skips the
|
|
185
|
+
* external access and expiry checks: revocation stops new commands, not
|
|
186
|
+
* committed obligations. A draining runner admits no new external work. Only
|
|
187
|
+
* the relay presents a mint proof or delivers a subscription envelope.
|
|
188
|
+
* - A turn runs only in a resident activation. After a capacity rejection with
|
|
189
|
+
* none resident, the latest attempt was not admitted, though an earlier one
|
|
190
|
+
* may have committed.
|
|
191
|
+
* - Queries and feeds read committed rows on the caller's node without an
|
|
192
|
+
* activation, generation fence, receipt, or command id. State and events are
|
|
193
|
+
* read against one event head so they describe one moment; a replica answers
|
|
194
|
+
* only once it has replayed the caller's commit version, else the primary
|
|
195
|
+
* does. Types with owned tables or blobs read their state on the primary,
|
|
196
|
+
* one server per query. No `statement_timeout` bounds query reads;
|
|
197
|
+
* interrupting one past `commandTimeout` cancels its statement on the server.
|
|
198
|
+
* Access is rechecked after the handler, so a result is released only to a
|
|
199
|
+
* caller still allowed. A failed replay read is unavailability, not a defect.
|
|
200
|
+
* - Effect progress is fire-and-forget to the performing actor's connection
|
|
201
|
+
* entity: no retry, no acknowledgment, and a lost message is a lost frame.
|
|
202
|
+
* Each effect's last frame is awaited so its close never overtakes it.
|
|
203
|
+
* - Payload versions this runtime writes are recorded and heartbeat before a
|
|
204
|
+
* type takes any shard, refreshed one at a time with the time taken before
|
|
205
|
+
* the statement is sent, so the gate's window can only end early.
|
|
206
|
+
* - Content grants are bound to the database's deployment id. The content
|
|
207
|
+
* sweep waits out the longest turn that may attach content across every
|
|
208
|
+
* runner, and each tenant is swept at most once an hour.
|
|
209
|
+
* - Exactly one runner of the deployment runs the telemetry sampler; runtimes
|
|
210
|
+
* sharing one Sharding in a process share its one sampler.
|
|
211
|
+
* - Readiness on PGlite always answers from the layer's own lifetime, since a
|
|
212
|
+
* single connection held by a turn would make a probe report unready; on
|
|
213
|
+
* Postgres the database answers at most once a second.
|
|
214
|
+
* - PGlite keeps runner bookkeeping in memory because SqlRunnerStorage would
|
|
215
|
+
* reserve its single connection for the layer's lifetime. Postgres uses
|
|
216
|
+
* advisory locks, held by a live session, so no second runner can take a
|
|
217
|
+
* shard while its holder runs.
|
|
218
|
+
* - An unreachable database fails a read as `ActorUnavailable`, which callers
|
|
219
|
+
* retry like any delivery failure; it is not a defect.
|
|
220
|
+
*/
|
|
221
|
+
export declare const layer: (options?: Options) => Layer.Layer<Actors | ContentStore | DefectLog | InternalActors | OperatorRuntime | RuntimeControl | TelemetrySampler, import("effect/sql/Migrator").MigrationError | SqlError.SqlError, Crypto.Crypto | SqlClient.SqlClient>;
|
|
222
|
+
/** Database layers for `Actors.layer`: `postgres` for real deployments, `pglite` for embedded and test use. */
|
|
223
|
+
export declare const Database: {
|
|
224
|
+
/**
|
|
225
|
+
* A runner holds three primary pools, plus optional replica and coordination
|
|
226
|
+
* pools. Turns lease sessions from the turn pool, `maxConnections` (default
|
|
227
|
+
* 50): a command holds one session until its transaction ends, so a pool
|
|
228
|
+
* smaller than the commands in flight queues callers behind
|
|
229
|
+
* it. Queries read from the query pool, `queryConnections` (default 10),
|
|
230
|
+
* except those of types with owned tables or blobs. Command admission,
|
|
231
|
+
* receipt replays, the relay, migrations, and cluster storage use the
|
|
232
|
+
* off-turn pool, `offTurnConnections` (default 10), unless `coordination`
|
|
233
|
+
* moves Cluster storage and deployment locks to an independent unsharded
|
|
234
|
+
* primary. All runners must designate the same authority. Every pool opens
|
|
235
|
+
* connections only as load needs them, refuses checkouts past its
|
|
236
|
+
* connections plus a bounded waiter allowance, and hands its connections out
|
|
237
|
+
* first come, first served. Keep the sum across runners below the server's
|
|
238
|
+
* `max_connections`.
|
|
239
|
+
*
|
|
240
|
+
* `replica` is this runner's nearest streaming replica of the same primary.
|
|
241
|
+
* Queries read there once it has replayed the commit version their caller
|
|
242
|
+
* last saw, and read the primary when it is behind or fails. Its pool
|
|
243
|
+
* (`maxConnections` default 10) opens connections only as queries need them.
|
|
244
|
+
* Every pool requests server TCP keepalives at 5 seconds idle, 2 seconds
|
|
245
|
+
* between probes, and 3 probes. `startupParameters` overrides these defaults
|
|
246
|
+
* independently on the primary and replica configurations.
|
|
247
|
+
*
|
|
248
|
+
* Registers a `regclass` codec because the pinned driver lacks one and the
|
|
249
|
+
* migrator needs it on restart; remove once Effect #8309 lands.
|
|
250
|
+
*/
|
|
251
|
+
postgres: (options: Omit<PgClient.PgPoolConfig, "types"> & {
|
|
252
|
+
readonly offTurnConnections?: number;
|
|
253
|
+
readonly queryConnections?: number;
|
|
254
|
+
readonly neki?: boolean;
|
|
255
|
+
readonly replica?: Omit<PgClient.PgPoolConfig, "types"> | undefined;
|
|
256
|
+
/** An unsharded primary shared by every runner; owns coordination rows and Cluster and fleet locks. */
|
|
257
|
+
readonly coordination?: Omit<PgClient.PgPoolConfig, "types"> | undefined;
|
|
258
|
+
}) => Layer.Layer<PgClient.PgClient | SqlClient.SqlClient | TurnConnections, SqlError.SqlError, never>;
|
|
259
|
+
pglite: typeof pglite;
|
|
260
|
+
};
|