@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,41 @@
|
|
|
1
|
+
import { Effect, Fiber, Layer, Schema } from "effect";
|
|
2
|
+
import { SqlClient } from "effect/sql";
|
|
3
|
+
import { ActorTest } from "../actor-test.ts";
|
|
4
|
+
import type { ConformanceCase, ConformanceSuite } from "../conformance.ts";
|
|
5
|
+
export declare const reductions: {
|
|
6
|
+
count: number;
|
|
7
|
+
};
|
|
8
|
+
/** Adds to the count; merged calls combine by summing. */
|
|
9
|
+
export declare const Bump: import("../../index.ts").Reducer<"Bump", {
|
|
10
|
+
readonly log: Schema.withDecodingDefault<Schema.$Array<Schema.String>, never>;
|
|
11
|
+
readonly count: Schema.withDecodingDefault<Schema.Int, never>;
|
|
12
|
+
}, Schema.Int, Schema.Void, Schema.Never>;
|
|
13
|
+
/** Like `Bump`, but models a reducer bug: an input above 10 throws. */
|
|
14
|
+
export declare const Fragile: import("../../index.ts").Reducer<"Fragile", {
|
|
15
|
+
readonly log: Schema.withDecodingDefault<Schema.$Array<Schema.String>, never>;
|
|
16
|
+
readonly count: Schema.withDecodingDefault<Schema.Int, never>;
|
|
17
|
+
}, Schema.Int, Schema.Void, Schema.Never>;
|
|
18
|
+
export declare const batchesLayer: Layer.Layer<never, never, import("../index.ts").InternalActors | SqlClient.SqlClient>;
|
|
19
|
+
/**
|
|
20
|
+
* Sends each call only once the previous one is in the actor's mailbox, so
|
|
21
|
+
* the calls are delivered in the order given.
|
|
22
|
+
*/
|
|
23
|
+
export declare const enqueue: <A, R>(calls: readonly Effect.Effect<A, never, R>[]) => Effect.Effect<Fiber.Fiber<A, never>[], never, R | ActorTest>;
|
|
24
|
+
/**
|
|
25
|
+
* Holds the actor's next turn before its commit, so every call enqueued
|
|
26
|
+
* meanwhile is already waiting when the actor takes its next batch.
|
|
27
|
+
*/
|
|
28
|
+
export declare const holding: <A, E, R>(first: Effect.Effect<A, E, R>) => Effect.Effect<{
|
|
29
|
+
fiber: Fiber.Fiber<A, E>;
|
|
30
|
+
release: Effect.Effect<void, never, never>;
|
|
31
|
+
}, never, R | ActorTest>;
|
|
32
|
+
/** The transaction that committed each receipt of `ref`, by command id. */
|
|
33
|
+
export declare const transactions: (ref: {
|
|
34
|
+
readonly tenant: string;
|
|
35
|
+
readonly actor: string;
|
|
36
|
+
readonly id: string;
|
|
37
|
+
}) => Effect.Effect<Map<string, string>, never, SqlClient.SqlClient>;
|
|
38
|
+
/** Turn-batch cases: waiting commands share one transaction in delivery order with one receipt each, respect the batch cap, and isolate declared failures and defects. */
|
|
39
|
+
export declare const batchesConformance: ReadonlyArray<ConformanceCase>;
|
|
40
|
+
/** The batch ledger actor. */
|
|
41
|
+
export declare const batchesSuite: ConformanceSuite;
|
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import { pgTable, text } from "drizzle-orm/pg-core";
|
|
2
|
+
import { Cause, Effect, Exit, Fiber, Layer, Result, Schema } from "effect";
|
|
3
|
+
import { SqlClient } from "effect/sql";
|
|
4
|
+
import { retryPoolRefusal } from "../../runtime/database/bounded.js";
|
|
5
|
+
import { Actor, Actors, Intent } from "../../index.js";
|
|
6
|
+
import { BATCH_CAP, MERGE_CAP } from "../../runtime/entity/mailbox.js";
|
|
7
|
+
import { ActorTest } from "../actor-test.js";
|
|
8
|
+
const marks = Actor.table(pgTable("batch_marks", { id: text("id").primaryKey() }));
|
|
9
|
+
class Refused extends Schema.TaggedError()("Refused", { label: Schema.String }) {
|
|
10
|
+
}
|
|
11
|
+
const Entry = Schema.Struct({ log: Schema.Array(Schema.String), marks: Schema.Finite });
|
|
12
|
+
const Append = Actor.command("Append", { payload: Schema.String, success: Entry });
|
|
13
|
+
const Refuse = Actor.command("Refuse", { payload: Schema.String, error: Refused });
|
|
14
|
+
const Explode = Actor.command("Explode", { payload: Schema.String });
|
|
15
|
+
const Noted = Actor.command("Noted", {});
|
|
16
|
+
/**
|
|
17
|
+
* Each handler writes state and an owned row, so a batch of its commands
|
|
18
|
+
* takes a savepoint per handler and threads state from one to the next.
|
|
19
|
+
*/
|
|
20
|
+
const LedgerState = Actor.state({
|
|
21
|
+
log: Schema.Array(Schema.String).pipe(Schema.withDecodingDefault(Effect.succeed([]))),
|
|
22
|
+
count: Schema.Int.pipe(Schema.withDecodingDefault(Effect.succeed(0))),
|
|
23
|
+
});
|
|
24
|
+
export const reductions = { count: 0 };
|
|
25
|
+
/** Adds to the count; merged calls combine by summing. */
|
|
26
|
+
export const Bump = Actor.reducer("Bump", {
|
|
27
|
+
state: LedgerState,
|
|
28
|
+
payload: Schema.Int,
|
|
29
|
+
reduce: (state, amount) => {
|
|
30
|
+
reductions.count += 1;
|
|
31
|
+
return Result.succeed({ ...state, count: state.count + amount });
|
|
32
|
+
},
|
|
33
|
+
batch: { combine: (first, second) => first + second },
|
|
34
|
+
});
|
|
35
|
+
/** Like `Bump`, but models a reducer bug: an input above 10 throws. */
|
|
36
|
+
export const Fragile = Actor.reducer("Fragile", {
|
|
37
|
+
state: LedgerState,
|
|
38
|
+
payload: Schema.Int,
|
|
39
|
+
reduce: (state, amount) => {
|
|
40
|
+
if (amount > 10)
|
|
41
|
+
throw new Error("Fragile reducer bug");
|
|
42
|
+
return Result.succeed({ ...state, count: state.count + amount });
|
|
43
|
+
},
|
|
44
|
+
batch: { combine: (first, second) => first + second },
|
|
45
|
+
});
|
|
46
|
+
const Ledger = Actor.make("BatchLedger", {
|
|
47
|
+
key: Schema.String,
|
|
48
|
+
state: LedgerState,
|
|
49
|
+
tables: [marks],
|
|
50
|
+
api: { Append, Refuse, Explode, Bump, Fragile },
|
|
51
|
+
internal: { Noted },
|
|
52
|
+
policy: { mailboxCapacity: 2048 },
|
|
53
|
+
});
|
|
54
|
+
const runs = new Map();
|
|
55
|
+
const ran = (label) => runs.set(label, (runs.get(label) ?? 0) + 1);
|
|
56
|
+
export const batchesLayer = Layer.unwrap(Effect.gen(function* () {
|
|
57
|
+
const sql = yield* SqlClient.SqlClient;
|
|
58
|
+
yield* retryPoolRefusal(sql.unsafe(`CREATE TABLE IF NOT EXISTS batch_marks (
|
|
59
|
+
routing_key bigint, tenant_id text, actor_id text, id text,
|
|
60
|
+
PRIMARY KEY (routing_key, tenant_id, actor_id, id))`));
|
|
61
|
+
return Ledger.toLayer(Effect.succeed({
|
|
62
|
+
Append: Effect.fnUntraced(function* (label) {
|
|
63
|
+
ran(label);
|
|
64
|
+
const turn = yield* Ledger.Turn;
|
|
65
|
+
const log = [...turn.state.log, label];
|
|
66
|
+
yield* turn.state.set({ log });
|
|
67
|
+
yield* turn.rows(marks).insert({ id: label });
|
|
68
|
+
return { log, marks: yield* turn.rows(marks).count() };
|
|
69
|
+
}),
|
|
70
|
+
Refuse: Effect.fnUntraced(function* (label) {
|
|
71
|
+
ran(label);
|
|
72
|
+
const turn = yield* Ledger.Turn;
|
|
73
|
+
yield* turn.state.set({ log: [...turn.state.log, label] });
|
|
74
|
+
yield* turn.rows(marks).insert({ id: label });
|
|
75
|
+
const self = yield* Ledger.intents(turn.id);
|
|
76
|
+
yield* self.Noted().pipe(Intent.after("1 hour"));
|
|
77
|
+
return yield* Refused.make({ label });
|
|
78
|
+
}),
|
|
79
|
+
Explode: Effect.fnUntraced(function* (label) {
|
|
80
|
+
ran(label);
|
|
81
|
+
const turn = yield* Ledger.Turn;
|
|
82
|
+
yield* turn.state.set({ log: [...turn.state.log, label] });
|
|
83
|
+
return yield* Effect.die(new Error("Batch member defect"));
|
|
84
|
+
}),
|
|
85
|
+
Noted: () => Effect.void,
|
|
86
|
+
}));
|
|
87
|
+
}).pipe(Effect.orDie));
|
|
88
|
+
/**
|
|
89
|
+
* Sends each call only once the previous one is in the actor's mailbox, so
|
|
90
|
+
* the calls are delivered in the order given.
|
|
91
|
+
*/
|
|
92
|
+
export const enqueue = Effect.fnUntraced(function* (calls) {
|
|
93
|
+
const test = yield* ActorTest;
|
|
94
|
+
const fibers = [];
|
|
95
|
+
for (const call of calls) {
|
|
96
|
+
const queued = yield* test.pauseNext("queued");
|
|
97
|
+
fibers.push(yield* Effect.forkChild(call));
|
|
98
|
+
yield* queued.reached;
|
|
99
|
+
yield* queued.release;
|
|
100
|
+
yield* Effect.yieldNow;
|
|
101
|
+
}
|
|
102
|
+
return fibers;
|
|
103
|
+
});
|
|
104
|
+
/**
|
|
105
|
+
* Holds the actor's next turn before its commit, so every call enqueued
|
|
106
|
+
* meanwhile is already waiting when the actor takes its next batch.
|
|
107
|
+
*/
|
|
108
|
+
export const holding = Effect.fnUntraced(function* (first) {
|
|
109
|
+
const test = yield* ActorTest;
|
|
110
|
+
const held = yield* test.pauseNext("beforeCommit");
|
|
111
|
+
const fiber = yield* Effect.forkChild(first);
|
|
112
|
+
yield* held.reached;
|
|
113
|
+
return { fiber, release: held.release };
|
|
114
|
+
});
|
|
115
|
+
/** The transaction that committed each receipt of `ref`, by command id. */
|
|
116
|
+
export const transactions = Effect.fnUntraced(function* (ref) {
|
|
117
|
+
const sql = yield* SqlClient.SqlClient;
|
|
118
|
+
const rows = yield* sql `
|
|
119
|
+
SELECT command_id, xmin::text AS tx FROM actor_receipts
|
|
120
|
+
WHERE tenant_id = ${ref.tenant} AND actor_type = ${ref.actor} AND actor_id = ${ref.id}`;
|
|
121
|
+
return new Map(rows.map((row) => [row.command_id, row.tx]));
|
|
122
|
+
}, Effect.orDie);
|
|
123
|
+
const mint = Effect.fnUntraced(function* (count) {
|
|
124
|
+
const actors = yield* Actors;
|
|
125
|
+
return yield* Effect.forEach(Array.from({ length: count }), () => actors.mintCommandId);
|
|
126
|
+
});
|
|
127
|
+
/** Turn-batch cases: waiting commands share one transaction in delivery order with one receipt each, respect the batch cap, and isolate declared failures and defects. */
|
|
128
|
+
export const batchesConformance = [
|
|
129
|
+
{
|
|
130
|
+
name: "turn batch: waiting commands share one transaction in delivery order, each with its own receipt, and none replies before the commit",
|
|
131
|
+
requiresIndependentConnections: true,
|
|
132
|
+
timeoutMs: 60_000,
|
|
133
|
+
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
134
|
+
const test = yield* ActorTest;
|
|
135
|
+
const ledger = yield* Ledger.get("order");
|
|
136
|
+
const [lone, ...ids] = yield* mint(5);
|
|
137
|
+
const labels = ["order-a", "order-b", "order-c", "order-d"];
|
|
138
|
+
const first = yield* holding(ledger.Append("order-first").pipe(Actor.commandId(lone)));
|
|
139
|
+
const waiting = yield* enqueue(labels.map((label, index) => ledger.Append(label).pipe(Actor.commandId(ids[index]), Effect.orDie)));
|
|
140
|
+
const commit = yield* test.pauseNext("beforeCommit");
|
|
141
|
+
yield* first.release;
|
|
142
|
+
expect(yield* Fiber.join(first.fiber)).toEqual({ log: ["order-first"], marks: 1 });
|
|
143
|
+
yield* commit.reached;
|
|
144
|
+
expect(waiting.map((fiber) => fiber.pollUnsafe())).toEqual(labels.map(() => undefined));
|
|
145
|
+
yield* commit.release;
|
|
146
|
+
const replies = yield* Effect.forEach(waiting, Fiber.join);
|
|
147
|
+
expect(replies).toEqual(labels.map((_, index) => ({
|
|
148
|
+
log: ["order-first", ...labels.slice(0, index + 1)],
|
|
149
|
+
marks: index + 2,
|
|
150
|
+
})));
|
|
151
|
+
const committed = yield* transactions(ledger.ref);
|
|
152
|
+
expect(new Set(ids.map((id) => committed.get(id))).size).toBe(1);
|
|
153
|
+
expect(committed.get(ids[0])).not.toBe(committed.get(lone));
|
|
154
|
+
expect(yield* test.inspect(ledger.ref)).toMatchObject({
|
|
155
|
+
state: { log: ["order-first", ...labels] },
|
|
156
|
+
receipts: 5,
|
|
157
|
+
});
|
|
158
|
+
})),
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: "turn batch: no batch exceeds the cap of waiting commands",
|
|
162
|
+
requiresIndependentConnections: true,
|
|
163
|
+
timeoutMs: 60_000,
|
|
164
|
+
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
165
|
+
const ledger = yield* Ledger.get("cap");
|
|
166
|
+
const total = BATCH_CAP + 8;
|
|
167
|
+
const [lone, ...ids] = yield* mint(total + 1);
|
|
168
|
+
const first = yield* holding(ledger.Append("cap-first").pipe(Actor.commandId(lone)));
|
|
169
|
+
const waiting = yield* enqueue(ids.map((id, index) => ledger.Append(`cap-${index}`).pipe(Actor.commandId(id), Effect.orDie)));
|
|
170
|
+
yield* first.release;
|
|
171
|
+
yield* Fiber.join(first.fiber);
|
|
172
|
+
const replies = yield* Effect.forEach(waiting, Fiber.join);
|
|
173
|
+
expect(replies.at(-1)).toMatchObject({ marks: total + 1 });
|
|
174
|
+
const committed = yield* transactions(ledger.ref);
|
|
175
|
+
const sizes = new Map();
|
|
176
|
+
for (const id of ids) {
|
|
177
|
+
const tx = committed.get(id);
|
|
178
|
+
sizes.set(tx, (sizes.get(tx) ?? 0) + 1);
|
|
179
|
+
}
|
|
180
|
+
expect([...sizes.values()].sort((a, b) => b - a)).toEqual([BATCH_CAP, 8]);
|
|
181
|
+
})),
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
name: "turn batch: a declared failure discards only its own state, rows, and intents, and commits its failure receipt",
|
|
185
|
+
requiresIndependentConnections: true,
|
|
186
|
+
timeoutMs: 60_000,
|
|
187
|
+
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
188
|
+
const test = yield* ActorTest;
|
|
189
|
+
const ledger = yield* Ledger.get("declared");
|
|
190
|
+
const [lone, before, refused, after] = yield* mint(4);
|
|
191
|
+
const first = yield* holding(ledger.Append("declared-first").pipe(Actor.commandId(lone)));
|
|
192
|
+
const [a, r, b] = yield* enqueue([
|
|
193
|
+
ledger.Append("declared-a").pipe(Actor.commandId(before), Effect.exit),
|
|
194
|
+
ledger.Refuse("declared-r").pipe(Actor.commandId(refused), Effect.exit),
|
|
195
|
+
ledger.Append("declared-b").pipe(Actor.commandId(after), Effect.exit),
|
|
196
|
+
]);
|
|
197
|
+
yield* first.release;
|
|
198
|
+
yield* Fiber.join(first.fiber);
|
|
199
|
+
expect(yield* Fiber.join(a)).toEqual(Exit.succeed({ log: ["declared-first", "declared-a"], marks: 2 }));
|
|
200
|
+
expect(yield* Fiber.join(r)).toEqual(Exit.fail(Refused.make({ label: "declared-r" })));
|
|
201
|
+
expect(yield* Fiber.join(b)).toEqual(Exit.succeed({ log: ["declared-first", "declared-a", "declared-b"], marks: 3 }));
|
|
202
|
+
const committed = yield* transactions(ledger.ref);
|
|
203
|
+
expect(new Set([before, refused, after].map((id) => committed.get(id))).size).toBe(1);
|
|
204
|
+
expect(yield* test.inspect(ledger.ref)).toMatchObject({
|
|
205
|
+
state: { log: ["declared-first", "declared-a", "declared-b"] },
|
|
206
|
+
receipts: 4,
|
|
207
|
+
outbox: 0,
|
|
208
|
+
});
|
|
209
|
+
expect(yield* ledger.Refuse("declared-r").pipe(Actor.commandId(refused), Effect.flip)).toEqual(Refused.make({ label: "declared-r" }));
|
|
210
|
+
expect(runs.get("declared-r")).toBe(1);
|
|
211
|
+
})),
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: "turn batch: a defect rolls the batch back, then its commands run one per transaction",
|
|
215
|
+
requiresIndependentConnections: true,
|
|
216
|
+
timeoutMs: 60_000,
|
|
217
|
+
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
218
|
+
const test = yield* ActorTest;
|
|
219
|
+
const ledger = yield* Ledger.get("defect");
|
|
220
|
+
const [lone, before, exploded, after] = yield* mint(4);
|
|
221
|
+
const first = yield* holding(ledger.Append("defect-first").pipe(Actor.commandId(lone)));
|
|
222
|
+
const [a, x, b] = yield* enqueue([
|
|
223
|
+
ledger.Append("defect-a").pipe(Actor.commandId(before), Effect.exit),
|
|
224
|
+
ledger.Explode("defect-x").pipe(Actor.commandId(exploded), Effect.exit),
|
|
225
|
+
ledger.Append("defect-b").pipe(Actor.commandId(after), Effect.exit),
|
|
226
|
+
]);
|
|
227
|
+
yield* first.release;
|
|
228
|
+
yield* Fiber.join(first.fiber);
|
|
229
|
+
expect(yield* Fiber.join(a)).toEqual(Exit.succeed({ log: ["defect-first", "defect-a"], marks: 2 }));
|
|
230
|
+
const failed = yield* Fiber.join(x);
|
|
231
|
+
expect(Exit.isFailure(failed) && Cause.hasDies(failed.cause)).toBe(true);
|
|
232
|
+
expect(yield* Fiber.join(b)).toEqual(Exit.succeed({ log: ["defect-first", "defect-a", "defect-b"], marks: 3 }));
|
|
233
|
+
expect(["defect-a", "defect-x", "defect-b"].map((label) => runs.get(label))).toEqual([
|
|
234
|
+
2, 2, 1,
|
|
235
|
+
]);
|
|
236
|
+
const committed = yield* transactions(ledger.ref);
|
|
237
|
+
expect(committed.has(exploded)).toBe(false);
|
|
238
|
+
expect(committed.get(before)).not.toBe(committed.get(after));
|
|
239
|
+
expect(yield* test.inspect(ledger.ref)).toMatchObject({
|
|
240
|
+
state: { log: ["defect-first", "defect-a", "defect-b"] },
|
|
241
|
+
receipts: 3,
|
|
242
|
+
});
|
|
243
|
+
})),
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
name: "turn batch: a crash before the shared commit reruns each command alone, and a crash after it replays each receipt",
|
|
247
|
+
requiresIndependentConnections: true,
|
|
248
|
+
timeoutMs: 60_000,
|
|
249
|
+
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
250
|
+
const test = yield* ActorTest;
|
|
251
|
+
const ledger = yield* Ledger.get("crash");
|
|
252
|
+
const [lone, ...ids] = yield* mint(7);
|
|
253
|
+
const before = ["crash-a", "crash-b", "crash-c"];
|
|
254
|
+
const after = ["crash-d", "crash-e", "crash-f"];
|
|
255
|
+
const first = yield* holding(ledger.Append("crash-first").pipe(Actor.commandId(lone)));
|
|
256
|
+
const early = yield* enqueue(before.map((label, index) => ledger.Append(label).pipe(Actor.commandId(ids[index]), Effect.orDie)));
|
|
257
|
+
yield* test.crashNext("beforeCommit");
|
|
258
|
+
yield* first.release;
|
|
259
|
+
yield* Fiber.join(first.fiber);
|
|
260
|
+
yield* Effect.forEach(early, Fiber.join);
|
|
261
|
+
expect(before.map((label) => runs.get(label))).toEqual([2, 1, 1]);
|
|
262
|
+
let committed = yield* transactions(ledger.ref);
|
|
263
|
+
expect(new Set(ids.slice(0, 3).map((id) => committed.get(id))).size).toBe(3);
|
|
264
|
+
const second = yield* holding(ledger.Append("crash-second"));
|
|
265
|
+
const late = yield* enqueue(after.map((label, index) => ledger.Append(label).pipe(Actor.commandId(ids[index + 3]), Effect.orDie)));
|
|
266
|
+
const shared = yield* test.pauseNext("beforeCommit");
|
|
267
|
+
yield* second.release;
|
|
268
|
+
yield* Fiber.join(second.fiber);
|
|
269
|
+
yield* shared.reached;
|
|
270
|
+
yield* test.crashNext("afterCommit");
|
|
271
|
+
yield* shared.release;
|
|
272
|
+
const replies = yield* Effect.forEach(late, Fiber.join);
|
|
273
|
+
expect(replies.at(-1)).toMatchObject({ marks: 8 });
|
|
274
|
+
expect(after.map((label) => runs.get(label))).toEqual([1, 1, 1]);
|
|
275
|
+
committed = yield* transactions(ledger.ref);
|
|
276
|
+
expect(new Set(ids.slice(3).map((id) => committed.get(id))).size).toBe(1);
|
|
277
|
+
expect(yield* test.inspect(ledger.ref)).toMatchObject({ receipts: 8 });
|
|
278
|
+
})),
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
name: "turn batch: a retry waiting behind its original resolves through the original's receipt",
|
|
282
|
+
requiresIndependentConnections: true,
|
|
283
|
+
timeoutMs: 60_000,
|
|
284
|
+
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
285
|
+
const test = yield* ActorTest;
|
|
286
|
+
const ledger = yield* Ledger.get("duplicate");
|
|
287
|
+
const [id] = yield* mint(1);
|
|
288
|
+
const first = yield* holding(ledger.Append("duplicate-first"));
|
|
289
|
+
const call = ledger.Append("duplicate-x").pipe(Actor.commandId(id), Effect.orDie);
|
|
290
|
+
const [original, retry] = yield* enqueue([call, call]);
|
|
291
|
+
yield* first.release;
|
|
292
|
+
yield* Fiber.join(first.fiber);
|
|
293
|
+
const reply = { log: ["duplicate-first", "duplicate-x"], marks: 2 };
|
|
294
|
+
expect(yield* Fiber.join(original)).toEqual(reply);
|
|
295
|
+
expect(yield* Fiber.join(retry)).toEqual(reply);
|
|
296
|
+
expect(runs.get("duplicate-x")).toBe(1);
|
|
297
|
+
expect(yield* test.inspect(ledger.ref)).toMatchObject({ receipts: 2 });
|
|
298
|
+
})),
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
name: "merged turn: commutative calls already waiting commit in one turn with one receipt per command id",
|
|
302
|
+
requiresIndependentConnections: true,
|
|
303
|
+
timeoutMs: 60_000,
|
|
304
|
+
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
305
|
+
const test = yield* ActorTest;
|
|
306
|
+
const ledger = yield* Ledger.get("merged");
|
|
307
|
+
const ids = yield* mint(5);
|
|
308
|
+
const first = yield* holding(ledger.Append("merged-first"));
|
|
309
|
+
const waiting = yield* enqueue(ids.map((id, index) => ledger.Bump(index + 1).pipe(Actor.commandId(id), Effect.orDie)));
|
|
310
|
+
const before = reductions.count;
|
|
311
|
+
yield* first.release;
|
|
312
|
+
yield* Fiber.join(first.fiber);
|
|
313
|
+
expect(yield* Effect.forEach(waiting, Fiber.join)).toEqual(ids.map(() => undefined));
|
|
314
|
+
expect(reductions.count - before).toBe(1);
|
|
315
|
+
const committed = yield* transactions(ledger.ref);
|
|
316
|
+
expect(ids.every((id) => committed.has(id))).toBe(true);
|
|
317
|
+
expect(new Set(ids.map((id) => committed.get(id))).size).toBe(1);
|
|
318
|
+
expect(yield* test.inspect(ledger.ref)).toMatchObject({
|
|
319
|
+
state: { log: ["merged-first"], count: 15 },
|
|
320
|
+
receipts: 6,
|
|
321
|
+
});
|
|
322
|
+
expect(yield* ledger.Bump(3).pipe(Actor.commandId(ids[2]))).toBe(undefined);
|
|
323
|
+
expect(reductions.count - before).toBe(1);
|
|
324
|
+
expect((yield* test.inspect(ledger.ref)).receipts).toBe(6);
|
|
325
|
+
})),
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
name: "merged turn: never combines more than 1,024 calls",
|
|
329
|
+
requiresIndependentConnections: true,
|
|
330
|
+
timeoutMs: 120_000,
|
|
331
|
+
run: ({ expect, environment }) => Effect.runPromise(Effect.gen(function* () {
|
|
332
|
+
yield* environment.stop;
|
|
333
|
+
const runtime = environment.build({ admission: { concurrency: 2048 } });
|
|
334
|
+
yield* Effect.promise(() => runtime
|
|
335
|
+
.runPromise(Effect.scoped(Effect.gen(function* () {
|
|
336
|
+
const ledger = yield* Ledger.get("merge-cap");
|
|
337
|
+
const ids = yield* mint(MERGE_CAP + 6);
|
|
338
|
+
const first = yield* holding(ledger.Append("merge-cap-first"));
|
|
339
|
+
const waiting = yield* enqueue(ids.map((id) => ledger.Bump(1).pipe(Actor.commandId(id), Effect.orDie)));
|
|
340
|
+
const before = reductions.count;
|
|
341
|
+
yield* first.release;
|
|
342
|
+
yield* Fiber.join(first.fiber);
|
|
343
|
+
yield* Effect.forEach(waiting, Fiber.join);
|
|
344
|
+
expect(reductions.count - before).toBe(2);
|
|
345
|
+
const committed = yield* transactions(ledger.ref);
|
|
346
|
+
expect(new Set(ids.map((id) => committed.get(id))).size).toBe(1);
|
|
347
|
+
const [state] = yield* SqlClient.SqlClient.pipe(Effect.flatMap((sql) => sql `SELECT count(*)::integer AS receipts
|
|
348
|
+
FROM actor_receipts WHERE actor_type = 'BatchLedger' AND actor_id = ${ledger.ref.id}
|
|
349
|
+
AND command = 'Bump'`), Effect.orDie);
|
|
350
|
+
expect(state.receipts).toBe(MERGE_CAP + 6);
|
|
351
|
+
})))
|
|
352
|
+
.finally(() => runtime.dispose()));
|
|
353
|
+
}).pipe(Effect.ensuring(environment.restart))),
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
name: "merged turn: a failing merged turn commits none of its calls, and each then runs alone",
|
|
357
|
+
requiresIndependentConnections: true,
|
|
358
|
+
timeoutMs: 60_000,
|
|
359
|
+
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
360
|
+
const test = yield* ActorTest;
|
|
361
|
+
const ledger = yield* Ledger.get("merge-fails");
|
|
362
|
+
const [one, bad, two] = yield* mint(3);
|
|
363
|
+
const first = yield* holding(ledger.Append("merge-fails-first"));
|
|
364
|
+
const [a, x, b] = yield* enqueue([
|
|
365
|
+
ledger.Fragile(1).pipe(Actor.commandId(one), Effect.exit),
|
|
366
|
+
ledger.Fragile(13).pipe(Actor.commandId(bad), Effect.exit),
|
|
367
|
+
ledger.Fragile(2).pipe(Actor.commandId(two), Effect.exit),
|
|
368
|
+
]);
|
|
369
|
+
yield* first.release;
|
|
370
|
+
yield* Fiber.join(first.fiber);
|
|
371
|
+
expect(yield* Fiber.join(a)).toEqual(Exit.succeed(undefined));
|
|
372
|
+
const failed = yield* Fiber.join(x);
|
|
373
|
+
expect(Exit.isFailure(failed) && Cause.hasDies(failed.cause)).toBe(true);
|
|
374
|
+
expect(yield* Fiber.join(b)).toEqual(Exit.succeed(undefined));
|
|
375
|
+
const committed = yield* transactions(ledger.ref);
|
|
376
|
+
expect(committed.has(bad)).toBe(false);
|
|
377
|
+
expect(committed.get(one)).not.toBe(committed.get(two));
|
|
378
|
+
expect(yield* test.inspect(ledger.ref)).toMatchObject({
|
|
379
|
+
state: { count: 3 },
|
|
380
|
+
receipts: 3,
|
|
381
|
+
});
|
|
382
|
+
})),
|
|
383
|
+
},
|
|
384
|
+
];
|
|
385
|
+
/** The batch ledger actor. */
|
|
386
|
+
export const batchesSuite = {
|
|
387
|
+
layer: () => batchesLayer,
|
|
388
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Effect, Layer } from "effect";
|
|
2
|
+
import type { ConformanceCase, ConformanceSuite } from "../conformance.ts";
|
|
3
|
+
/** Blob names shared by two actor types, so only the scope keeps their entries apart. */
|
|
4
|
+
export declare const files: import("../../index.ts").Blob<"files">;
|
|
5
|
+
export interface BlobsFixture {
|
|
6
|
+
escaped: Effect.Effect<unknown>;
|
|
7
|
+
}
|
|
8
|
+
export declare const blobsFixture: () => BlobsFixture;
|
|
9
|
+
/** Handlers for the blob actors; `fixture` records handler runs so cases can tell a rerun from a replay. */
|
|
10
|
+
export declare const blobsLayer: (fixture: BlobsFixture) => Layer.Layer<never, never, import("../index.ts").InternalActors>;
|
|
11
|
+
/** Actor blob cases: tenant and actor scoping, append/compact/set round trips, and rollback with a declared failure. */
|
|
12
|
+
export declare const blobsConformance: ReadonlyArray<ConformanceCase<BlobsFixture>>;
|
|
13
|
+
/** The actor blob actors. */
|
|
14
|
+
export declare const blobsSuite: ConformanceSuite<BlobsFixture>;
|