@rivetkit/engine 1.0.0 → 2.2.1-pr.4600.b74ff3b
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/CLAUDE.md +38 -0
- package/artifacts/config-schema.json +1140 -0
- package/artifacts/errors/actor.kv_storage_quota_exceeded.json +5 -0
- package/artifacts/errors/actor.no_runner_config_configured.json +5 -0
- package/artifacts/errors/guard.actor_runner_failed.json +5 -0
- package/artifacts/errors/guard.invalid_request.json +5 -0
- package/artifacts/errors/guard.invalid_request_body.json +5 -0
- package/artifacts/errors/guard.invalid_response_body.json +5 -0
- package/artifacts/errors/guard.missing_query_parameter.json +5 -0
- package/artifacts/errors/guard.query_ambiguous_runner_configs.json +5 -0
- package/artifacts/errors/guard.query_duplicate_param.json +5 -0
- package/artifacts/errors/guard.query_empty_actor_name.json +5 -0
- package/artifacts/errors/guard.query_get_disallowed_params.json +5 -0
- package/artifacts/errors/guard.query_invalid_base64_input.json +5 -0
- package/artifacts/errors/guard.query_invalid_cbor_input.json +5 -0
- package/artifacts/errors/guard.query_invalid_params.json +5 -0
- package/artifacts/errors/guard.query_invalid_percent_encoding.json +5 -0
- package/artifacts/errors/guard.query_missing_runner_name.json +5 -0
- package/artifacts/errors/guard.query_no_runner_configs.json +5 -0
- package/artifacts/errors/guard.query_param_missing_equals.json +5 -0
- package/artifacts/errors/guard.query_path_token_syntax.json +5 -0
- package/artifacts/errors/guard.query_unknown_param.json +5 -0
- package/artifacts/errors/guard.request_body_too_large.json +5 -0
- package/artifacts/errors/guard.response_body_too_large.json +5 -0
- package/artifacts/errors/serverless_runner_pool.failed_to_fetch_metadata.json +5 -0
- package/artifacts/errors/serverless_runner_pool.not_found.json +5 -0
- package/artifacts/errors/{api.rate_limited.json → test.api_rate_limited.json} +2 -2
- package/artifacts/errors/{namespace.invalid_name.json → test.namespace_invalid_name.json} +2 -2
- package/artifacts/errors/ws.going_away.json +5 -0
- package/artifacts/openapi.json +458 -6
- package/docker/builder-base/linux-gnu.Dockerfile +21 -0
- package/docker/builder-base/linux-musl.Dockerfile +53 -0
- package/docker/builder-base/osxcross.Dockerfile +42 -0
- package/docker/builder-base/windows-mingw.Dockerfile +41 -0
- package/docker/builder-base/windows-msvc.Dockerfile +25 -0
- package/docker/dev/docker-compose.yml +43 -18
- package/docker/dev/grafana/dashboards/api.json +1077 -1239
- package/docker/dev/grafana/dashboards/cache.json +911 -1074
- package/docker/dev/grafana/dashboards/epoxy.json +1606 -0
- package/docker/dev/grafana/dashboards/futures.json +242 -229
- package/docker/dev/grafana/dashboards/gasoline.json +2663 -2476
- package/docker/dev/grafana/dashboards/guard.json +1433 -1273
- package/docker/dev/grafana/dashboards/operation.json +871 -0
- package/docker/dev/grafana/dashboards/pegboard.json +1274 -0
- package/docker/dev/grafana/dashboards/tokio.json +930 -1004
- package/docker/dev/grafana/dashboards/traces.json +35 -13
- package/docker/dev/grafana/provisioning/datasources/datasources.yaml +8 -0
- package/docker/{dev-multinode/otel-collector-server → dev/otel-collector}/config.yaml +18 -13
- package/docker/dev/prometheus/prometheus.yml +4 -0
- package/docker/dev/rivet-engine/config.jsonc +9 -16
- package/docker/dev-host/docker-compose.yml +38 -16
- package/docker/dev-host/grafana/dashboards/api.json +1077 -1239
- package/docker/dev-host/grafana/dashboards/cache.json +911 -1074
- package/docker/dev-host/grafana/dashboards/epoxy.json +1606 -0
- package/docker/dev-host/grafana/dashboards/futures.json +242 -229
- package/docker/dev-host/grafana/dashboards/gasoline.json +2663 -2476
- package/docker/dev-host/grafana/dashboards/guard.json +1433 -1273
- package/docker/dev-host/grafana/dashboards/operation.json +871 -0
- package/docker/dev-host/grafana/dashboards/pegboard.json +1274 -0
- package/docker/dev-host/grafana/dashboards/tokio.json +930 -1004
- package/docker/dev-host/grafana/dashboards/traces.json +35 -13
- package/docker/dev-host/grafana/provisioning/datasources/datasources.yaml +8 -0
- package/docker/dev-host/{otel-collector-server → otel-collector}/config.yaml +18 -13
- package/docker/dev-host/prometheus/prometheus.yml +4 -0
- package/docker/dev-host/rivet-engine/config.jsonc +9 -16
- package/docker/dev-multidc/core/grafana/dashboards/api.json +1077 -1239
- package/docker/dev-multidc/core/grafana/dashboards/cache.json +911 -1074
- package/docker/dev-multidc/core/grafana/dashboards/epoxy.json +1606 -0
- package/docker/dev-multidc/core/grafana/dashboards/futures.json +242 -229
- package/docker/dev-multidc/core/grafana/dashboards/gasoline.json +2663 -2476
- package/docker/dev-multidc/core/grafana/dashboards/guard.json +1433 -1273
- package/docker/dev-multidc/core/grafana/dashboards/operation.json +871 -0
- package/docker/dev-multidc/core/grafana/dashboards/pegboard.json +1274 -0
- package/docker/dev-multidc/core/grafana/dashboards/tokio.json +930 -1004
- package/docker/dev-multidc/core/grafana/dashboards/traces.json +35 -13
- package/docker/dev-multidc/core/grafana/provisioning/datasources/datasources.yaml +8 -0
- package/docker/dev-multidc/core/prometheus/prometheus.yml +4 -0
- package/docker/dev-multidc/datacenters/dc-a/{otel-collector-server → otel-collector}/config.yaml +18 -13
- package/docker/dev-multidc/datacenters/dc-a/rivet-engine/config.jsonc +23 -22
- package/docker/{dev-multidc-multinode/datacenters/dc-b/otel-collector-server → dev-multidc/datacenters/dc-b/otel-collector}/config.yaml +18 -13
- package/docker/dev-multidc/datacenters/dc-b/rivet-engine/config.jsonc +23 -22
- package/docker/dev-multidc/datacenters/dc-c/{otel-collector-server → otel-collector}/config.yaml +18 -13
- package/docker/dev-multidc/datacenters/dc-c/rivet-engine/config.jsonc +23 -22
- package/docker/dev-multidc/docker-compose.yml +71 -64
- package/docker/dev-multidc-multinode/core/grafana/dashboards/api.json +1077 -1239
- package/docker/dev-multidc-multinode/core/grafana/dashboards/cache.json +911 -1074
- package/docker/dev-multidc-multinode/core/grafana/dashboards/epoxy.json +1606 -0
- package/docker/dev-multidc-multinode/core/grafana/dashboards/futures.json +242 -229
- package/docker/dev-multidc-multinode/core/grafana/dashboards/gasoline.json +2663 -2476
- package/docker/dev-multidc-multinode/core/grafana/dashboards/guard.json +1433 -1273
- package/docker/dev-multidc-multinode/core/grafana/dashboards/operation.json +871 -0
- package/docker/dev-multidc-multinode/core/grafana/dashboards/pegboard.json +1274 -0
- package/docker/dev-multidc-multinode/core/grafana/dashboards/tokio.json +930 -1004
- package/docker/dev-multidc-multinode/core/grafana/dashboards/traces.json +35 -13
- package/docker/dev-multidc-multinode/core/grafana/provisioning/datasources/datasources.yaml +8 -0
- package/docker/dev-multidc-multinode/core/prometheus/prometheus.yml +4 -0
- package/docker/dev-multidc-multinode/datacenters/dc-a/{otel-collector-server → otel-collector}/config.yaml +28 -13
- package/docker/dev-multidc-multinode/datacenters/dc-a/rivet-engine/0/config.jsonc +23 -22
- package/docker/dev-multidc-multinode/datacenters/dc-a/rivet-engine/1/config.jsonc +23 -22
- package/docker/dev-multidc-multinode/datacenters/dc-a/rivet-engine/2/config.jsonc +23 -22
- package/docker/{dev-multidc/datacenters/dc-b/otel-collector-server → dev-multidc-multinode/datacenters/dc-b/otel-collector}/config.yaml +28 -13
- package/docker/dev-multidc-multinode/datacenters/dc-b/rivet-engine/0/config.jsonc +23 -22
- package/docker/dev-multidc-multinode/datacenters/dc-b/rivet-engine/1/config.jsonc +23 -22
- package/docker/dev-multidc-multinode/datacenters/dc-b/rivet-engine/2/config.jsonc +23 -22
- package/docker/dev-multidc-multinode/datacenters/dc-c/{otel-collector-server → otel-collector}/config.yaml +28 -13
- package/docker/dev-multidc-multinode/datacenters/dc-c/rivet-engine/0/config.jsonc +23 -22
- package/docker/dev-multidc-multinode/datacenters/dc-c/rivet-engine/1/config.jsonc +23 -22
- package/docker/dev-multidc-multinode/datacenters/dc-c/rivet-engine/2/config.jsonc +23 -22
- package/docker/dev-multidc-multinode/docker-compose.yml +113 -88
- package/docker/dev-multinode/docker-compose.yml +57 -26
- package/docker/dev-multinode/grafana/dashboards/api.json +1077 -1239
- package/docker/dev-multinode/grafana/dashboards/cache.json +911 -1074
- package/docker/dev-multinode/grafana/dashboards/epoxy.json +1606 -0
- package/docker/dev-multinode/grafana/dashboards/futures.json +242 -229
- package/docker/dev-multinode/grafana/dashboards/gasoline.json +2663 -2476
- package/docker/dev-multinode/grafana/dashboards/guard.json +1433 -1273
- package/docker/dev-multinode/grafana/dashboards/operation.json +871 -0
- package/docker/dev-multinode/grafana/dashboards/pegboard.json +1274 -0
- package/docker/dev-multinode/grafana/dashboards/tokio.json +930 -1004
- package/docker/dev-multinode/grafana/dashboards/traces.json +35 -13
- package/docker/dev-multinode/grafana/provisioning/datasources/datasources.yaml +8 -0
- package/docker/{dev/otel-collector-server → dev-multinode/otel-collector}/config.yaml +28 -13
- package/docker/dev-multinode/prometheus/prometheus.yml +4 -0
- package/docker/dev-multinode/rivet-engine/0/config.jsonc +9 -16
- package/docker/dev-multinode/rivet-engine/1/config.jsonc +9 -16
- package/docker/dev-multinode/rivet-engine/2/config.jsonc +9 -16
- package/docker/engine/linux-aarch64.Dockerfile +9 -49
- package/docker/engine/linux-x86_64.Dockerfile +7 -57
- package/docker/engine/macos-aarch64.Dockerfile +8 -54
- package/docker/engine/macos-x86_64.Dockerfile +9 -55
- package/docker/engine/windows.Dockerfile +5 -53
- package/docker/template/grafana-dashboards/api.json +1077 -1239
- package/docker/template/grafana-dashboards/cache.json +911 -1074
- package/docker/template/grafana-dashboards/epoxy.json +1606 -0
- package/docker/template/grafana-dashboards/futures.json +242 -229
- package/docker/template/grafana-dashboards/gasoline.json +2663 -2476
- package/docker/template/grafana-dashboards/guard.json +1433 -1273
- package/docker/template/grafana-dashboards/operation.json +871 -0
- package/docker/template/grafana-dashboards/pegboard.json +1274 -0
- package/docker/template/grafana-dashboards/tokio.json +930 -1004
- package/docker/template/grafana-dashboards/traces.json +35 -13
- package/docker/template/node_modules/.bin/js-yaml +4 -4
- package/docker/template/node_modules/.bin/tsc +4 -4
- package/docker/template/node_modules/.bin/tsserver +4 -4
- package/docker/template/node_modules/.bin/tsx +4 -4
- package/docker/template/src/docker-compose.ts +42 -29
- package/docker/template/src/main.ts +4 -4
- package/docker/template/src/services/core/grafana.ts +14 -1
- package/docker/template/src/services/core/prometheus.ts +20 -0
- package/docker/template/src/services/edge/{otel-collector-server.ts → otel-collector.ts} +55 -24
- package/docker/template/src/services/edge/rivet-engine.ts +4 -16
- package/docker/template/src/services/edge/runner.ts +2 -3
- package/docker/universal/Dockerfile +5 -3
- package/package.json +2 -5
- package/packages/api-builder/src/global_context.rs +1 -1
- package/packages/api-builder/src/metrics.rs +28 -24
- package/packages/api-builder/src/middleware.rs +30 -48
- package/packages/api-builder/src/router.rs +13 -1
- package/packages/api-peer/Cargo.toml +7 -9
- package/packages/api-peer/src/actors/delete.rs +56 -57
- package/packages/api-peer/src/actors/get_or_create.rs +139 -0
- package/packages/api-peer/src/actors/kv_get.rs +40 -28
- package/packages/api-peer/src/actors/list.rs +31 -14
- package/packages/api-peer/src/actors/list_names.rs +6 -6
- package/packages/api-peer/src/actors/mod.rs +3 -0
- package/packages/api-peer/src/actors/reschedule.rs +55 -0
- package/packages/api-peer/src/actors/sleep.rs +55 -0
- package/packages/api-peer/src/envoys.rs +57 -0
- package/packages/api-peer/src/internal.rs +441 -24
- package/packages/api-peer/src/lib.rs +2 -1
- package/packages/api-peer/src/namespaces.rs +24 -9
- package/packages/api-peer/src/router.rs +31 -7
- package/packages/api-peer/src/runner_configs.rs +66 -19
- package/packages/api-peer/src/runners.rs +30 -32
- package/packages/api-public/Cargo.toml +2 -0
- package/packages/api-public/src/actors/create.rs +8 -17
- package/packages/api-public/src/actors/delete.rs +11 -35
- package/packages/api-public/src/actors/get_or_create.rs +23 -95
- package/packages/api-public/src/actors/kv_get.rs +12 -29
- package/packages/api-public/src/actors/list.rs +56 -78
- package/packages/api-public/src/actors/list_names.rs +15 -14
- package/packages/api-public/src/actors/mod.rs +2 -0
- package/packages/api-public/src/actors/reschedule.rs +65 -0
- package/packages/api-public/src/actors/sleep.rs +64 -0
- package/packages/api-public/src/actors/utils.rs +12 -60
- package/packages/api-public/src/ctx.rs +14 -6
- package/packages/api-public/src/datacenters.rs +5 -5
- package/packages/api-public/src/envoys.rs +57 -0
- package/packages/api-public/src/errors.rs +0 -7
- package/packages/api-public/src/health.rs +51 -44
- package/packages/api-public/src/lib.rs +2 -1
- package/packages/api-public/src/metadata.rs +44 -14
- package/packages/api-public/src/namespaces.rs +11 -11
- package/packages/api-public/src/router.rs +22 -5
- package/packages/api-public/src/runner_configs/delete.rs +13 -10
- package/packages/api-public/src/runner_configs/list.rs +5 -2
- package/packages/api-public/src/runner_configs/refresh_metadata.rs +1 -1
- package/packages/api-public/src/runner_configs/serverless_health_check.rs +2 -2
- package/packages/api-public/src/runner_configs/upsert.rs +12 -9
- package/packages/api-public/src/runner_configs/utils.rs +35 -175
- package/packages/api-public/src/runners.rs +17 -45
- package/packages/{dump-openapi → api-public-openapi-gen}/Cargo.toml +1 -1
- package/packages/api-types/src/actors/create.rs +1 -0
- package/packages/api-types/src/actors/delete.rs +20 -0
- package/packages/api-types/src/actors/get_or_create.rs +30 -0
- package/packages/api-types/src/actors/kv_get.rs +25 -0
- package/packages/api-types/src/actors/list.rs +8 -1
- package/packages/api-types/src/actors/mod.rs +5 -0
- package/packages/api-types/src/actors/reschedule.rs +26 -0
- package/packages/api-types/src/actors/sleep.rs +26 -0
- package/packages/api-types/src/datacenters/list.rs +2 -2
- package/packages/api-types/src/envoys/list.rs +24 -0
- package/packages/api-types/src/envoys/mod.rs +1 -0
- package/packages/api-types/src/lib.rs +1 -0
- package/packages/api-types/src/namespaces/list.rs +4 -0
- package/packages/api-types/src/namespaces/runner_configs.rs +23 -2
- package/packages/api-types/src/runner_configs/list.rs +6 -1
- package/packages/api-types/src/runner_configs/mod.rs +12 -0
- package/packages/api-types/src/runners/list.rs +4 -0
- package/packages/api-types/src/runners/list_names.rs +21 -0
- package/packages/api-types/src/runners/mod.rs +1 -0
- package/packages/api-util/src/lib.rs +44 -21
- package/packages/bootstrap/Cargo.toml +7 -4
- package/packages/bootstrap/src/backfill.rs +53 -0
- package/packages/bootstrap/src/lib.rs +43 -7
- package/packages/cache/Cargo.toml +3 -1
- package/packages/cache/src/driver.rs +43 -151
- package/packages/cache/src/getter_ctx.rs +48 -70
- package/packages/cache/src/inner.rs +28 -18
- package/packages/cache/src/key.rs +17 -3
- package/packages/cache/src/lib.rs +0 -2
- package/packages/cache/src/metrics.rs +43 -31
- package/packages/cache/src/req_config.rs +219 -156
- package/packages/cache/tests/fetch.rs +91 -0
- package/packages/cache/tests/in_flight.rs +361 -0
- package/packages/cache/tests/ttl.rs +314 -0
- package/packages/cache-purge/src/lib.rs +1 -1
- package/packages/config/Cargo.toml +1 -0
- package/packages/config/src/config/cache.rs +10 -3
- package/packages/config/src/config/clickhouse.rs +0 -30
- package/packages/config/src/config/{db.rs → db/mod.rs} +3 -18
- package/packages/config/src/config/db/postgres.rs +59 -0
- package/packages/config/src/config/guard.rs +19 -0
- package/packages/config/src/config/metrics.rs +22 -0
- package/packages/config/src/config/mod.rs +44 -10
- package/packages/config/src/config/pegboard.rs +242 -16
- package/packages/config/src/config/pubsub.rs +11 -0
- package/packages/config/src/config/runtime.rs +58 -0
- package/packages/config/src/config/telemetry.rs +1 -0
- package/packages/config/src/config/topology.rs +78 -19
- package/packages/config/src/defaults.rs +3 -0
- package/packages/config/src/lib.rs +10 -1
- package/packages/config-schema-gen/Cargo.toml +11 -0
- package/packages/config-schema-gen/build.rs +26 -0
- package/packages/config-schema-gen/src/lib.rs +2 -0
- package/packages/engine/Cargo.toml +11 -2
- package/packages/engine/src/commands/db/mod.rs +0 -10
- package/packages/engine/src/commands/epoxy.rs +395 -0
- package/packages/engine/src/commands/mod.rs +1 -1
- package/packages/engine/src/commands/start.rs +43 -63
- package/packages/engine/src/commands/udb/cli.rs +148 -4
- package/packages/engine/src/commands/wf/mod.rs +83 -12
- package/packages/engine/src/commands/wf/signal.rs +38 -0
- package/packages/engine/src/lib.rs +6 -3
- package/packages/engine/src/main.rs +1 -1
- package/packages/engine/src/run_config.rs +6 -7
- package/packages/engine/src/util/db.rs +1 -25
- package/packages/engine/src/util/wf/mod.rs +39 -5
- package/packages/engine/tests/common/actors.rs +50 -332
- package/packages/engine/tests/common/api/mod.rs +7 -0
- package/packages/engine/tests/common/api/peer.rs +364 -0
- package/packages/engine/tests/common/api/public.rs +473 -0
- package/packages/engine/tests/common/ctx.rs +15 -3
- package/packages/engine/tests/common/mod.rs +8 -5
- package/packages/engine/tests/common/test_envoy.rs +87 -0
- package/packages/engine/tests/common/test_helpers.rs +218 -130
- package/packages/engine/tests/common/test_runner.rs +273 -0
- package/packages/engine/tests/envoy/actors_lifecycle.rs +1277 -0
- package/packages/engine/tests/envoy/mod.rs +1 -0
- package/packages/engine/tests/mod.rs +3 -0
- package/packages/engine/tests/runner/actors_alarm.rs +1453 -0
- package/packages/engine/tests/runner/actors_kv_crud.rs +996 -0
- package/packages/engine/tests/runner/actors_kv_delete_range.rs +126 -0
- package/packages/engine/tests/runner/actors_kv_drop.rs +255 -0
- package/packages/engine/tests/runner/actors_kv_list.rs +1061 -0
- package/packages/engine/tests/runner/actors_kv_misc.rs +882 -0
- package/packages/engine/tests/runner/actors_lifecycle.rs +1284 -0
- package/packages/engine/tests/runner/actors_scheduling_errors.rs +1005 -0
- package/packages/engine/tests/runner/api_actors_create.rs +422 -0
- package/packages/engine/tests/runner/api_actors_delete.rs +487 -0
- package/packages/engine/tests/runner/api_actors_get_or_create.rs +634 -0
- package/packages/engine/tests/runner/api_actors_list.rs +1771 -0
- package/packages/engine/tests/runner/api_actors_list_names.rs +691 -0
- package/packages/engine/tests/runner/api_namespaces_create.rs +428 -0
- package/packages/engine/tests/runner/api_namespaces_list.rs +760 -0
- package/packages/engine/tests/runner/api_runner_configs_list.rs +646 -0
- package/packages/engine/tests/runner/api_runner_configs_upsert.rs +651 -0
- package/packages/engine/tests/runner/api_runners_list.rs +166 -0
- package/packages/engine/tests/runner/api_runners_list_names.rs +386 -0
- package/packages/engine/tests/runner/mod.rs +20 -0
- package/packages/engine/tests/runner/runner_drain_on_version.rs +620 -0
- package/packages/env/Cargo.toml +0 -4
- package/packages/env/src/lib.rs +0 -18
- package/packages/epoxy/Cargo.toml +3 -2
- package/packages/epoxy/README.md +554 -93
- package/packages/epoxy/src/consts.rs +4 -36
- package/packages/epoxy/src/http_client.rs +59 -26
- package/packages/epoxy/src/http_routes.rs +73 -10
- package/packages/epoxy/src/keys/keys.rs +260 -11
- package/packages/epoxy/src/keys/mod.rs +11 -1
- package/packages/epoxy/src/keys/replica.rs +5 -260
- package/packages/epoxy/src/lib.rs +2 -1
- package/packages/epoxy/src/metrics.rs +118 -0
- package/packages/epoxy/src/ops/kv/get_local.rs +15 -24
- package/packages/epoxy/src/ops/kv/get_optimistic.rs +102 -64
- package/packages/epoxy/src/ops/kv/mod.rs +1 -0
- package/packages/epoxy/src/ops/kv/purge_local.rs +18 -9
- package/packages/epoxy/src/ops/kv/read_value.rs +92 -0
- package/packages/epoxy/src/ops/mod.rs +0 -1
- package/packages/epoxy/src/ops/propose.rs +1079 -194
- package/packages/epoxy/src/replica/ballot.rs +162 -102
- package/packages/epoxy/src/replica/changelog.rs +147 -0
- package/packages/epoxy/src/replica/commit_kv.rs +69 -66
- package/packages/epoxy/src/replica/message_request.rs +33 -48
- package/packages/epoxy/src/replica/messages/accept.rs +82 -41
- package/packages/epoxy/src/replica/messages/commit.rs +21 -33
- package/packages/epoxy/src/replica/messages/mod.rs +0 -8
- package/packages/epoxy/src/replica/messages/prepare.rs +68 -69
- package/packages/epoxy/src/replica/mod.rs +1 -6
- package/packages/epoxy/src/replica/update_config.rs +3 -1
- package/packages/epoxy/src/types.rs +30 -54
- package/packages/epoxy/src/utils.rs +149 -16
- package/packages/epoxy/src/workflows/backfill.rs +233 -0
- package/packages/epoxy/src/workflows/coordinator/mod.rs +33 -7
- package/packages/epoxy/src/workflows/coordinator/reconfigure.rs +44 -0
- package/packages/epoxy/src/workflows/coordinator/replica_status_change.rs +4 -3
- package/packages/epoxy/src/workflows/mod.rs +1 -1
- package/packages/epoxy/src/workflows/replica/mod.rs +4 -6
- package/packages/epoxy/src/workflows/replica/setup.rs +130 -771
- package/packages/epoxy/tests/backfill.rs +65 -0
- package/packages/epoxy/tests/backfill_snapshot.rs +233 -0
- package/packages/epoxy/tests/common/mod.rs +77 -21
- package/packages/epoxy/tests/common/utils.rs +366 -10
- package/packages/epoxy/tests/consensus_regressions.rs +285 -0
- package/packages/epoxy/tests/kv.rs +128 -167
- package/packages/epoxy/tests/kv_get_optimistic.rs +257 -157
- package/packages/epoxy/tests/migration.rs +75 -0
- package/packages/epoxy/tests/proposal.rs +133 -28
- package/packages/epoxy/tests/reconfigure.rs +92 -474
- package/packages/error/tests/basic.rs +8 -8
- package/packages/gasoline/Cargo.toml +1 -0
- package/packages/gasoline/src/builder/common/message.rs +19 -47
- package/packages/gasoline/src/builder/common/signal.rs +37 -21
- package/packages/gasoline/src/builder/common/workflow.rs +19 -15
- package/packages/gasoline/src/builder/workflow/lupe.rs +295 -0
- package/packages/gasoline/src/builder/workflow/message.rs +24 -47
- package/packages/gasoline/src/builder/workflow/mod.rs +1 -0
- package/packages/gasoline/src/builder/workflow/signal.rs +68 -22
- package/packages/gasoline/src/builder/workflow/sub_workflow.rs +6 -15
- package/packages/gasoline/src/ctx/activity.rs +46 -6
- package/packages/gasoline/src/ctx/common.rs +26 -23
- package/packages/gasoline/src/ctx/listen.rs +33 -50
- package/packages/gasoline/src/ctx/message.rs +76 -64
- package/packages/gasoline/src/ctx/operation.rs +15 -5
- package/packages/gasoline/src/ctx/standalone.rs +32 -4
- package/packages/gasoline/src/ctx/test.rs +31 -6
- package/packages/gasoline/src/ctx/versioned_workflow.rs +33 -7
- package/packages/gasoline/src/ctx/workflow.rs +194 -384
- package/packages/gasoline/src/db/debug.rs +49 -9
- package/packages/gasoline/src/db/kv/debug.rs +905 -15
- package/packages/gasoline/src/db/kv/keys/history.rs +434 -9
- package/packages/gasoline/src/db/kv/keys/metric.rs +70 -47
- package/packages/gasoline/src/db/kv/keys/signal.rs +19 -3
- package/packages/gasoline/src/db/kv/keys/workflow.rs +349 -3
- package/packages/gasoline/src/db/kv/mod.rs +975 -514
- package/packages/gasoline/src/db/kv/system.rs +155 -18
- package/packages/gasoline/src/db/mod.rs +29 -7
- package/packages/gasoline/src/error.rs +26 -21
- package/packages/gasoline/src/executable.rs +3 -1
- package/packages/gasoline/src/history/cursor.rs +436 -336
- package/packages/gasoline/src/history/event.rs +24 -15
- package/packages/gasoline/src/listen.rs +2 -14
- package/packages/gasoline/src/message.rs +1 -1
- package/packages/gasoline/src/metrics.rs +260 -143
- package/packages/gasoline/src/prelude.rs +1 -1
- package/packages/gasoline/src/registry.rs +6 -2
- package/packages/gasoline/src/signal.rs +34 -31
- package/packages/gasoline/src/utils/mod.rs +1 -18
- package/packages/gasoline/src/utils/topic.rs +35 -0
- package/packages/gasoline/src/worker.rs +71 -14
- package/packages/gasoline/src/workflow.rs +13 -0
- package/packages/gasoline/tests/workflows/eviction_test.rs +2 -2
- package/packages/gasoline-macros/src/lib.rs +74 -12
- package/packages/gasoline-runtime/Cargo.toml +18 -0
- package/packages/gasoline-runtime/src/lib.rs +12 -0
- package/packages/gasoline-runtime/src/workflows/mod.rs +1 -0
- package/packages/gasoline-runtime/src/workflows/pruner.rs +55 -0
- package/packages/guard/Cargo.toml +16 -8
- package/packages/guard/src/cache/mod.rs +63 -43
- package/packages/guard/src/cache/pegboard_gateway.rs +144 -0
- package/packages/guard/src/errors.rs +105 -0
- package/packages/guard/src/lib.rs +5 -15
- package/packages/guard/src/metrics.rs +12 -0
- package/packages/guard/src/routing/actor_path.rs +409 -0
- package/packages/guard/src/routing/api_public.rs +6 -14
- package/packages/guard/src/routing/envoy.rs +98 -0
- package/packages/guard/src/routing/mod.rs +152 -206
- package/packages/guard/src/routing/pegboard_gateway/mod.rs +572 -0
- package/packages/guard/src/routing/pegboard_gateway/resolve_actor_query.rs +236 -0
- package/packages/guard/src/routing/runner.rs +24 -54
- package/packages/guard/src/routing/ws_health.rs +61 -0
- package/packages/guard/src/shared_state.rs +11 -2
- package/packages/guard/tests/parse_actor_path.rs +418 -165
- package/packages/guard-core/Cargo.toml +3 -10
- package/packages/guard-core/src/custom_serve.rs +4 -10
- package/packages/guard-core/src/errors.rs +20 -4
- package/packages/guard-core/src/lib.rs +6 -4
- package/packages/guard-core/src/metrics.rs +66 -53
- package/packages/guard-core/src/proxy_service.rs +618 -1520
- package/packages/guard-core/src/request_context.rs +149 -169
- package/packages/guard-core/src/response_body.rs +65 -0
- package/packages/guard-core/src/route.rs +76 -0
- package/packages/guard-core/src/server.rs +60 -26
- package/packages/guard-core/src/task_group.rs +4 -0
- package/packages/guard-core/src/utils.rs +296 -0
- package/packages/guard-core/src/websocket_handle.rs +3 -3
- package/packages/guard-core/tests/common/mod.rs +0 -1
- package/packages/guard-core/tests/custom_serve.rs +4 -6
- package/packages/guard-core/tests/simple_websocket.rs +19 -19
- package/packages/guard-core/tests/streaming_response.rs +4 -9
- package/packages/metrics/Cargo.toml +3 -2
- package/packages/metrics/src/buckets.rs +5 -11
- package/packages/metrics/src/lib.rs +6 -3
- package/packages/metrics/src/providers.rs +2 -42
- package/packages/metrics/src/registry.rs +7 -0
- package/packages/metrics/src/server.rs +57 -0
- package/packages/namespace/Cargo.toml +0 -3
- package/packages/namespace/src/keys/metric.rs +301 -0
- package/packages/namespace/src/keys/mod.rs +1 -1
- package/packages/namespace/src/ops/get_global.rs +7 -4
- package/packages/namespace/src/ops/get_local.rs +32 -16
- package/packages/namespace/src/ops/mod.rs +0 -1
- package/packages/namespace/src/ops/resolve_for_name_global.rs +7 -4
- package/packages/namespace/src/ops/resolve_for_name_local.rs +39 -19
- package/packages/namespace/src/workflows/namespace.rs +3 -3
- package/packages/pegboard/Cargo.toml +22 -0
- package/packages/pegboard/src/actor_kv/entry.rs +47 -0
- package/packages/pegboard/src/actor_kv/metrics.rs +19 -0
- package/packages/pegboard/src/actor_kv/mod.rs +530 -0
- package/packages/pegboard/src/actor_kv/preload.rs +363 -0
- package/packages/{actor-kv/src → pegboard/src/actor_kv}/utils.rs +36 -35
- package/packages/pegboard/src/errors.rs +39 -5
- package/packages/pegboard/src/keys/actor.rs +285 -2
- package/packages/{actor-kv/src/entry.rs → pegboard/src/keys/actor_kv.rs} +73 -39
- package/packages/pegboard/src/keys/backfill.rs +49 -0
- package/packages/pegboard/src/keys/envoy.rs +1070 -0
- package/packages/pegboard/src/keys/epoxy/ns.rs +1 -1
- package/packages/pegboard/src/keys/mod.rs +4 -6
- package/packages/pegboard/src/keys/ns.rs +493 -14
- package/packages/pegboard/src/keys/runner.rs +281 -0
- package/packages/{namespace → pegboard}/src/keys/runner_config.rs +53 -0
- package/packages/pegboard/src/lib.rs +15 -2
- package/packages/pegboard/src/metrics.rs +57 -16
- package/packages/pegboard/src/ops/actor/create.rs +123 -53
- package/packages/pegboard/src/ops/actor/get.rs +14 -45
- package/packages/pegboard/src/ops/actor/get_for_gateway.rs +16 -0
- package/packages/pegboard/src/ops/actor/get_for_key.rs +3 -0
- package/packages/pegboard/src/ops/actor/get_for_kv.rs +43 -0
- package/packages/pegboard/src/ops/actor/get_for_runner.rs +99 -0
- package/packages/pegboard/src/ops/actor/get_reservation_for_key.rs +1 -0
- package/packages/pegboard/src/ops/actor/list_for_ns.rs +10 -38
- package/packages/pegboard/src/ops/actor/list_names.rs +3 -3
- package/packages/pegboard/src/ops/actor/mod.rs +3 -1
- package/packages/pegboard/src/ops/actor/util.rs +263 -0
- package/packages/pegboard/src/ops/envoy/drain.rs +101 -0
- package/packages/pegboard/src/ops/envoy/evict_actors.rs +54 -0
- package/packages/pegboard/src/ops/envoy/expire.rs +92 -0
- package/packages/pegboard/src/ops/envoy/get.rs +135 -0
- package/packages/pegboard/src/ops/envoy/list.rs +131 -0
- package/packages/pegboard/src/ops/envoy/mod.rs +6 -0
- package/packages/pegboard/src/ops/envoy/update_ping.rs +92 -0
- package/packages/pegboard/src/ops/mod.rs +3 -0
- package/packages/pegboard/src/ops/runner/drain.rs +110 -0
- package/packages/pegboard/src/ops/runner/list_names.rs +3 -3
- package/packages/pegboard/src/ops/runner/list_runner_config_enabled_dcs.rs +199 -0
- package/packages/pegboard/src/ops/runner/list_runner_config_epoxy_replica_ids.rs +51 -0
- package/packages/pegboard/src/ops/runner/mod.rs +3 -1
- package/packages/pegboard/src/ops/runner/update_alloc_idx.rs +17 -5
- package/packages/{namespace → pegboard}/src/ops/runner_config/delete.rs +18 -9
- package/packages/pegboard/src/ops/runner_config/ensure_normal_if_missing.rs +62 -0
- package/packages/{namespace → pegboard}/src/ops/runner_config/get.rs +15 -5
- package/packages/pegboard/src/ops/runner_config/get_error.rs +146 -0
- package/packages/{namespace → pegboard}/src/ops/runner_config/list.rs +13 -12
- package/packages/pegboard/src/ops/runner_config/mod.rs +7 -0
- package/packages/pegboard/src/ops/runner_config/refresh_metadata.rs +124 -0
- package/packages/pegboard/src/ops/runner_config/upsert.rs +206 -0
- package/packages/pegboard/src/ops/serverless_metadata/fetch.rs +223 -0
- package/packages/pegboard/src/ops/serverless_metadata/mod.rs +1 -0
- package/packages/pegboard/src/pubsub_subjects.rs +52 -0
- package/packages/pegboard/src/utils.rs +36 -2
- package/packages/pegboard/src/workflows/actor/destroy.rs +135 -99
- package/packages/pegboard/src/workflows/actor/keys.rs +59 -5
- package/packages/pegboard/src/workflows/actor/metrics.rs +345 -0
- package/packages/pegboard/src/workflows/actor/mod.rs +848 -204
- package/packages/pegboard/src/workflows/actor/runtime.rs +785 -212
- package/packages/pegboard/src/workflows/actor/setup.rs +61 -0
- package/packages/pegboard/src/workflows/actor2/keys.rs +337 -0
- package/packages/pegboard/src/workflows/actor2/metrics.rs +334 -0
- package/packages/pegboard/src/workflows/actor2/mod.rs +1251 -0
- package/packages/pegboard/src/workflows/actor2/runtime.rs +1005 -0
- package/packages/pegboard/src/workflows/actor_runner_name_selector_backfill.rs +266 -0
- package/packages/pegboard/src/workflows/metrics_aggregator.rs +282 -0
- package/packages/pegboard/src/workflows/mod.rs +8 -0
- package/packages/pegboard/src/workflows/runner.rs +62 -56
- package/packages/pegboard/src/workflows/runner2.rs +978 -0
- package/packages/pegboard/src/workflows/runner_pool.rs +298 -0
- package/packages/pegboard/src/workflows/runner_pool_error_tracker.rs +173 -0
- package/packages/pegboard/src/workflows/runner_pool_metadata_poller.rs +237 -0
- package/packages/pegboard/src/workflows/serverless/backfill.rs +120 -0
- package/packages/pegboard/src/workflows/serverless/conn.rs +702 -0
- package/packages/pegboard/src/workflows/serverless/mod.rs +3 -0
- package/packages/pegboard/src/workflows/serverless/receiver.rs +87 -0
- package/packages/pegboard/tests/actor_v1_pre_migration.rs +77 -0
- package/packages/{actor-kv/tests/list_edge_cases.rs → pegboard/tests/kv_list_edge_cases.rs} +74 -59
- package/packages/{actor-kv → pegboard}/tests/kv_operations.rs +77 -48
- package/packages/pegboard-envoy/Cargo.toml +43 -0
- package/packages/pegboard-envoy/src/actor_event_demuxer.rs +165 -0
- package/packages/pegboard-envoy/src/conn.rs +417 -0
- package/packages/pegboard-envoy/src/errors.rs +38 -0
- package/packages/pegboard-envoy/src/lib.rs +250 -0
- package/packages/pegboard-envoy/src/metrics.rs +44 -0
- package/packages/pegboard-envoy/src/ping_task.rs +61 -0
- package/packages/pegboard-envoy/src/tunnel_to_ws_task.rs +183 -0
- package/packages/pegboard-envoy/src/utils.rs +68 -0
- package/packages/pegboard-envoy/src/ws_to_tunnel_task.rs +536 -0
- package/packages/pegboard-envoy/tests/support/ws_to_tunnel_task.rs +82 -0
- package/packages/pegboard-gateway/Cargo.toml +2 -0
- package/packages/pegboard-gateway/src/keepalive_task.rs +1 -1
- package/packages/pegboard-gateway/src/lib.rs +506 -128
- package/packages/pegboard-gateway/src/metrics.rs +7 -11
- package/packages/pegboard-gateway/src/metrics_task.rs +80 -0
- package/packages/pegboard-gateway/src/ping_task.rs +9 -2
- package/packages/pegboard-gateway/src/shared_state.rs +110 -74
- package/packages/pegboard-gateway/src/tunnel_to_ws_task.rs +21 -7
- package/packages/pegboard-gateway/src/ws_to_tunnel_task.rs +12 -6
- package/packages/pegboard-gateway2/Cargo.toml +37 -0
- package/packages/pegboard-gateway2/src/keepalive_task.rs +61 -0
- package/packages/pegboard-gateway2/src/lib.rs +1044 -0
- package/packages/pegboard-gateway2/src/metrics.rs +10 -0
- package/packages/pegboard-gateway2/src/metrics_task.rs +80 -0
- package/packages/pegboard-gateway2/src/ping_task.rs +30 -0
- package/packages/pegboard-gateway2/src/shared_state.rs +601 -0
- package/packages/pegboard-gateway2/src/tunnel_to_ws_task.rs +99 -0
- package/packages/pegboard-gateway2/src/ws_to_tunnel_task.rs +71 -0
- package/packages/{pegboard-serverless → pegboard-outbound}/Cargo.toml +9 -9
- package/packages/pegboard-outbound/src/lib.rs +487 -0
- package/packages/pegboard-outbound/src/metrics.rs +17 -0
- package/packages/pegboard-runner/Cargo.toml +11 -5
- package/packages/pegboard-runner/src/actor_event_demuxer.rs +163 -0
- package/packages/pegboard-runner/src/conn.rs +358 -122
- package/packages/pegboard-runner/src/errors.rs +5 -0
- package/packages/pegboard-runner/src/lib.rs +62 -36
- package/packages/pegboard-runner/src/metrics.rs +44 -0
- package/packages/pegboard-runner/src/ping_task.rs +60 -13
- package/packages/pegboard-runner/src/tunnel_to_ws_task.rs +249 -110
- package/packages/pegboard-runner/src/ws_to_tunnel_task.rs +738 -113
- package/packages/pegboard-runner/tests/support/ws_to_tunnel_task.rs +150 -0
- package/packages/pools/Cargo.toml +1 -2
- package/packages/pools/src/db/clickhouse.rs +7 -6
- package/packages/pools/src/db/udb.rs +16 -3
- package/packages/pools/src/db/ups.rs +27 -5
- package/packages/pools/src/error.rs +0 -3
- package/packages/pools/src/lib.rs +0 -2
- package/packages/pools/src/metrics.rs +33 -28
- package/packages/pools/src/pools.rs +15 -39
- package/packages/pools/src/prelude.rs +1 -1
- package/packages/postgres-util/Cargo.toml +13 -0
- package/packages/postgres-util/src/lib.rs +84 -0
- package/packages/runner-protocol/build.rs +157 -0
- package/packages/runner-protocol/src/lib.rs +16 -0
- package/packages/runner-protocol/src/util.rs +14 -0
- package/packages/runner-protocol/src/versioned.rs +4345 -0
- package/packages/runtime/src/lib.rs +46 -46
- package/packages/runtime/src/metrics.rs +39 -30
- package/packages/runtime/src/term_signal.rs +25 -12
- package/packages/runtime/src/traces.rs +5 -8
- package/packages/service-manager/src/lib.rs +66 -15
- package/packages/test-deps/src/datacenter.rs +22 -8
- package/packages/test-deps/src/lib.rs +47 -25
- package/packages/test-deps-docker/src/database.rs +45 -36
- package/packages/test-snapshot-gen/Cargo.toml +39 -0
- package/packages/test-snapshot-gen/snapshots/.gitkeep +0 -0
- package/packages/test-snapshot-gen/snapshots/epoxy-v1/metadata.json +3 -0
- package/packages/test-snapshot-gen/snapshots/epoxy-v1/replica-1/000008.log +0 -0
- package/packages/test-snapshot-gen/snapshots/epoxy-v1/replica-1/000009.sst +3 -0
- package/packages/test-snapshot-gen/snapshots/epoxy-v1/replica-1/CURRENT +3 -0
- package/packages/test-snapshot-gen/snapshots/epoxy-v1/replica-1/MANIFEST-000005 +3 -0
- package/packages/test-snapshot-gen/snapshots/epoxy-v1/replica-1/OPTIONS-000007 +3 -0
- package/packages/test-snapshot-gen/snapshots/epoxy-v1/replica-2/000008.log +0 -0
- package/packages/test-snapshot-gen/snapshots/epoxy-v1/replica-2/000009.sst +3 -0
- package/packages/test-snapshot-gen/snapshots/epoxy-v1/replica-2/CURRENT +3 -0
- package/packages/test-snapshot-gen/snapshots/epoxy-v1/replica-2/MANIFEST-000005 +3 -0
- package/packages/test-snapshot-gen/snapshots/epoxy-v1/replica-2/OPTIONS-000007 +3 -0
- package/packages/test-snapshot-gen/snapshots/pb-actor-v1-pre-migration/metadata.json +3 -0
- package/packages/test-snapshot-gen/snapshots/pb-actor-v1-pre-migration/replica-1/000008.log +0 -0
- package/packages/test-snapshot-gen/snapshots/pb-actor-v1-pre-migration/replica-1/000009.sst +3 -0
- package/packages/test-snapshot-gen/snapshots/pb-actor-v1-pre-migration/replica-1/CURRENT +3 -0
- package/packages/test-snapshot-gen/snapshots/pb-actor-v1-pre-migration/replica-1/MANIFEST-000005 +3 -0
- package/packages/test-snapshot-gen/snapshots/pb-actor-v1-pre-migration/replica-1/OPTIONS-000007 +3 -0
- package/packages/test-snapshot-gen/snapshots/pb-actor-v1-pre-migration/replica-2/000008.log +0 -0
- package/packages/test-snapshot-gen/snapshots/pb-actor-v1-pre-migration/replica-2/000009.sst +3 -0
- package/packages/test-snapshot-gen/snapshots/pb-actor-v1-pre-migration/replica-2/CURRENT +3 -0
- package/packages/test-snapshot-gen/snapshots/pb-actor-v1-pre-migration/replica-2/MANIFEST-000005 +3 -0
- package/packages/test-snapshot-gen/snapshots/pb-actor-v1-pre-migration/replica-2/OPTIONS-000007 +3 -0
- package/packages/test-snapshot-gen/src/lib.rs +328 -0
- package/packages/test-snapshot-gen/src/main.rs +145 -0
- package/packages/test-snapshot-gen/src/scenarios/epoxy_keys.rs +60 -0
- package/packages/test-snapshot-gen/src/scenarios/mod.rs +27 -0
- package/packages/test-snapshot-gen/src/scenarios/pb_actor_v1_pre_migration.rs +56 -0
- package/packages/test-snapshot-gen/src/test_cluster.rs +234 -0
- package/packages/tracing-reconfigure/src/lib.rs +1 -1
- package/packages/tracing-utils/src/lib.rs +12 -20
- package/packages/types/src/actor/error.rs +59 -0
- package/packages/types/src/actor/mod.rs +2 -0
- package/packages/types/src/actors.rs +5 -0
- package/packages/types/src/envoys.rs +21 -0
- package/packages/types/src/keys/backfill.rs +5 -0
- package/packages/types/src/keys/mod.rs +1 -0
- package/packages/types/src/lib.rs +2 -1
- package/packages/types/src/runner_configs.rs +43 -14
- package/packages/universaldb/Cargo.toml +4 -0
- package/packages/universaldb/src/database.rs +50 -5
- package/packages/universaldb/src/driver/mod.rs +12 -2
- package/packages/universaldb/src/driver/postgres/database.rs +88 -27
- package/packages/universaldb/src/driver/postgres/mod.rs +1 -1
- package/packages/universaldb/src/driver/postgres/transaction.rs +4 -7
- package/packages/universaldb/src/driver/postgres/transaction_task.rs +30 -52
- package/packages/universaldb/src/driver/rocksdb/database.rs +13 -7
- package/packages/universaldb/src/driver/rocksdb/transaction_conflict_tracker.rs +5 -5
- package/packages/universaldb/src/driver/rocksdb/transaction_task.rs +2 -1
- package/packages/universaldb/src/metrics.rs +39 -23
- package/packages/universaldb/src/prelude.rs +1 -1
- package/packages/universaldb/src/transaction.rs +9 -2
- package/packages/universaldb/src/utils/cherry_pick.rs +46 -46
- package/packages/universaldb/src/utils/keys.rs +21 -2
- package/packages/universaldb/src/utils/mod.rs +8 -0
- package/packages/universaldb/src/utils/subspace.rs +9 -4
- package/packages/universaldb/tests/integration.rs +5 -3
- package/packages/universaldb/tests/integration_gas.rs +5 -3
- package/packages/universaldb/tests/rocksdb.rs +152 -19
- package/packages/universalpubsub/Cargo.toml +8 -2
- package/packages/universalpubsub/benches/simple.rs +28 -8
- package/packages/universalpubsub/src/chunking.rs +27 -5
- package/packages/universalpubsub/src/driver/memory/mod.rs +131 -20
- package/packages/universalpubsub/src/driver/mod.rs +5 -0
- package/packages/universalpubsub/src/driver/nats/mod.rs +8 -0
- package/packages/universalpubsub/src/driver/postgres/mod.rs +505 -96
- package/packages/universalpubsub/src/lib.rs +3 -0
- package/packages/universalpubsub/src/metrics.rs +60 -0
- package/packages/universalpubsub/src/pubsub.rs +227 -87
- package/packages/universalpubsub/src/subject.rs +32 -0
- package/packages/universalpubsub/tests/chunking.rs +298 -0
- package/packages/universalpubsub/tests/integration.rs +148 -7
- package/packages/universalpubsub/tests/reconnect.rs +8 -6
- package/packages/util/Cargo.toml +1 -3
- package/packages/util/build.rs +6 -0
- package/packages/util/src/lib.rs +7 -2
- package/packages/util/src/metric.rs +1 -0
- package/packages/util/src/serde.rs +1 -516
- package/packages/{internal → util-serde}/Cargo.toml +4 -5
- package/packages/util-serde/src/lib.rs +517 -0
- package/packages/workflow-worker/Cargo.toml +4 -4
- package/packages/workflow-worker/src/lib.rs +3 -2
- package/sdks/go/api-full/client/client.go +17 -4
- package/sdks/go/api-full/metadata/client.go +50 -0
- package/sdks/go/api-full/namespaces/client.go +3 -0
- package/sdks/go/api-full/namespaces.go +6 -4
- package/sdks/go/api-full/runners/client.go +3 -0
- package/sdks/go/api-full/runners.go +8 -6
- package/sdks/go/api-full/types.go +107 -23
- package/sdks/rust/api-full/rust/.openapi-generator/FILES +6 -0
- package/sdks/rust/api-full/rust/Cargo.toml +1 -1
- package/sdks/rust/api-full/rust/README.md +5 -2
- package/sdks/rust/api-full/rust/docs/Actor.md +1 -0
- package/sdks/rust/api-full/rust/docs/ActorsDeleteApi.md +1 -1
- package/sdks/rust/api-full/rust/docs/ActorsKvGetApi.md +2 -1
- package/sdks/rust/api-full/rust/docs/ActorsListApi.md +3 -2
- package/sdks/rust/api-full/rust/docs/MetadataApi.md +34 -0
- package/sdks/rust/api-full/rust/docs/MetadataGetResponse.md +18 -0
- package/sdks/rust/api-full/rust/docs/NamespacesApi.md +3 -2
- package/sdks/rust/api-full/rust/docs/RunnerConfig.md +1 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigKindOneOf1Serverless.md +1 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigResponse.md +15 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigsListApi.md +3 -2
- package/sdks/rust/api-full/rust/docs/RunnerConfigsListResponseRunnerConfigsValue.md +1 -1
- package/sdks/rust/api-full/rust/docs/RunnersApi.md +3 -2
- package/sdks/rust/api-full/rust/src/apis/actors_create_api.rs +1 -1
- package/sdks/rust/api-full/rust/src/apis/actors_delete_api.rs +3 -5
- package/sdks/rust/api-full/rust/src/apis/actors_get_or_create_api.rs +1 -1
- package/sdks/rust/api-full/rust/src/apis/actors_kv_get_api.rs +4 -2
- package/sdks/rust/api-full/rust/src/apis/actors_list_api.rs +9 -2
- package/sdks/rust/api-full/rust/src/apis/actors_list_names_api.rs +1 -1
- package/sdks/rust/api-full/rust/src/apis/configuration.rs +2 -2
- package/sdks/rust/api-full/rust/src/apis/datacenters_api.rs +1 -1
- package/sdks/rust/api-full/rust/src/apis/health_api.rs +1 -1
- package/sdks/rust/api-full/rust/src/apis/metadata_api.rs +62 -0
- package/sdks/rust/api-full/rust/src/apis/mod.rs +1 -0
- package/sdks/rust/api-full/rust/src/apis/namespaces_api.rs +9 -2
- package/sdks/rust/api-full/rust/src/apis/runner_configs_delete_api.rs +1 -1
- package/sdks/rust/api-full/rust/src/apis/runner_configs_list_api.rs +9 -2
- package/sdks/rust/api-full/rust/src/apis/runner_configs_refresh_metadata_api.rs +1 -1
- package/sdks/rust/api-full/rust/src/apis/runner_configs_serverless_health_check_api.rs +1 -1
- package/sdks/rust/api-full/rust/src/apis/runner_configs_upsert_api.rs +1 -1
- package/sdks/rust/api-full/rust/src/apis/runners_api.rs +9 -2
- package/sdks/rust/api-full/rust/src/models/actor.rs +5 -1
- package/sdks/rust/api-full/rust/src/models/actor_name.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/actors_create_request.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/actors_create_response.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/actors_get_or_create_request.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/actors_get_or_create_response.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/actors_kv_get_response.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/actors_list_names_response.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/actors_list_response.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/crash_policy.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/datacenter.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/datacenter_health.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/datacenters_list_response.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/health_fanout_response.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/health_response.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/health_status.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/metadata_get_response.rs +48 -0
- package/sdks/rust/api-full/rust/src/models/mod.rs +4 -0
- package/sdks/rust/api-full/rust/src/models/namespace.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/namespace_list_response.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/namespaces_create_request.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/namespaces_create_response.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/pagination.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/runner.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/runner_config.rs +4 -1
- package/sdks/rust/api-full/rust/src/models/runner_config_kind.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/runner_config_kind_one_of.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/runner_config_kind_one_of_1.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/runner_config_kind_one_of_1_serverless.rs +5 -1
- package/sdks/rust/api-full/rust/src/models/runner_config_response.rs +39 -0
- package/sdks/rust/api-full/rust/src/models/runner_config_variant.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/runner_configs_list_response.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/runner_configs_list_response_runner_configs_value.rs +3 -3
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_health_check_request.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_health_check_response.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_health_check_response_one_of.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_health_check_response_one_of_1.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_health_check_response_one_of_1_failure.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_health_check_response_one_of_success.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error_one_of.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error_one_of_1.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error_one_of_2.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error_one_of_3.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error_one_of_3_non_success_status.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error_one_of_4.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error_one_of_4_invalid_response_json.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error_one_of_5.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error_one_of_5_invalid_response_schema.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/runner_configs_upsert_request_body.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/runner_configs_upsert_response.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/runners_list_names_response.rs +1 -1
- package/sdks/rust/api-full/rust/src/models/runners_list_response.rs +1 -1
- package/sdks/rust/api-full/src/apis/actors_api.rs +8 -4
- package/sdks/rust/api-full/src/apis/ns_api.rs +8 -4
- package/sdks/rust/data/src/converted.rs +7 -4
- package/sdks/rust/data/src/lib.rs +2 -2
- package/sdks/rust/data/src/versioned/mod.rs +47 -4
- package/sdks/rust/data/src/versioned/namespace_runner_config.rs +256 -6
- package/sdks/rust/envoy-client/Cargo.toml +25 -0
- package/sdks/rust/envoy-client/src/actor.rs +992 -0
- package/sdks/rust/envoy-client/src/commands.rs +88 -0
- package/sdks/rust/envoy-client/src/config.rs +159 -0
- package/sdks/rust/envoy-client/src/connection.rs +288 -0
- package/sdks/rust/envoy-client/src/context.rs +24 -0
- package/sdks/rust/envoy-client/src/envoy.rs +432 -0
- package/sdks/rust/envoy-client/src/events.rs +62 -0
- package/sdks/rust/envoy-client/src/handle.rs +355 -0
- package/sdks/rust/envoy-client/src/kv.rs +132 -0
- package/sdks/rust/envoy-client/src/latency_channel.rs +27 -0
- package/sdks/rust/envoy-client/src/lib.rs +15 -0
- package/sdks/rust/envoy-client/src/stringify.rs +322 -0
- package/sdks/rust/envoy-client/src/tunnel.rs +265 -0
- package/sdks/rust/envoy-client/src/utils.rs +172 -0
- package/sdks/rust/envoy-protocol/Cargo.toml +22 -0
- package/sdks/rust/envoy-protocol/build.rs +200 -0
- package/sdks/rust/envoy-protocol/src/generated.rs +1 -0
- package/sdks/rust/envoy-protocol/src/lib.rs +8 -0
- package/sdks/rust/envoy-protocol/src/versioned.rs +208 -0
- package/sdks/rust/epoxy-protocol/Cargo.toml +0 -2
- package/sdks/rust/epoxy-protocol/build.rs +7 -0
- package/sdks/rust/epoxy-protocol/src/lib.rs +2 -5
- package/sdks/rust/epoxy-protocol/src/protocol.rs +128 -0
- package/sdks/rust/test-envoy/Cargo.toml +23 -0
- package/sdks/rust/test-envoy/Dockerfile +22 -0
- package/sdks/rust/test-envoy/src/behaviors.rs +141 -0
- package/sdks/rust/test-envoy/src/lib.rs +11 -0
- package/sdks/rust/test-envoy/src/main.rs +4 -0
- package/sdks/rust/test-envoy/src/server.rs +269 -0
- package/sdks/schemas/README.md +1 -2
- package/sdks/schemas/data/namespace.runner_config.v3.bare +24 -0
- package/sdks/schemas/data/namespace.runner_config.v4.bare +25 -0
- package/sdks/schemas/data/namespace.runner_config.v5.bare +26 -0
- package/sdks/schemas/data/pegboard.namespace.runner_alloc_idx.v2.bare +8 -0
- package/sdks/schemas/envoy-protocol/v1.bare +459 -0
- package/sdks/schemas/epoxy-protocol/v2.bare +220 -0
- package/sdks/schemas/runner-protocol/v4.bare +438 -0
- package/sdks/schemas/runner-protocol/v5.bare +430 -0
- package/sdks/schemas/runner-protocol/v6.bare +432 -0
- package/sdks/schemas/runner-protocol/v7.bare +438 -0
- package/sdks/typescript/api-full/.turbo/turbo-build.log +28 -27
- package/sdks/typescript/api-full/build.js +7 -1
- package/sdks/typescript/api-full/package.json +66 -57
- package/sdks/typescript/api-full/rivetkit-engine-api-full-25.5.3.tgz +0 -0
- package/sdks/typescript/api-full/src/Client.ts +41 -10
- package/sdks/typescript/api-full/src/api/client/requests/ActorsDeleteRequest.ts +4 -2
- package/sdks/typescript/api-full/src/api/client/requests/ActorsKvGetRequest.ts +13 -0
- package/sdks/typescript/api-full/src/api/client/requests/ActorsListRequest.ts +6 -0
- package/sdks/typescript/api-full/src/api/client/requests/RunnerConfigsListRequest.ts +4 -0
- package/sdks/typescript/api-full/src/api/client/requests/index.ts +1 -0
- package/sdks/typescript/api-full/src/api/resources/index.ts +1 -0
- package/sdks/typescript/api-full/src/api/resources/metadata/client/Client.ts +97 -0
- package/sdks/typescript/api-full/src/api/resources/metadata/client/index.ts +1 -0
- package/sdks/typescript/api-full/src/api/resources/metadata/index.ts +1 -0
- package/sdks/typescript/api-full/src/api/resources/namespaces/client/Client.ts +12 -2
- package/sdks/typescript/api-full/src/api/resources/namespaces/client/requests/NamespacesListRequest.ts +6 -0
- package/sdks/typescript/api-full/src/api/resources/runners/client/Client.ts +12 -2
- package/sdks/typescript/api-full/src/api/resources/runners/client/requests/RunnersListRequest.ts +6 -0
- package/sdks/typescript/api-full/src/api/types/Actor.ts +2 -0
- package/sdks/typescript/api-full/src/api/types/MetadataGetResponse.ts +14 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfig.ts +1 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigKindServerlessServerless.ts +2 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigResponse.ts +9 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigServerless.ts +2 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigsListResponseRunnerConfigsValue.ts +1 -1
- package/sdks/typescript/api-full/src/api/types/index.ts +2 -0
- package/sdks/typescript/api-full/src/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.ts +6 -4
- package/sdks/typescript/api-full/src/core/fetcher/stream-wrappers/UndiciStreamWrapper.ts +4 -3
- package/sdks/typescript/api-full/src/serialization/types/Actor.ts +2 -0
- package/sdks/typescript/api-full/src/serialization/types/MetadataGetResponse.ts +34 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfig.ts +5 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigKindServerlessServerless.ts +2 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigResponse.ts +26 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigServerless.ts +2 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigsListResponseRunnerConfigsValue.ts +3 -3
- package/sdks/typescript/api-full/src/serialization/types/index.ts +2 -0
- package/sdks/typescript/api-full/turbo.json +9 -0
- package/sdks/typescript/envoy-protocol/.turbo/turbo-build.log +23 -0
- package/sdks/typescript/{runner-protocol → envoy-protocol}/dist/index.cjs +466 -281
- package/sdks/typescript/envoy-protocol/dist/index.cjs.map +1 -0
- package/sdks/typescript/envoy-protocol/dist/index.d.cts +699 -0
- package/sdks/typescript/envoy-protocol/dist/index.d.ts +699 -0
- package/sdks/typescript/{runner-protocol → envoy-protocol}/dist/index.js +530 -345
- package/sdks/typescript/envoy-protocol/dist/index.js.map +1 -0
- package/sdks/typescript/{runner-protocol → envoy-protocol}/node_modules/.bin/tsc +4 -4
- package/{tests/load → sdks/typescript/envoy-protocol}/node_modules/.bin/tsserver +4 -4
- package/sdks/typescript/envoy-protocol/node_modules/.bin/tsup +21 -0
- package/sdks/typescript/envoy-protocol/node_modules/.bin/tsup-node +21 -0
- package/sdks/typescript/envoy-protocol/package.json +36 -0
- package/sdks/typescript/envoy-protocol/src/index.ts +2331 -0
- package/sdks/typescript/envoy-protocol/tsconfig.json +9 -0
- package/sdks/typescript/envoy-protocol/tsup.config.ts +4 -0
- package/sdks/typescript/runner/package.json +8 -2
- package/sdks/typescript/runner/src/actor.ts +38 -0
- package/sdks/typescript/runner/src/mod.ts +435 -229
- package/sdks/typescript/runner/src/stringify.ts +36 -33
- package/sdks/typescript/runner/src/tunnel.ts +52 -56
- package/sdks/typescript/runner/src/utils.ts +19 -0
- package/sdks/typescript/runner/src/websocket-tunnel-adapter.ts +98 -435
- package/sdks/typescript/runner-protocol/package.json +11 -9
- package/sdks/typescript/runner-protocol/src/index.ts +224 -156
- package/sdks/typescript/runner-protocol/tsconfig.json +1 -9
- package/sdks/typescript/test-runner/.turbo/turbo-build.log +5 -5
- package/sdks/typescript/test-runner/dist/index.js +53 -44
- package/sdks/typescript/test-runner/dist/index.js.map +1 -1
- package/sdks/typescript/test-runner/node_modules/.bin/pino +2 -2
- package/sdks/typescript/test-runner/node_modules/.bin/tsc +4 -4
- package/sdks/typescript/test-runner/node_modules/.bin/tsserver +4 -4
- package/sdks/typescript/test-runner/node_modules/.bin/tsup +4 -4
- package/sdks/typescript/test-runner/node_modules/.bin/tsup-node +4 -4
- package/sdks/typescript/test-runner/node_modules/.bin/tsx +4 -4
- package/sdks/typescript/test-runner/node_modules/.bin/vitest +4 -4
- package/sdks/typescript/test-runner/package.json +3 -3
- package/sdks/typescript/test-runner/src/index.ts +65 -42
- package/sdks/typescript/test-runner/src/log.ts +4 -18
- package/artifacts/errors/actor.no_runners_available.json +0 -5
- package/artifacts/errors/guard.actor_destroyed.json +0 -5
- package/artifacts/errors/guard.actor_not_found.json +0 -5
- package/contrib-docs/ACTOR_KEY_RESERVATION.md +0 -101
- package/contrib-docs/API.md +0 -11
- package/contrib-docs/DOCKER.md +0 -5
- package/contrib-docs/ERRORS.md +0 -13
- package/contrib-docs/GUARD.md +0 -76
- package/contrib-docs/PEGBOARD_TUNNEL_RETRIES.md +0 -83
- package/contrib-docs/RUNNER_LIFECYCLE.md +0 -172
- package/contrib-docs/SDKS.md +0 -9
- package/contrib-docs/TEST_DEPENDENCIES.md +0 -43
- package/contrib-docs/design-choicse/EMBEDDED_KV.md +0 -80
- package/contrib-docs/operate/TRACING_RECONFIGURE.md +0 -78
- package/docker/dev/otel-collector-client/config.yaml +0 -39
- package/docker/dev-host/otel-collector-client/config.yaml +0 -39
- package/docker/dev-multidc/datacenters/dc-a/otel-collector-client/config.yaml +0 -39
- package/docker/dev-multidc/datacenters/dc-b/otel-collector-client/config.yaml +0 -39
- package/docker/dev-multidc/datacenters/dc-c/otel-collector-client/config.yaml +0 -39
- package/docker/dev-multidc-multinode/datacenters/dc-a/otel-collector-client/config.yaml +0 -39
- package/docker/dev-multidc-multinode/datacenters/dc-b/otel-collector-client/config.yaml +0 -39
- package/docker/dev-multidc-multinode/datacenters/dc-c/otel-collector-client/config.yaml +0 -39
- package/docker/dev-multinode/otel-collector-client/config.yaml +0 -39
- package/docker/template/src/services/edge/otel-collector-client.ts +0 -64
- package/packages/actor-kv/Cargo.toml +0 -31
- package/packages/actor-kv/src/key.rs +0 -81
- package/packages/actor-kv/src/lib.rs +0 -357
- package/packages/cache/src/rate_limit.rs +0 -109
- package/packages/cache/tests/integration.rs +0 -582
- package/packages/clickhouse-inserter/Cargo.toml +0 -17
- package/packages/clickhouse-inserter/src/error.rs +0 -16
- package/packages/clickhouse-inserter/src/lib.rs +0 -179
- package/packages/clickhouse-user-query/Cargo.toml +0 -16
- package/packages/clickhouse-user-query/examples/case_sensitivity_demo.rs +0 -100
- package/packages/clickhouse-user-query/examples/group_by_example.rs +0 -53
- package/packages/clickhouse-user-query/examples/string_contains_demo.rs +0 -96
- package/packages/clickhouse-user-query/src/builder.rs +0 -445
- package/packages/clickhouse-user-query/src/error.rs +0 -37
- package/packages/clickhouse-user-query/src/lib.rs +0 -61
- package/packages/clickhouse-user-query/src/query.rs +0 -143
- package/packages/clickhouse-user-query/src/schema.rs +0 -78
- package/packages/clickhouse-user-query/tests/builder_tests.rs +0 -619
- package/packages/clickhouse-user-query/tests/case_sensitivity_tests.rs +0 -307
- package/packages/clickhouse-user-query/tests/integration_tests.rs +0 -540
- package/packages/clickhouse-user-query/tests/query_tests.rs +0 -263
- package/packages/clickhouse-user-query/tests/schema_tests.rs +0 -44
- package/packages/config/src/config/vector.rs +0 -18
- package/packages/engine/src/commands/udb_keys.rs +0 -200
- package/packages/engine/tests/actors_create.rs +0 -524
- package/packages/engine/tests/actors_delete.rs +0 -243
- package/packages/engine/tests/actors_general.rs +0 -191
- package/packages/engine/tests/actors_get.rs +0 -230
- package/packages/engine/tests/actors_get_by_id.rs +0 -170
- package/packages/engine/tests/actors_get_or_create.rs +0 -294
- package/packages/engine/tests/actors_get_or_create_by_id.rs +0 -147
- package/packages/engine/tests/actors_lifecycle.rs +0 -165
- package/packages/engine/tests/actors_list.rs +0 -798
- package/packages/engine/tests/actors_list_names.rs +0 -353
- package/packages/engine/tests/common/ns.rs +0 -36
- package/packages/engine/tests/common/runner.rs +0 -134
- package/packages/engine/tests/runners_dupe_key.rs +0 -27
- package/packages/engine/tests/runners_version.rs +0 -50
- package/packages/env/build.rs +0 -8
- package/packages/epoxy/spec/KEYS.md +0 -33
- package/packages/epoxy/spec/PROPOSAL.md +0 -125
- package/packages/epoxy/spec/RECONFIGURE.md +0 -40
- package/packages/epoxy/src/ops/explicit_prepare.rs +0 -342
- package/packages/epoxy/src/replica/decide_path.rs +0 -51
- package/packages/epoxy/src/replica/lead_consensus.rs +0 -65
- package/packages/epoxy/src/replica/log.rs +0 -84
- package/packages/epoxy/src/replica/messages/accepted.rs +0 -35
- package/packages/epoxy/src/replica/messages/committed.rs +0 -41
- package/packages/epoxy/src/replica/messages/download_instances.rs +0 -69
- package/packages/epoxy/src/replica/messages/pre_accept.rs +0 -69
- package/packages/epoxy/src/replica/utils.rs +0 -111
- package/packages/epoxy/src/workflows/purger.rs +0 -81
- package/packages/guard/src/cache/actor.rs +0 -43
- package/packages/guard/src/middleware.rs +0 -42
- package/packages/guard/src/routing/pegboard_gateway.rs +0 -260
- package/packages/guard-core/src/analytics.rs +0 -46
- package/packages/internal/README.md +0 -1
- package/packages/internal/src/lib.rs +0 -1
- package/packages/internal/src/ops/bump_serverless_autoscaler_global.rs +0 -64
- package/packages/internal/src/ops/cache/mod.rs +0 -1
- package/packages/internal/src/ops/cache/purge_global.rs +0 -81
- package/packages/internal/src/ops/mod.rs +0 -2
- package/packages/namespace/src/ops/runner_config/mod.rs +0 -4
- package/packages/namespace/src/ops/runner_config/upsert.rs +0 -148
- package/packages/pegboard/src/ops/actor/get_runner.rs +0 -64
- package/packages/pegboard/src/ops/runner/find_dc_with_runner.rs +0 -222
- package/packages/pegboard-serverless/src/lib.rs +0 -523
- package/packages/types/src/msgs/mod.rs +0 -1
- package/packages/types/src/msgs/pegboard.rs +0 -5
- package/sdks/rust/epoxy-protocol/src/versioned.rs +0 -206
- package/sdks/rust/runner-protocol/build.rs +0 -115
- package/sdks/rust/runner-protocol/src/lib.rs +0 -10
- package/sdks/rust/runner-protocol/src/versioned.rs +0 -1734
- package/sdks/schemas/epoxy-protocol/v1.bare +0 -260
- package/sdks/typescript/runner/.turbo/turbo-build.log +0 -22
- package/sdks/typescript/runner/dist/mod.cjs +0 -2951
- package/sdks/typescript/runner/dist/mod.cjs.map +0 -1
- package/sdks/typescript/runner/dist/mod.d.cts +0 -326
- package/sdks/typescript/runner/dist/mod.d.ts +0 -326
- package/sdks/typescript/runner/dist/mod.js +0 -2951
- package/sdks/typescript/runner/dist/mod.js.map +0 -1
- package/sdks/typescript/runner/node_modules/.bin/pino +0 -21
- package/sdks/typescript/runner/node_modules/.bin/tsc +0 -21
- package/sdks/typescript/runner/node_modules/.bin/tsserver +0 -21
- package/sdks/typescript/runner/node_modules/.bin/tsup +0 -21
- package/sdks/typescript/runner/node_modules/.bin/tsup-node +0 -21
- package/sdks/typescript/runner/node_modules/.bin/tsx +0 -21
- package/sdks/typescript/runner/node_modules/.bin/uuid +0 -21
- package/sdks/typescript/runner/node_modules/.bin/vitest +0 -21
- package/sdks/typescript/runner-protocol/.turbo/turbo-build.log +0 -22
- package/sdks/typescript/runner-protocol/dist/index.cjs.map +0 -1
- package/sdks/typescript/runner-protocol/dist/index.d.cts +0 -666
- package/sdks/typescript/runner-protocol/dist/index.d.ts +0 -666
- package/sdks/typescript/runner-protocol/dist/index.js.map +0 -1
- package/sdks/typescript/runner-protocol/node_modules/.bin/tsserver +0 -21
- package/sdks/typescript/runner-protocol/node_modules/.bin/tsup +0 -21
- package/sdks/typescript/runner-protocol/node_modules/.bin/tsup-node +0 -21
- package/sdks/typescript/test-runner/Dockerfile +0 -26
- package/tests/load/README.md +0 -28
- package/tests/load/actor-lifecycle/README.md +0 -26
- package/tests/load/actor-lifecycle/actor.ts +0 -41
- package/tests/load/actor-lifecycle/config.ts +0 -14
- package/tests/load/actor-lifecycle/index.ts +0 -62
- package/tests/load/actor-lifecycle/rivet_api.ts +0 -140
- package/tests/load/actor-lifecycle/types.ts +0 -17
- package/tests/load/node_modules/.bin/biome +0 -21
- package/tests/load/node_modules/.bin/tsc +0 -21
- package/tests/load/package.json +0 -15
- package/tests/load/tsconfig.json +0 -20
- package/tests/smoke/README.md +0 -32
- package/tests/smoke/package.json +0 -19
- package/tests/smoke/scripts/connect.ts +0 -41
- package/tests/smoke/src/server/registry.ts +0 -32
- package/tests/smoke/src/server/server.ts +0 -7
- package/tests/smoke/src/smoke-test/index.ts +0 -161
- package/tests/smoke/src/smoke-test/spawn-actor.ts +0 -109
- package/tests/smoke/tsconfig.json +0 -43
- /package/packages/{dump-openapi → api-public-openapi-gen}/build.rs +0 -0
- /package/packages/{dump-openapi → api-public-openapi-gen}/src/lib.rs +0 -0
- /package/{sdks/rust → packages}/runner-protocol/Cargo.toml +0 -0
- /package/{sdks/rust → packages}/runner-protocol/src/compat.rs +0 -0
- /package/{sdks/rust → packages}/runner-protocol/src/generated.rs +0 -0
- /package/{sdks/rust → packages}/runner-protocol/src/uuid_compat.rs +0 -0
- /package/sdks/rust/{runner-protocol → envoy-protocol}/src/util.rs +0 -0
- /package/{tests/smoke → sdks/typescript/envoy-protocol}/turbo.json +0 -0
|
@@ -0,0 +1,2331 @@
|
|
|
1
|
+
// @generated - post-processed by build.rs
|
|
2
|
+
|
|
3
|
+
import * as bare from "@rivetkit/bare-ts"
|
|
4
|
+
|
|
5
|
+
const DEFAULT_CONFIG = /* @__PURE__ */ bare.Config({})
|
|
6
|
+
|
|
7
|
+
export type i64 = bigint
|
|
8
|
+
export type u16 = number
|
|
9
|
+
export type u32 = number
|
|
10
|
+
export type u64 = bigint
|
|
11
|
+
|
|
12
|
+
export type Id = string
|
|
13
|
+
|
|
14
|
+
export function readId(bc: bare.ByteCursor): Id {
|
|
15
|
+
return bare.readString(bc)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function writeId(bc: bare.ByteCursor, x: Id): void {
|
|
19
|
+
bare.writeString(bc, x)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type Json = string
|
|
23
|
+
|
|
24
|
+
export function readJson(bc: bare.ByteCursor): Json {
|
|
25
|
+
return bare.readString(bc)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function writeJson(bc: bare.ByteCursor, x: Json): void {
|
|
29
|
+
bare.writeString(bc, x)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type GatewayId = ArrayBuffer
|
|
33
|
+
|
|
34
|
+
export function readGatewayId(bc: bare.ByteCursor): GatewayId {
|
|
35
|
+
return bare.readFixedData(bc, 4)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function writeGatewayId(bc: bare.ByteCursor, x: GatewayId): void {
|
|
39
|
+
assert(x.byteLength === 4)
|
|
40
|
+
bare.writeFixedData(bc, x)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type RequestId = ArrayBuffer
|
|
44
|
+
|
|
45
|
+
export function readRequestId(bc: bare.ByteCursor): RequestId {
|
|
46
|
+
return bare.readFixedData(bc, 4)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function writeRequestId(bc: bare.ByteCursor, x: RequestId): void {
|
|
50
|
+
assert(x.byteLength === 4)
|
|
51
|
+
bare.writeFixedData(bc, x)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type MessageIndex = u16
|
|
55
|
+
|
|
56
|
+
export function readMessageIndex(bc: bare.ByteCursor): MessageIndex {
|
|
57
|
+
return bare.readU16(bc)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function writeMessageIndex(bc: bare.ByteCursor, x: MessageIndex): void {
|
|
61
|
+
bare.writeU16(bc, x)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Basic types
|
|
66
|
+
*/
|
|
67
|
+
export type KvKey = ArrayBuffer
|
|
68
|
+
|
|
69
|
+
export function readKvKey(bc: bare.ByteCursor): KvKey {
|
|
70
|
+
return bare.readData(bc)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function writeKvKey(bc: bare.ByteCursor, x: KvKey): void {
|
|
74
|
+
bare.writeData(bc, x)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type KvValue = ArrayBuffer
|
|
78
|
+
|
|
79
|
+
export function readKvValue(bc: bare.ByteCursor): KvValue {
|
|
80
|
+
return bare.readData(bc)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function writeKvValue(bc: bare.ByteCursor, x: KvValue): void {
|
|
84
|
+
bare.writeData(bc, x)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export type KvMetadata = {
|
|
88
|
+
readonly version: ArrayBuffer
|
|
89
|
+
readonly updateTs: i64
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function readKvMetadata(bc: bare.ByteCursor): KvMetadata {
|
|
93
|
+
return {
|
|
94
|
+
version: bare.readData(bc),
|
|
95
|
+
updateTs: bare.readI64(bc),
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function writeKvMetadata(bc: bare.ByteCursor, x: KvMetadata): void {
|
|
100
|
+
bare.writeData(bc, x.version)
|
|
101
|
+
bare.writeI64(bc, x.updateTs)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Query types
|
|
106
|
+
*/
|
|
107
|
+
export type KvListAllQuery = null
|
|
108
|
+
|
|
109
|
+
export type KvListRangeQuery = {
|
|
110
|
+
readonly start: KvKey
|
|
111
|
+
readonly end: KvKey
|
|
112
|
+
readonly exclusive: boolean
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function readKvListRangeQuery(bc: bare.ByteCursor): KvListRangeQuery {
|
|
116
|
+
return {
|
|
117
|
+
start: readKvKey(bc),
|
|
118
|
+
end: readKvKey(bc),
|
|
119
|
+
exclusive: bare.readBool(bc),
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function writeKvListRangeQuery(bc: bare.ByteCursor, x: KvListRangeQuery): void {
|
|
124
|
+
writeKvKey(bc, x.start)
|
|
125
|
+
writeKvKey(bc, x.end)
|
|
126
|
+
bare.writeBool(bc, x.exclusive)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export type KvListPrefixQuery = {
|
|
130
|
+
readonly key: KvKey
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function readKvListPrefixQuery(bc: bare.ByteCursor): KvListPrefixQuery {
|
|
134
|
+
return {
|
|
135
|
+
key: readKvKey(bc),
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function writeKvListPrefixQuery(bc: bare.ByteCursor, x: KvListPrefixQuery): void {
|
|
140
|
+
writeKvKey(bc, x.key)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export type KvListQuery =
|
|
144
|
+
| { readonly tag: "KvListAllQuery"; readonly val: KvListAllQuery }
|
|
145
|
+
| { readonly tag: "KvListRangeQuery"; readonly val: KvListRangeQuery }
|
|
146
|
+
| { readonly tag: "KvListPrefixQuery"; readonly val: KvListPrefixQuery }
|
|
147
|
+
|
|
148
|
+
export function readKvListQuery(bc: bare.ByteCursor): KvListQuery {
|
|
149
|
+
const offset = bc.offset
|
|
150
|
+
const tag = bare.readU8(bc)
|
|
151
|
+
switch (tag) {
|
|
152
|
+
case 0:
|
|
153
|
+
return { tag: "KvListAllQuery", val: null }
|
|
154
|
+
case 1:
|
|
155
|
+
return { tag: "KvListRangeQuery", val: readKvListRangeQuery(bc) }
|
|
156
|
+
case 2:
|
|
157
|
+
return { tag: "KvListPrefixQuery", val: readKvListPrefixQuery(bc) }
|
|
158
|
+
default: {
|
|
159
|
+
bc.offset = offset
|
|
160
|
+
throw new bare.BareError(offset, "invalid tag")
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function writeKvListQuery(bc: bare.ByteCursor, x: KvListQuery): void {
|
|
166
|
+
switch (x.tag) {
|
|
167
|
+
case "KvListAllQuery": {
|
|
168
|
+
bare.writeU8(bc, 0)
|
|
169
|
+
break
|
|
170
|
+
}
|
|
171
|
+
case "KvListRangeQuery": {
|
|
172
|
+
bare.writeU8(bc, 1)
|
|
173
|
+
writeKvListRangeQuery(bc, x.val)
|
|
174
|
+
break
|
|
175
|
+
}
|
|
176
|
+
case "KvListPrefixQuery": {
|
|
177
|
+
bare.writeU8(bc, 2)
|
|
178
|
+
writeKvListPrefixQuery(bc, x.val)
|
|
179
|
+
break
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function read0(bc: bare.ByteCursor): readonly KvKey[] {
|
|
185
|
+
const len = bare.readUintSafe(bc)
|
|
186
|
+
if (len === 0) {
|
|
187
|
+
return []
|
|
188
|
+
}
|
|
189
|
+
const result = [readKvKey(bc)]
|
|
190
|
+
for (let i = 1; i < len; i++) {
|
|
191
|
+
result[i] = readKvKey(bc)
|
|
192
|
+
}
|
|
193
|
+
return result
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function write0(bc: bare.ByteCursor, x: readonly KvKey[]): void {
|
|
197
|
+
bare.writeUintSafe(bc, x.length)
|
|
198
|
+
for (let i = 0; i < x.length; i++) {
|
|
199
|
+
writeKvKey(bc, x[i])
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Request types
|
|
205
|
+
*/
|
|
206
|
+
export type KvGetRequest = {
|
|
207
|
+
readonly keys: readonly KvKey[]
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export function readKvGetRequest(bc: bare.ByteCursor): KvGetRequest {
|
|
211
|
+
return {
|
|
212
|
+
keys: read0(bc),
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export function writeKvGetRequest(bc: bare.ByteCursor, x: KvGetRequest): void {
|
|
217
|
+
write0(bc, x.keys)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function read1(bc: bare.ByteCursor): boolean | null {
|
|
221
|
+
return bare.readBool(bc) ? bare.readBool(bc) : null
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function write1(bc: bare.ByteCursor, x: boolean | null): void {
|
|
225
|
+
bare.writeBool(bc, x != null)
|
|
226
|
+
if (x != null) {
|
|
227
|
+
bare.writeBool(bc, x)
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function read2(bc: bare.ByteCursor): u64 | null {
|
|
232
|
+
return bare.readBool(bc) ? bare.readU64(bc) : null
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function write2(bc: bare.ByteCursor, x: u64 | null): void {
|
|
236
|
+
bare.writeBool(bc, x != null)
|
|
237
|
+
if (x != null) {
|
|
238
|
+
bare.writeU64(bc, x)
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export type KvListRequest = {
|
|
243
|
+
readonly query: KvListQuery
|
|
244
|
+
readonly reverse: boolean | null
|
|
245
|
+
readonly limit: u64 | null
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export function readKvListRequest(bc: bare.ByteCursor): KvListRequest {
|
|
249
|
+
return {
|
|
250
|
+
query: readKvListQuery(bc),
|
|
251
|
+
reverse: read1(bc),
|
|
252
|
+
limit: read2(bc),
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export function writeKvListRequest(bc: bare.ByteCursor, x: KvListRequest): void {
|
|
257
|
+
writeKvListQuery(bc, x.query)
|
|
258
|
+
write1(bc, x.reverse)
|
|
259
|
+
write2(bc, x.limit)
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function read3(bc: bare.ByteCursor): readonly KvValue[] {
|
|
263
|
+
const len = bare.readUintSafe(bc)
|
|
264
|
+
if (len === 0) {
|
|
265
|
+
return []
|
|
266
|
+
}
|
|
267
|
+
const result = [readKvValue(bc)]
|
|
268
|
+
for (let i = 1; i < len; i++) {
|
|
269
|
+
result[i] = readKvValue(bc)
|
|
270
|
+
}
|
|
271
|
+
return result
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function write3(bc: bare.ByteCursor, x: readonly KvValue[]): void {
|
|
275
|
+
bare.writeUintSafe(bc, x.length)
|
|
276
|
+
for (let i = 0; i < x.length; i++) {
|
|
277
|
+
writeKvValue(bc, x[i])
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export type KvPutRequest = {
|
|
282
|
+
readonly keys: readonly KvKey[]
|
|
283
|
+
readonly values: readonly KvValue[]
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export function readKvPutRequest(bc: bare.ByteCursor): KvPutRequest {
|
|
287
|
+
return {
|
|
288
|
+
keys: read0(bc),
|
|
289
|
+
values: read3(bc),
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export function writeKvPutRequest(bc: bare.ByteCursor, x: KvPutRequest): void {
|
|
294
|
+
write0(bc, x.keys)
|
|
295
|
+
write3(bc, x.values)
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export type KvDeleteRequest = {
|
|
299
|
+
readonly keys: readonly KvKey[]
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export function readKvDeleteRequest(bc: bare.ByteCursor): KvDeleteRequest {
|
|
303
|
+
return {
|
|
304
|
+
keys: read0(bc),
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export function writeKvDeleteRequest(bc: bare.ByteCursor, x: KvDeleteRequest): void {
|
|
309
|
+
write0(bc, x.keys)
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export type KvDeleteRangeRequest = {
|
|
313
|
+
readonly start: KvKey
|
|
314
|
+
readonly end: KvKey
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export function readKvDeleteRangeRequest(bc: bare.ByteCursor): KvDeleteRangeRequest {
|
|
318
|
+
return {
|
|
319
|
+
start: readKvKey(bc),
|
|
320
|
+
end: readKvKey(bc),
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
export function writeKvDeleteRangeRequest(bc: bare.ByteCursor, x: KvDeleteRangeRequest): void {
|
|
325
|
+
writeKvKey(bc, x.start)
|
|
326
|
+
writeKvKey(bc, x.end)
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export type KvDropRequest = null
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Response types
|
|
333
|
+
*/
|
|
334
|
+
export type KvErrorResponse = {
|
|
335
|
+
readonly message: string
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export function readKvErrorResponse(bc: bare.ByteCursor): KvErrorResponse {
|
|
339
|
+
return {
|
|
340
|
+
message: bare.readString(bc),
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export function writeKvErrorResponse(bc: bare.ByteCursor, x: KvErrorResponse): void {
|
|
345
|
+
bare.writeString(bc, x.message)
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
function read4(bc: bare.ByteCursor): readonly KvMetadata[] {
|
|
349
|
+
const len = bare.readUintSafe(bc)
|
|
350
|
+
if (len === 0) {
|
|
351
|
+
return []
|
|
352
|
+
}
|
|
353
|
+
const result = [readKvMetadata(bc)]
|
|
354
|
+
for (let i = 1; i < len; i++) {
|
|
355
|
+
result[i] = readKvMetadata(bc)
|
|
356
|
+
}
|
|
357
|
+
return result
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function write4(bc: bare.ByteCursor, x: readonly KvMetadata[]): void {
|
|
361
|
+
bare.writeUintSafe(bc, x.length)
|
|
362
|
+
for (let i = 0; i < x.length; i++) {
|
|
363
|
+
writeKvMetadata(bc, x[i])
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export type KvGetResponse = {
|
|
368
|
+
readonly keys: readonly KvKey[]
|
|
369
|
+
readonly values: readonly KvValue[]
|
|
370
|
+
readonly metadata: readonly KvMetadata[]
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export function readKvGetResponse(bc: bare.ByteCursor): KvGetResponse {
|
|
374
|
+
return {
|
|
375
|
+
keys: read0(bc),
|
|
376
|
+
values: read3(bc),
|
|
377
|
+
metadata: read4(bc),
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export function writeKvGetResponse(bc: bare.ByteCursor, x: KvGetResponse): void {
|
|
382
|
+
write0(bc, x.keys)
|
|
383
|
+
write3(bc, x.values)
|
|
384
|
+
write4(bc, x.metadata)
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
export type KvListResponse = {
|
|
388
|
+
readonly keys: readonly KvKey[]
|
|
389
|
+
readonly values: readonly KvValue[]
|
|
390
|
+
readonly metadata: readonly KvMetadata[]
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
export function readKvListResponse(bc: bare.ByteCursor): KvListResponse {
|
|
394
|
+
return {
|
|
395
|
+
keys: read0(bc),
|
|
396
|
+
values: read3(bc),
|
|
397
|
+
metadata: read4(bc),
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
export function writeKvListResponse(bc: bare.ByteCursor, x: KvListResponse): void {
|
|
402
|
+
write0(bc, x.keys)
|
|
403
|
+
write3(bc, x.values)
|
|
404
|
+
write4(bc, x.metadata)
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
export type KvPutResponse = null
|
|
408
|
+
|
|
409
|
+
export type KvDeleteResponse = null
|
|
410
|
+
|
|
411
|
+
export type KvDropResponse = null
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Request/Response unions
|
|
415
|
+
*/
|
|
416
|
+
export type KvRequestData =
|
|
417
|
+
| { readonly tag: "KvGetRequest"; readonly val: KvGetRequest }
|
|
418
|
+
| { readonly tag: "KvListRequest"; readonly val: KvListRequest }
|
|
419
|
+
| { readonly tag: "KvPutRequest"; readonly val: KvPutRequest }
|
|
420
|
+
| { readonly tag: "KvDeleteRequest"; readonly val: KvDeleteRequest }
|
|
421
|
+
| { readonly tag: "KvDeleteRangeRequest"; readonly val: KvDeleteRangeRequest }
|
|
422
|
+
| { readonly tag: "KvDropRequest"; readonly val: KvDropRequest }
|
|
423
|
+
|
|
424
|
+
export function readKvRequestData(bc: bare.ByteCursor): KvRequestData {
|
|
425
|
+
const offset = bc.offset
|
|
426
|
+
const tag = bare.readU8(bc)
|
|
427
|
+
switch (tag) {
|
|
428
|
+
case 0:
|
|
429
|
+
return { tag: "KvGetRequest", val: readKvGetRequest(bc) }
|
|
430
|
+
case 1:
|
|
431
|
+
return { tag: "KvListRequest", val: readKvListRequest(bc) }
|
|
432
|
+
case 2:
|
|
433
|
+
return { tag: "KvPutRequest", val: readKvPutRequest(bc) }
|
|
434
|
+
case 3:
|
|
435
|
+
return { tag: "KvDeleteRequest", val: readKvDeleteRequest(bc) }
|
|
436
|
+
case 4:
|
|
437
|
+
return { tag: "KvDeleteRangeRequest", val: readKvDeleteRangeRequest(bc) }
|
|
438
|
+
case 5:
|
|
439
|
+
return { tag: "KvDropRequest", val: null }
|
|
440
|
+
default: {
|
|
441
|
+
bc.offset = offset
|
|
442
|
+
throw new bare.BareError(offset, "invalid tag")
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
export function writeKvRequestData(bc: bare.ByteCursor, x: KvRequestData): void {
|
|
448
|
+
switch (x.tag) {
|
|
449
|
+
case "KvGetRequest": {
|
|
450
|
+
bare.writeU8(bc, 0)
|
|
451
|
+
writeKvGetRequest(bc, x.val)
|
|
452
|
+
break
|
|
453
|
+
}
|
|
454
|
+
case "KvListRequest": {
|
|
455
|
+
bare.writeU8(bc, 1)
|
|
456
|
+
writeKvListRequest(bc, x.val)
|
|
457
|
+
break
|
|
458
|
+
}
|
|
459
|
+
case "KvPutRequest": {
|
|
460
|
+
bare.writeU8(bc, 2)
|
|
461
|
+
writeKvPutRequest(bc, x.val)
|
|
462
|
+
break
|
|
463
|
+
}
|
|
464
|
+
case "KvDeleteRequest": {
|
|
465
|
+
bare.writeU8(bc, 3)
|
|
466
|
+
writeKvDeleteRequest(bc, x.val)
|
|
467
|
+
break
|
|
468
|
+
}
|
|
469
|
+
case "KvDeleteRangeRequest": {
|
|
470
|
+
bare.writeU8(bc, 4)
|
|
471
|
+
writeKvDeleteRangeRequest(bc, x.val)
|
|
472
|
+
break
|
|
473
|
+
}
|
|
474
|
+
case "KvDropRequest": {
|
|
475
|
+
bare.writeU8(bc, 5)
|
|
476
|
+
break
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
export type KvResponseData =
|
|
482
|
+
| { readonly tag: "KvErrorResponse"; readonly val: KvErrorResponse }
|
|
483
|
+
| { readonly tag: "KvGetResponse"; readonly val: KvGetResponse }
|
|
484
|
+
| { readonly tag: "KvListResponse"; readonly val: KvListResponse }
|
|
485
|
+
| { readonly tag: "KvPutResponse"; readonly val: KvPutResponse }
|
|
486
|
+
| { readonly tag: "KvDeleteResponse"; readonly val: KvDeleteResponse }
|
|
487
|
+
| { readonly tag: "KvDropResponse"; readonly val: KvDropResponse }
|
|
488
|
+
|
|
489
|
+
export function readKvResponseData(bc: bare.ByteCursor): KvResponseData {
|
|
490
|
+
const offset = bc.offset
|
|
491
|
+
const tag = bare.readU8(bc)
|
|
492
|
+
switch (tag) {
|
|
493
|
+
case 0:
|
|
494
|
+
return { tag: "KvErrorResponse", val: readKvErrorResponse(bc) }
|
|
495
|
+
case 1:
|
|
496
|
+
return { tag: "KvGetResponse", val: readKvGetResponse(bc) }
|
|
497
|
+
case 2:
|
|
498
|
+
return { tag: "KvListResponse", val: readKvListResponse(bc) }
|
|
499
|
+
case 3:
|
|
500
|
+
return { tag: "KvPutResponse", val: null }
|
|
501
|
+
case 4:
|
|
502
|
+
return { tag: "KvDeleteResponse", val: null }
|
|
503
|
+
case 5:
|
|
504
|
+
return { tag: "KvDropResponse", val: null }
|
|
505
|
+
default: {
|
|
506
|
+
bc.offset = offset
|
|
507
|
+
throw new bare.BareError(offset, "invalid tag")
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
export function writeKvResponseData(bc: bare.ByteCursor, x: KvResponseData): void {
|
|
513
|
+
switch (x.tag) {
|
|
514
|
+
case "KvErrorResponse": {
|
|
515
|
+
bare.writeU8(bc, 0)
|
|
516
|
+
writeKvErrorResponse(bc, x.val)
|
|
517
|
+
break
|
|
518
|
+
}
|
|
519
|
+
case "KvGetResponse": {
|
|
520
|
+
bare.writeU8(bc, 1)
|
|
521
|
+
writeKvGetResponse(bc, x.val)
|
|
522
|
+
break
|
|
523
|
+
}
|
|
524
|
+
case "KvListResponse": {
|
|
525
|
+
bare.writeU8(bc, 2)
|
|
526
|
+
writeKvListResponse(bc, x.val)
|
|
527
|
+
break
|
|
528
|
+
}
|
|
529
|
+
case "KvPutResponse": {
|
|
530
|
+
bare.writeU8(bc, 3)
|
|
531
|
+
break
|
|
532
|
+
}
|
|
533
|
+
case "KvDeleteResponse": {
|
|
534
|
+
bare.writeU8(bc, 4)
|
|
535
|
+
break
|
|
536
|
+
}
|
|
537
|
+
case "KvDropResponse": {
|
|
538
|
+
bare.writeU8(bc, 5)
|
|
539
|
+
break
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Core
|
|
546
|
+
*/
|
|
547
|
+
export enum StopCode {
|
|
548
|
+
Ok = "Ok",
|
|
549
|
+
Error = "Error",
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
export function readStopCode(bc: bare.ByteCursor): StopCode {
|
|
553
|
+
const offset = bc.offset
|
|
554
|
+
const tag = bare.readU8(bc)
|
|
555
|
+
switch (tag) {
|
|
556
|
+
case 0:
|
|
557
|
+
return StopCode.Ok
|
|
558
|
+
case 1:
|
|
559
|
+
return StopCode.Error
|
|
560
|
+
default: {
|
|
561
|
+
bc.offset = offset
|
|
562
|
+
throw new bare.BareError(offset, "invalid tag")
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
export function writeStopCode(bc: bare.ByteCursor, x: StopCode): void {
|
|
568
|
+
switch (x) {
|
|
569
|
+
case StopCode.Ok: {
|
|
570
|
+
bare.writeU8(bc, 0)
|
|
571
|
+
break
|
|
572
|
+
}
|
|
573
|
+
case StopCode.Error: {
|
|
574
|
+
bare.writeU8(bc, 1)
|
|
575
|
+
break
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
export type ActorName = {
|
|
581
|
+
readonly metadata: Json
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
export function readActorName(bc: bare.ByteCursor): ActorName {
|
|
585
|
+
return {
|
|
586
|
+
metadata: readJson(bc),
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
export function writeActorName(bc: bare.ByteCursor, x: ActorName): void {
|
|
591
|
+
writeJson(bc, x.metadata)
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
function read5(bc: bare.ByteCursor): string | null {
|
|
595
|
+
return bare.readBool(bc) ? bare.readString(bc) : null
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
function write5(bc: bare.ByteCursor, x: string | null): void {
|
|
599
|
+
bare.writeBool(bc, x != null)
|
|
600
|
+
if (x != null) {
|
|
601
|
+
bare.writeString(bc, x)
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
function read6(bc: bare.ByteCursor): ArrayBuffer | null {
|
|
606
|
+
return bare.readBool(bc) ? bare.readData(bc) : null
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
function write6(bc: bare.ByteCursor, x: ArrayBuffer | null): void {
|
|
610
|
+
bare.writeBool(bc, x != null)
|
|
611
|
+
if (x != null) {
|
|
612
|
+
bare.writeData(bc, x)
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
export type ActorConfig = {
|
|
617
|
+
readonly name: string
|
|
618
|
+
readonly key: string | null
|
|
619
|
+
readonly createTs: i64
|
|
620
|
+
readonly input: ArrayBuffer | null
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
export function readActorConfig(bc: bare.ByteCursor): ActorConfig {
|
|
624
|
+
return {
|
|
625
|
+
name: bare.readString(bc),
|
|
626
|
+
key: read5(bc),
|
|
627
|
+
createTs: bare.readI64(bc),
|
|
628
|
+
input: read6(bc),
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
export function writeActorConfig(bc: bare.ByteCursor, x: ActorConfig): void {
|
|
633
|
+
bare.writeString(bc, x.name)
|
|
634
|
+
write5(bc, x.key)
|
|
635
|
+
bare.writeI64(bc, x.createTs)
|
|
636
|
+
write6(bc, x.input)
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
export type ActorCheckpoint = {
|
|
640
|
+
readonly actorId: Id
|
|
641
|
+
readonly generation: u32
|
|
642
|
+
readonly index: i64
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
export function readActorCheckpoint(bc: bare.ByteCursor): ActorCheckpoint {
|
|
646
|
+
return {
|
|
647
|
+
actorId: readId(bc),
|
|
648
|
+
generation: bare.readU32(bc),
|
|
649
|
+
index: bare.readI64(bc),
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
export function writeActorCheckpoint(bc: bare.ByteCursor, x: ActorCheckpoint): void {
|
|
654
|
+
writeId(bc, x.actorId)
|
|
655
|
+
bare.writeU32(bc, x.generation)
|
|
656
|
+
bare.writeI64(bc, x.index)
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* Intent
|
|
661
|
+
*/
|
|
662
|
+
export type ActorIntentSleep = null
|
|
663
|
+
|
|
664
|
+
export type ActorIntentStop = null
|
|
665
|
+
|
|
666
|
+
export type ActorIntent =
|
|
667
|
+
| { readonly tag: "ActorIntentSleep"; readonly val: ActorIntentSleep }
|
|
668
|
+
| { readonly tag: "ActorIntentStop"; readonly val: ActorIntentStop }
|
|
669
|
+
|
|
670
|
+
export function readActorIntent(bc: bare.ByteCursor): ActorIntent {
|
|
671
|
+
const offset = bc.offset
|
|
672
|
+
const tag = bare.readU8(bc)
|
|
673
|
+
switch (tag) {
|
|
674
|
+
case 0:
|
|
675
|
+
return { tag: "ActorIntentSleep", val: null }
|
|
676
|
+
case 1:
|
|
677
|
+
return { tag: "ActorIntentStop", val: null }
|
|
678
|
+
default: {
|
|
679
|
+
bc.offset = offset
|
|
680
|
+
throw new bare.BareError(offset, "invalid tag")
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
export function writeActorIntent(bc: bare.ByteCursor, x: ActorIntent): void {
|
|
686
|
+
switch (x.tag) {
|
|
687
|
+
case "ActorIntentSleep": {
|
|
688
|
+
bare.writeU8(bc, 0)
|
|
689
|
+
break
|
|
690
|
+
}
|
|
691
|
+
case "ActorIntentStop": {
|
|
692
|
+
bare.writeU8(bc, 1)
|
|
693
|
+
break
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* State
|
|
700
|
+
*/
|
|
701
|
+
export type ActorStateRunning = null
|
|
702
|
+
|
|
703
|
+
export type ActorStateStopped = {
|
|
704
|
+
readonly code: StopCode
|
|
705
|
+
readonly message: string | null
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
export function readActorStateStopped(bc: bare.ByteCursor): ActorStateStopped {
|
|
709
|
+
return {
|
|
710
|
+
code: readStopCode(bc),
|
|
711
|
+
message: read5(bc),
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
export function writeActorStateStopped(bc: bare.ByteCursor, x: ActorStateStopped): void {
|
|
716
|
+
writeStopCode(bc, x.code)
|
|
717
|
+
write5(bc, x.message)
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
export type ActorState =
|
|
721
|
+
| { readonly tag: "ActorStateRunning"; readonly val: ActorStateRunning }
|
|
722
|
+
| { readonly tag: "ActorStateStopped"; readonly val: ActorStateStopped }
|
|
723
|
+
|
|
724
|
+
export function readActorState(bc: bare.ByteCursor): ActorState {
|
|
725
|
+
const offset = bc.offset
|
|
726
|
+
const tag = bare.readU8(bc)
|
|
727
|
+
switch (tag) {
|
|
728
|
+
case 0:
|
|
729
|
+
return { tag: "ActorStateRunning", val: null }
|
|
730
|
+
case 1:
|
|
731
|
+
return { tag: "ActorStateStopped", val: readActorStateStopped(bc) }
|
|
732
|
+
default: {
|
|
733
|
+
bc.offset = offset
|
|
734
|
+
throw new bare.BareError(offset, "invalid tag")
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
export function writeActorState(bc: bare.ByteCursor, x: ActorState): void {
|
|
740
|
+
switch (x.tag) {
|
|
741
|
+
case "ActorStateRunning": {
|
|
742
|
+
bare.writeU8(bc, 0)
|
|
743
|
+
break
|
|
744
|
+
}
|
|
745
|
+
case "ActorStateStopped": {
|
|
746
|
+
bare.writeU8(bc, 1)
|
|
747
|
+
writeActorStateStopped(bc, x.val)
|
|
748
|
+
break
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
/**
|
|
754
|
+
* MARK: Events
|
|
755
|
+
*/
|
|
756
|
+
export type EventActorIntent = {
|
|
757
|
+
readonly intent: ActorIntent
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
export function readEventActorIntent(bc: bare.ByteCursor): EventActorIntent {
|
|
761
|
+
return {
|
|
762
|
+
intent: readActorIntent(bc),
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
export function writeEventActorIntent(bc: bare.ByteCursor, x: EventActorIntent): void {
|
|
767
|
+
writeActorIntent(bc, x.intent)
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
export type EventActorStateUpdate = {
|
|
771
|
+
readonly state: ActorState
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
export function readEventActorStateUpdate(bc: bare.ByteCursor): EventActorStateUpdate {
|
|
775
|
+
return {
|
|
776
|
+
state: readActorState(bc),
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
export function writeEventActorStateUpdate(bc: bare.ByteCursor, x: EventActorStateUpdate): void {
|
|
781
|
+
writeActorState(bc, x.state)
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
function read7(bc: bare.ByteCursor): i64 | null {
|
|
785
|
+
return bare.readBool(bc) ? bare.readI64(bc) : null
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
function write7(bc: bare.ByteCursor, x: i64 | null): void {
|
|
789
|
+
bare.writeBool(bc, x != null)
|
|
790
|
+
if (x != null) {
|
|
791
|
+
bare.writeI64(bc, x)
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
export type EventActorSetAlarm = {
|
|
796
|
+
readonly alarmTs: i64 | null
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
export function readEventActorSetAlarm(bc: bare.ByteCursor): EventActorSetAlarm {
|
|
800
|
+
return {
|
|
801
|
+
alarmTs: read7(bc),
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
export function writeEventActorSetAlarm(bc: bare.ByteCursor, x: EventActorSetAlarm): void {
|
|
806
|
+
write7(bc, x.alarmTs)
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
export type Event =
|
|
810
|
+
| { readonly tag: "EventActorIntent"; readonly val: EventActorIntent }
|
|
811
|
+
| { readonly tag: "EventActorStateUpdate"; readonly val: EventActorStateUpdate }
|
|
812
|
+
| { readonly tag: "EventActorSetAlarm"; readonly val: EventActorSetAlarm }
|
|
813
|
+
|
|
814
|
+
export function readEvent(bc: bare.ByteCursor): Event {
|
|
815
|
+
const offset = bc.offset
|
|
816
|
+
const tag = bare.readU8(bc)
|
|
817
|
+
switch (tag) {
|
|
818
|
+
case 0:
|
|
819
|
+
return { tag: "EventActorIntent", val: readEventActorIntent(bc) }
|
|
820
|
+
case 1:
|
|
821
|
+
return { tag: "EventActorStateUpdate", val: readEventActorStateUpdate(bc) }
|
|
822
|
+
case 2:
|
|
823
|
+
return { tag: "EventActorSetAlarm", val: readEventActorSetAlarm(bc) }
|
|
824
|
+
default: {
|
|
825
|
+
bc.offset = offset
|
|
826
|
+
throw new bare.BareError(offset, "invalid tag")
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
export function writeEvent(bc: bare.ByteCursor, x: Event): void {
|
|
832
|
+
switch (x.tag) {
|
|
833
|
+
case "EventActorIntent": {
|
|
834
|
+
bare.writeU8(bc, 0)
|
|
835
|
+
writeEventActorIntent(bc, x.val)
|
|
836
|
+
break
|
|
837
|
+
}
|
|
838
|
+
case "EventActorStateUpdate": {
|
|
839
|
+
bare.writeU8(bc, 1)
|
|
840
|
+
writeEventActorStateUpdate(bc, x.val)
|
|
841
|
+
break
|
|
842
|
+
}
|
|
843
|
+
case "EventActorSetAlarm": {
|
|
844
|
+
bare.writeU8(bc, 2)
|
|
845
|
+
writeEventActorSetAlarm(bc, x.val)
|
|
846
|
+
break
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
export type EventWrapper = {
|
|
852
|
+
readonly checkpoint: ActorCheckpoint
|
|
853
|
+
readonly inner: Event
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
export function readEventWrapper(bc: bare.ByteCursor): EventWrapper {
|
|
857
|
+
return {
|
|
858
|
+
checkpoint: readActorCheckpoint(bc),
|
|
859
|
+
inner: readEvent(bc),
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
export function writeEventWrapper(bc: bare.ByteCursor, x: EventWrapper): void {
|
|
864
|
+
writeActorCheckpoint(bc, x.checkpoint)
|
|
865
|
+
writeEvent(bc, x.inner)
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
export type PreloadedKvEntry = {
|
|
869
|
+
readonly key: KvKey
|
|
870
|
+
readonly value: KvValue
|
|
871
|
+
readonly metadata: KvMetadata
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
export function readPreloadedKvEntry(bc: bare.ByteCursor): PreloadedKvEntry {
|
|
875
|
+
return {
|
|
876
|
+
key: readKvKey(bc),
|
|
877
|
+
value: readKvValue(bc),
|
|
878
|
+
metadata: readKvMetadata(bc),
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
export function writePreloadedKvEntry(bc: bare.ByteCursor, x: PreloadedKvEntry): void {
|
|
883
|
+
writeKvKey(bc, x.key)
|
|
884
|
+
writeKvValue(bc, x.value)
|
|
885
|
+
writeKvMetadata(bc, x.metadata)
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
function read8(bc: bare.ByteCursor): readonly PreloadedKvEntry[] {
|
|
889
|
+
const len = bare.readUintSafe(bc)
|
|
890
|
+
if (len === 0) {
|
|
891
|
+
return []
|
|
892
|
+
}
|
|
893
|
+
const result = [readPreloadedKvEntry(bc)]
|
|
894
|
+
for (let i = 1; i < len; i++) {
|
|
895
|
+
result[i] = readPreloadedKvEntry(bc)
|
|
896
|
+
}
|
|
897
|
+
return result
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
function write8(bc: bare.ByteCursor, x: readonly PreloadedKvEntry[]): void {
|
|
901
|
+
bare.writeUintSafe(bc, x.length)
|
|
902
|
+
for (let i = 0; i < x.length; i++) {
|
|
903
|
+
writePreloadedKvEntry(bc, x[i])
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
export type PreloadedKv = {
|
|
908
|
+
readonly entries: readonly PreloadedKvEntry[]
|
|
909
|
+
readonly requestedGetKeys: readonly KvKey[]
|
|
910
|
+
readonly requestedPrefixes: readonly KvKey[]
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
export function readPreloadedKv(bc: bare.ByteCursor): PreloadedKv {
|
|
914
|
+
return {
|
|
915
|
+
entries: read8(bc),
|
|
916
|
+
requestedGetKeys: read0(bc),
|
|
917
|
+
requestedPrefixes: read0(bc),
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
export function writePreloadedKv(bc: bare.ByteCursor, x: PreloadedKv): void {
|
|
922
|
+
write8(bc, x.entries)
|
|
923
|
+
write0(bc, x.requestedGetKeys)
|
|
924
|
+
write0(bc, x.requestedPrefixes)
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
export type HibernatingRequest = {
|
|
928
|
+
readonly gatewayId: GatewayId
|
|
929
|
+
readonly requestId: RequestId
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
export function readHibernatingRequest(bc: bare.ByteCursor): HibernatingRequest {
|
|
933
|
+
return {
|
|
934
|
+
gatewayId: readGatewayId(bc),
|
|
935
|
+
requestId: readRequestId(bc),
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
export function writeHibernatingRequest(bc: bare.ByteCursor, x: HibernatingRequest): void {
|
|
940
|
+
writeGatewayId(bc, x.gatewayId)
|
|
941
|
+
writeRequestId(bc, x.requestId)
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
function read9(bc: bare.ByteCursor): readonly HibernatingRequest[] {
|
|
945
|
+
const len = bare.readUintSafe(bc)
|
|
946
|
+
if (len === 0) {
|
|
947
|
+
return []
|
|
948
|
+
}
|
|
949
|
+
const result = [readHibernatingRequest(bc)]
|
|
950
|
+
for (let i = 1; i < len; i++) {
|
|
951
|
+
result[i] = readHibernatingRequest(bc)
|
|
952
|
+
}
|
|
953
|
+
return result
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
function write9(bc: bare.ByteCursor, x: readonly HibernatingRequest[]): void {
|
|
957
|
+
bare.writeUintSafe(bc, x.length)
|
|
958
|
+
for (let i = 0; i < x.length; i++) {
|
|
959
|
+
writeHibernatingRequest(bc, x[i])
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
function read10(bc: bare.ByteCursor): PreloadedKv | null {
|
|
964
|
+
return bare.readBool(bc) ? readPreloadedKv(bc) : null
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
function write10(bc: bare.ByteCursor, x: PreloadedKv | null): void {
|
|
968
|
+
bare.writeBool(bc, x != null)
|
|
969
|
+
if (x != null) {
|
|
970
|
+
writePreloadedKv(bc, x)
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
export type CommandStartActor = {
|
|
975
|
+
readonly config: ActorConfig
|
|
976
|
+
readonly hibernatingRequests: readonly HibernatingRequest[]
|
|
977
|
+
readonly preloadedKv: PreloadedKv | null
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
export function readCommandStartActor(bc: bare.ByteCursor): CommandStartActor {
|
|
981
|
+
return {
|
|
982
|
+
config: readActorConfig(bc),
|
|
983
|
+
hibernatingRequests: read9(bc),
|
|
984
|
+
preloadedKv: read10(bc),
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
export function writeCommandStartActor(bc: bare.ByteCursor, x: CommandStartActor): void {
|
|
989
|
+
writeActorConfig(bc, x.config)
|
|
990
|
+
write9(bc, x.hibernatingRequests)
|
|
991
|
+
write10(bc, x.preloadedKv)
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
export enum StopActorReason {
|
|
995
|
+
SleepIntent = "SleepIntent",
|
|
996
|
+
StopIntent = "StopIntent",
|
|
997
|
+
Destroy = "Destroy",
|
|
998
|
+
GoingAway = "GoingAway",
|
|
999
|
+
Lost = "Lost",
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
export function readStopActorReason(bc: bare.ByteCursor): StopActorReason {
|
|
1003
|
+
const offset = bc.offset
|
|
1004
|
+
const tag = bare.readU8(bc)
|
|
1005
|
+
switch (tag) {
|
|
1006
|
+
case 0:
|
|
1007
|
+
return StopActorReason.SleepIntent
|
|
1008
|
+
case 1:
|
|
1009
|
+
return StopActorReason.StopIntent
|
|
1010
|
+
case 2:
|
|
1011
|
+
return StopActorReason.Destroy
|
|
1012
|
+
case 3:
|
|
1013
|
+
return StopActorReason.GoingAway
|
|
1014
|
+
case 4:
|
|
1015
|
+
return StopActorReason.Lost
|
|
1016
|
+
default: {
|
|
1017
|
+
bc.offset = offset
|
|
1018
|
+
throw new bare.BareError(offset, "invalid tag")
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
export function writeStopActorReason(bc: bare.ByteCursor, x: StopActorReason): void {
|
|
1024
|
+
switch (x) {
|
|
1025
|
+
case StopActorReason.SleepIntent: {
|
|
1026
|
+
bare.writeU8(bc, 0)
|
|
1027
|
+
break
|
|
1028
|
+
}
|
|
1029
|
+
case StopActorReason.StopIntent: {
|
|
1030
|
+
bare.writeU8(bc, 1)
|
|
1031
|
+
break
|
|
1032
|
+
}
|
|
1033
|
+
case StopActorReason.Destroy: {
|
|
1034
|
+
bare.writeU8(bc, 2)
|
|
1035
|
+
break
|
|
1036
|
+
}
|
|
1037
|
+
case StopActorReason.GoingAway: {
|
|
1038
|
+
bare.writeU8(bc, 3)
|
|
1039
|
+
break
|
|
1040
|
+
}
|
|
1041
|
+
case StopActorReason.Lost: {
|
|
1042
|
+
bare.writeU8(bc, 4)
|
|
1043
|
+
break
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
export type CommandStopActor = {
|
|
1049
|
+
readonly reason: StopActorReason
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
export function readCommandStopActor(bc: bare.ByteCursor): CommandStopActor {
|
|
1053
|
+
return {
|
|
1054
|
+
reason: readStopActorReason(bc),
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
export function writeCommandStopActor(bc: bare.ByteCursor, x: CommandStopActor): void {
|
|
1059
|
+
writeStopActorReason(bc, x.reason)
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
export type Command =
|
|
1063
|
+
| { readonly tag: "CommandStartActor"; readonly val: CommandStartActor }
|
|
1064
|
+
| { readonly tag: "CommandStopActor"; readonly val: CommandStopActor }
|
|
1065
|
+
|
|
1066
|
+
export function readCommand(bc: bare.ByteCursor): Command {
|
|
1067
|
+
const offset = bc.offset
|
|
1068
|
+
const tag = bare.readU8(bc)
|
|
1069
|
+
switch (tag) {
|
|
1070
|
+
case 0:
|
|
1071
|
+
return { tag: "CommandStartActor", val: readCommandStartActor(bc) }
|
|
1072
|
+
case 1:
|
|
1073
|
+
return { tag: "CommandStopActor", val: readCommandStopActor(bc) }
|
|
1074
|
+
default: {
|
|
1075
|
+
bc.offset = offset
|
|
1076
|
+
throw new bare.BareError(offset, "invalid tag")
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
export function writeCommand(bc: bare.ByteCursor, x: Command): void {
|
|
1082
|
+
switch (x.tag) {
|
|
1083
|
+
case "CommandStartActor": {
|
|
1084
|
+
bare.writeU8(bc, 0)
|
|
1085
|
+
writeCommandStartActor(bc, x.val)
|
|
1086
|
+
break
|
|
1087
|
+
}
|
|
1088
|
+
case "CommandStopActor": {
|
|
1089
|
+
bare.writeU8(bc, 1)
|
|
1090
|
+
writeCommandStopActor(bc, x.val)
|
|
1091
|
+
break
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
export type CommandWrapper = {
|
|
1097
|
+
readonly checkpoint: ActorCheckpoint
|
|
1098
|
+
readonly inner: Command
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
export function readCommandWrapper(bc: bare.ByteCursor): CommandWrapper {
|
|
1102
|
+
return {
|
|
1103
|
+
checkpoint: readActorCheckpoint(bc),
|
|
1104
|
+
inner: readCommand(bc),
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
export function writeCommandWrapper(bc: bare.ByteCursor, x: CommandWrapper): void {
|
|
1109
|
+
writeActorCheckpoint(bc, x.checkpoint)
|
|
1110
|
+
writeCommand(bc, x.inner)
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
/**
|
|
1114
|
+
* We redeclare this so its top level
|
|
1115
|
+
*/
|
|
1116
|
+
export type ActorCommandKeyData =
|
|
1117
|
+
| { readonly tag: "CommandStartActor"; readonly val: CommandStartActor }
|
|
1118
|
+
| { readonly tag: "CommandStopActor"; readonly val: CommandStopActor }
|
|
1119
|
+
|
|
1120
|
+
export function readActorCommandKeyData(bc: bare.ByteCursor): ActorCommandKeyData {
|
|
1121
|
+
const offset = bc.offset
|
|
1122
|
+
const tag = bare.readU8(bc)
|
|
1123
|
+
switch (tag) {
|
|
1124
|
+
case 0:
|
|
1125
|
+
return { tag: "CommandStartActor", val: readCommandStartActor(bc) }
|
|
1126
|
+
case 1:
|
|
1127
|
+
return { tag: "CommandStopActor", val: readCommandStopActor(bc) }
|
|
1128
|
+
default: {
|
|
1129
|
+
bc.offset = offset
|
|
1130
|
+
throw new bare.BareError(offset, "invalid tag")
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
export function writeActorCommandKeyData(bc: bare.ByteCursor, x: ActorCommandKeyData): void {
|
|
1136
|
+
switch (x.tag) {
|
|
1137
|
+
case "CommandStartActor": {
|
|
1138
|
+
bare.writeU8(bc, 0)
|
|
1139
|
+
writeCommandStartActor(bc, x.val)
|
|
1140
|
+
break
|
|
1141
|
+
}
|
|
1142
|
+
case "CommandStopActor": {
|
|
1143
|
+
bare.writeU8(bc, 1)
|
|
1144
|
+
writeCommandStopActor(bc, x.val)
|
|
1145
|
+
break
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
export function encodeActorCommandKeyData(x: ActorCommandKeyData, config?: Partial<bare.Config>): Uint8Array {
|
|
1151
|
+
const fullConfig = config != null ? bare.Config(config) : DEFAULT_CONFIG
|
|
1152
|
+
const bc = new bare.ByteCursor(
|
|
1153
|
+
new Uint8Array(fullConfig.initialBufferLength),
|
|
1154
|
+
fullConfig,
|
|
1155
|
+
)
|
|
1156
|
+
writeActorCommandKeyData(bc, x)
|
|
1157
|
+
return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset)
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
export function decodeActorCommandKeyData(bytes: Uint8Array): ActorCommandKeyData {
|
|
1161
|
+
const bc = new bare.ByteCursor(bytes, DEFAULT_CONFIG)
|
|
1162
|
+
const result = readActorCommandKeyData(bc)
|
|
1163
|
+
if (bc.offset < bc.view.byteLength) {
|
|
1164
|
+
throw new bare.BareError(bc.offset, "remaining bytes")
|
|
1165
|
+
}
|
|
1166
|
+
return result
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
export type MessageId = {
|
|
1170
|
+
/**
|
|
1171
|
+
* Globally unique ID
|
|
1172
|
+
*/
|
|
1173
|
+
readonly gatewayId: GatewayId
|
|
1174
|
+
/**
|
|
1175
|
+
* Unique ID to the gateway
|
|
1176
|
+
*/
|
|
1177
|
+
readonly requestId: RequestId
|
|
1178
|
+
/**
|
|
1179
|
+
* Unique ID to the request
|
|
1180
|
+
*/
|
|
1181
|
+
readonly messageIndex: MessageIndex
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
export function readMessageId(bc: bare.ByteCursor): MessageId {
|
|
1185
|
+
return {
|
|
1186
|
+
gatewayId: readGatewayId(bc),
|
|
1187
|
+
requestId: readRequestId(bc),
|
|
1188
|
+
messageIndex: readMessageIndex(bc),
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
export function writeMessageId(bc: bare.ByteCursor, x: MessageId): void {
|
|
1193
|
+
writeGatewayId(bc, x.gatewayId)
|
|
1194
|
+
writeRequestId(bc, x.requestId)
|
|
1195
|
+
writeMessageIndex(bc, x.messageIndex)
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
function read11(bc: bare.ByteCursor): ReadonlyMap<string, string> {
|
|
1199
|
+
const len = bare.readUintSafe(bc)
|
|
1200
|
+
const result = new Map<string, string>()
|
|
1201
|
+
for (let i = 0; i < len; i++) {
|
|
1202
|
+
const offset = bc.offset
|
|
1203
|
+
const key = bare.readString(bc)
|
|
1204
|
+
if (result.has(key)) {
|
|
1205
|
+
bc.offset = offset
|
|
1206
|
+
throw new bare.BareError(offset, "duplicated key")
|
|
1207
|
+
}
|
|
1208
|
+
result.set(key, bare.readString(bc))
|
|
1209
|
+
}
|
|
1210
|
+
return result
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
function write11(bc: bare.ByteCursor, x: ReadonlyMap<string, string>): void {
|
|
1214
|
+
bare.writeUintSafe(bc, x.size)
|
|
1215
|
+
for (const kv of x) {
|
|
1216
|
+
bare.writeString(bc, kv[0])
|
|
1217
|
+
bare.writeString(bc, kv[1])
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
/**
|
|
1222
|
+
* HTTP
|
|
1223
|
+
*/
|
|
1224
|
+
export type ToEnvoyRequestStart = {
|
|
1225
|
+
readonly actorId: Id
|
|
1226
|
+
readonly method: string
|
|
1227
|
+
readonly path: string
|
|
1228
|
+
readonly headers: ReadonlyMap<string, string>
|
|
1229
|
+
readonly body: ArrayBuffer | null
|
|
1230
|
+
readonly stream: boolean
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
export function readToEnvoyRequestStart(bc: bare.ByteCursor): ToEnvoyRequestStart {
|
|
1234
|
+
return {
|
|
1235
|
+
actorId: readId(bc),
|
|
1236
|
+
method: bare.readString(bc),
|
|
1237
|
+
path: bare.readString(bc),
|
|
1238
|
+
headers: read11(bc),
|
|
1239
|
+
body: read6(bc),
|
|
1240
|
+
stream: bare.readBool(bc),
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
export function writeToEnvoyRequestStart(bc: bare.ByteCursor, x: ToEnvoyRequestStart): void {
|
|
1245
|
+
writeId(bc, x.actorId)
|
|
1246
|
+
bare.writeString(bc, x.method)
|
|
1247
|
+
bare.writeString(bc, x.path)
|
|
1248
|
+
write11(bc, x.headers)
|
|
1249
|
+
write6(bc, x.body)
|
|
1250
|
+
bare.writeBool(bc, x.stream)
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
export type ToEnvoyRequestChunk = {
|
|
1254
|
+
readonly body: ArrayBuffer
|
|
1255
|
+
readonly finish: boolean
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
export function readToEnvoyRequestChunk(bc: bare.ByteCursor): ToEnvoyRequestChunk {
|
|
1259
|
+
return {
|
|
1260
|
+
body: bare.readData(bc),
|
|
1261
|
+
finish: bare.readBool(bc),
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
export function writeToEnvoyRequestChunk(bc: bare.ByteCursor, x: ToEnvoyRequestChunk): void {
|
|
1266
|
+
bare.writeData(bc, x.body)
|
|
1267
|
+
bare.writeBool(bc, x.finish)
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
export type ToEnvoyRequestAbort = null
|
|
1271
|
+
|
|
1272
|
+
export type ToRivetResponseStart = {
|
|
1273
|
+
readonly status: u16
|
|
1274
|
+
readonly headers: ReadonlyMap<string, string>
|
|
1275
|
+
readonly body: ArrayBuffer | null
|
|
1276
|
+
readonly stream: boolean
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
export function readToRivetResponseStart(bc: bare.ByteCursor): ToRivetResponseStart {
|
|
1280
|
+
return {
|
|
1281
|
+
status: bare.readU16(bc),
|
|
1282
|
+
headers: read11(bc),
|
|
1283
|
+
body: read6(bc),
|
|
1284
|
+
stream: bare.readBool(bc),
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
export function writeToRivetResponseStart(bc: bare.ByteCursor, x: ToRivetResponseStart): void {
|
|
1289
|
+
bare.writeU16(bc, x.status)
|
|
1290
|
+
write11(bc, x.headers)
|
|
1291
|
+
write6(bc, x.body)
|
|
1292
|
+
bare.writeBool(bc, x.stream)
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
export type ToRivetResponseChunk = {
|
|
1296
|
+
readonly body: ArrayBuffer
|
|
1297
|
+
readonly finish: boolean
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
export function readToRivetResponseChunk(bc: bare.ByteCursor): ToRivetResponseChunk {
|
|
1301
|
+
return {
|
|
1302
|
+
body: bare.readData(bc),
|
|
1303
|
+
finish: bare.readBool(bc),
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
export function writeToRivetResponseChunk(bc: bare.ByteCursor, x: ToRivetResponseChunk): void {
|
|
1308
|
+
bare.writeData(bc, x.body)
|
|
1309
|
+
bare.writeBool(bc, x.finish)
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
export type ToRivetResponseAbort = null
|
|
1313
|
+
|
|
1314
|
+
/**
|
|
1315
|
+
* WebSocket
|
|
1316
|
+
*/
|
|
1317
|
+
export type ToEnvoyWebSocketOpen = {
|
|
1318
|
+
readonly actorId: Id
|
|
1319
|
+
readonly path: string
|
|
1320
|
+
readonly headers: ReadonlyMap<string, string>
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
export function readToEnvoyWebSocketOpen(bc: bare.ByteCursor): ToEnvoyWebSocketOpen {
|
|
1324
|
+
return {
|
|
1325
|
+
actorId: readId(bc),
|
|
1326
|
+
path: bare.readString(bc),
|
|
1327
|
+
headers: read11(bc),
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
export function writeToEnvoyWebSocketOpen(bc: bare.ByteCursor, x: ToEnvoyWebSocketOpen): void {
|
|
1332
|
+
writeId(bc, x.actorId)
|
|
1333
|
+
bare.writeString(bc, x.path)
|
|
1334
|
+
write11(bc, x.headers)
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
export type ToEnvoyWebSocketMessage = {
|
|
1338
|
+
readonly data: ArrayBuffer
|
|
1339
|
+
readonly binary: boolean
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
export function readToEnvoyWebSocketMessage(bc: bare.ByteCursor): ToEnvoyWebSocketMessage {
|
|
1343
|
+
return {
|
|
1344
|
+
data: bare.readData(bc),
|
|
1345
|
+
binary: bare.readBool(bc),
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
export function writeToEnvoyWebSocketMessage(bc: bare.ByteCursor, x: ToEnvoyWebSocketMessage): void {
|
|
1350
|
+
bare.writeData(bc, x.data)
|
|
1351
|
+
bare.writeBool(bc, x.binary)
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
function read12(bc: bare.ByteCursor): u16 | null {
|
|
1355
|
+
return bare.readBool(bc) ? bare.readU16(bc) : null
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
function write12(bc: bare.ByteCursor, x: u16 | null): void {
|
|
1359
|
+
bare.writeBool(bc, x != null)
|
|
1360
|
+
if (x != null) {
|
|
1361
|
+
bare.writeU16(bc, x)
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
export type ToEnvoyWebSocketClose = {
|
|
1366
|
+
readonly code: u16 | null
|
|
1367
|
+
readonly reason: string | null
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
export function readToEnvoyWebSocketClose(bc: bare.ByteCursor): ToEnvoyWebSocketClose {
|
|
1371
|
+
return {
|
|
1372
|
+
code: read12(bc),
|
|
1373
|
+
reason: read5(bc),
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
export function writeToEnvoyWebSocketClose(bc: bare.ByteCursor, x: ToEnvoyWebSocketClose): void {
|
|
1378
|
+
write12(bc, x.code)
|
|
1379
|
+
write5(bc, x.reason)
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
export type ToRivetWebSocketOpen = {
|
|
1383
|
+
readonly canHibernate: boolean
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
export function readToRivetWebSocketOpen(bc: bare.ByteCursor): ToRivetWebSocketOpen {
|
|
1387
|
+
return {
|
|
1388
|
+
canHibernate: bare.readBool(bc),
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
export function writeToRivetWebSocketOpen(bc: bare.ByteCursor, x: ToRivetWebSocketOpen): void {
|
|
1393
|
+
bare.writeBool(bc, x.canHibernate)
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
export type ToRivetWebSocketMessage = {
|
|
1397
|
+
readonly data: ArrayBuffer
|
|
1398
|
+
readonly binary: boolean
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
export function readToRivetWebSocketMessage(bc: bare.ByteCursor): ToRivetWebSocketMessage {
|
|
1402
|
+
return {
|
|
1403
|
+
data: bare.readData(bc),
|
|
1404
|
+
binary: bare.readBool(bc),
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
export function writeToRivetWebSocketMessage(bc: bare.ByteCursor, x: ToRivetWebSocketMessage): void {
|
|
1409
|
+
bare.writeData(bc, x.data)
|
|
1410
|
+
bare.writeBool(bc, x.binary)
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
export type ToRivetWebSocketMessageAck = {
|
|
1414
|
+
readonly index: MessageIndex
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
export function readToRivetWebSocketMessageAck(bc: bare.ByteCursor): ToRivetWebSocketMessageAck {
|
|
1418
|
+
return {
|
|
1419
|
+
index: readMessageIndex(bc),
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
export function writeToRivetWebSocketMessageAck(bc: bare.ByteCursor, x: ToRivetWebSocketMessageAck): void {
|
|
1424
|
+
writeMessageIndex(bc, x.index)
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
export type ToRivetWebSocketClose = {
|
|
1428
|
+
readonly code: u16 | null
|
|
1429
|
+
readonly reason: string | null
|
|
1430
|
+
readonly hibernate: boolean
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
export function readToRivetWebSocketClose(bc: bare.ByteCursor): ToRivetWebSocketClose {
|
|
1434
|
+
return {
|
|
1435
|
+
code: read12(bc),
|
|
1436
|
+
reason: read5(bc),
|
|
1437
|
+
hibernate: bare.readBool(bc),
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
export function writeToRivetWebSocketClose(bc: bare.ByteCursor, x: ToRivetWebSocketClose): void {
|
|
1442
|
+
write12(bc, x.code)
|
|
1443
|
+
write5(bc, x.reason)
|
|
1444
|
+
bare.writeBool(bc, x.hibernate)
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
/**
|
|
1448
|
+
* To Rivet
|
|
1449
|
+
*/
|
|
1450
|
+
export type ToRivetTunnelMessageKind =
|
|
1451
|
+
/**
|
|
1452
|
+
* HTTP
|
|
1453
|
+
*/
|
|
1454
|
+
| { readonly tag: "ToRivetResponseStart"; readonly val: ToRivetResponseStart }
|
|
1455
|
+
| { readonly tag: "ToRivetResponseChunk"; readonly val: ToRivetResponseChunk }
|
|
1456
|
+
| { readonly tag: "ToRivetResponseAbort"; readonly val: ToRivetResponseAbort }
|
|
1457
|
+
/**
|
|
1458
|
+
* WebSocket
|
|
1459
|
+
*/
|
|
1460
|
+
| { readonly tag: "ToRivetWebSocketOpen"; readonly val: ToRivetWebSocketOpen }
|
|
1461
|
+
| { readonly tag: "ToRivetWebSocketMessage"; readonly val: ToRivetWebSocketMessage }
|
|
1462
|
+
| { readonly tag: "ToRivetWebSocketMessageAck"; readonly val: ToRivetWebSocketMessageAck }
|
|
1463
|
+
| { readonly tag: "ToRivetWebSocketClose"; readonly val: ToRivetWebSocketClose }
|
|
1464
|
+
|
|
1465
|
+
export function readToRivetTunnelMessageKind(bc: bare.ByteCursor): ToRivetTunnelMessageKind {
|
|
1466
|
+
const offset = bc.offset
|
|
1467
|
+
const tag = bare.readU8(bc)
|
|
1468
|
+
switch (tag) {
|
|
1469
|
+
case 0:
|
|
1470
|
+
return { tag: "ToRivetResponseStart", val: readToRivetResponseStart(bc) }
|
|
1471
|
+
case 1:
|
|
1472
|
+
return { tag: "ToRivetResponseChunk", val: readToRivetResponseChunk(bc) }
|
|
1473
|
+
case 2:
|
|
1474
|
+
return { tag: "ToRivetResponseAbort", val: null }
|
|
1475
|
+
case 3:
|
|
1476
|
+
return { tag: "ToRivetWebSocketOpen", val: readToRivetWebSocketOpen(bc) }
|
|
1477
|
+
case 4:
|
|
1478
|
+
return { tag: "ToRivetWebSocketMessage", val: readToRivetWebSocketMessage(bc) }
|
|
1479
|
+
case 5:
|
|
1480
|
+
return { tag: "ToRivetWebSocketMessageAck", val: readToRivetWebSocketMessageAck(bc) }
|
|
1481
|
+
case 6:
|
|
1482
|
+
return { tag: "ToRivetWebSocketClose", val: readToRivetWebSocketClose(bc) }
|
|
1483
|
+
default: {
|
|
1484
|
+
bc.offset = offset
|
|
1485
|
+
throw new bare.BareError(offset, "invalid tag")
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
export function writeToRivetTunnelMessageKind(bc: bare.ByteCursor, x: ToRivetTunnelMessageKind): void {
|
|
1491
|
+
switch (x.tag) {
|
|
1492
|
+
case "ToRivetResponseStart": {
|
|
1493
|
+
bare.writeU8(bc, 0)
|
|
1494
|
+
writeToRivetResponseStart(bc, x.val)
|
|
1495
|
+
break
|
|
1496
|
+
}
|
|
1497
|
+
case "ToRivetResponseChunk": {
|
|
1498
|
+
bare.writeU8(bc, 1)
|
|
1499
|
+
writeToRivetResponseChunk(bc, x.val)
|
|
1500
|
+
break
|
|
1501
|
+
}
|
|
1502
|
+
case "ToRivetResponseAbort": {
|
|
1503
|
+
bare.writeU8(bc, 2)
|
|
1504
|
+
break
|
|
1505
|
+
}
|
|
1506
|
+
case "ToRivetWebSocketOpen": {
|
|
1507
|
+
bare.writeU8(bc, 3)
|
|
1508
|
+
writeToRivetWebSocketOpen(bc, x.val)
|
|
1509
|
+
break
|
|
1510
|
+
}
|
|
1511
|
+
case "ToRivetWebSocketMessage": {
|
|
1512
|
+
bare.writeU8(bc, 4)
|
|
1513
|
+
writeToRivetWebSocketMessage(bc, x.val)
|
|
1514
|
+
break
|
|
1515
|
+
}
|
|
1516
|
+
case "ToRivetWebSocketMessageAck": {
|
|
1517
|
+
bare.writeU8(bc, 5)
|
|
1518
|
+
writeToRivetWebSocketMessageAck(bc, x.val)
|
|
1519
|
+
break
|
|
1520
|
+
}
|
|
1521
|
+
case "ToRivetWebSocketClose": {
|
|
1522
|
+
bare.writeU8(bc, 6)
|
|
1523
|
+
writeToRivetWebSocketClose(bc, x.val)
|
|
1524
|
+
break
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
export type ToRivetTunnelMessage = {
|
|
1530
|
+
readonly messageId: MessageId
|
|
1531
|
+
readonly messageKind: ToRivetTunnelMessageKind
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
export function readToRivetTunnelMessage(bc: bare.ByteCursor): ToRivetTunnelMessage {
|
|
1535
|
+
return {
|
|
1536
|
+
messageId: readMessageId(bc),
|
|
1537
|
+
messageKind: readToRivetTunnelMessageKind(bc),
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1541
|
+
export function writeToRivetTunnelMessage(bc: bare.ByteCursor, x: ToRivetTunnelMessage): void {
|
|
1542
|
+
writeMessageId(bc, x.messageId)
|
|
1543
|
+
writeToRivetTunnelMessageKind(bc, x.messageKind)
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
/**
|
|
1547
|
+
* To Envoy
|
|
1548
|
+
*/
|
|
1549
|
+
export type ToEnvoyTunnelMessageKind =
|
|
1550
|
+
/**
|
|
1551
|
+
* HTTP
|
|
1552
|
+
*/
|
|
1553
|
+
| { readonly tag: "ToEnvoyRequestStart"; readonly val: ToEnvoyRequestStart }
|
|
1554
|
+
| { readonly tag: "ToEnvoyRequestChunk"; readonly val: ToEnvoyRequestChunk }
|
|
1555
|
+
| { readonly tag: "ToEnvoyRequestAbort"; readonly val: ToEnvoyRequestAbort }
|
|
1556
|
+
/**
|
|
1557
|
+
* WebSocket
|
|
1558
|
+
*/
|
|
1559
|
+
| { readonly tag: "ToEnvoyWebSocketOpen"; readonly val: ToEnvoyWebSocketOpen }
|
|
1560
|
+
| { readonly tag: "ToEnvoyWebSocketMessage"; readonly val: ToEnvoyWebSocketMessage }
|
|
1561
|
+
| { readonly tag: "ToEnvoyWebSocketClose"; readonly val: ToEnvoyWebSocketClose }
|
|
1562
|
+
|
|
1563
|
+
export function readToEnvoyTunnelMessageKind(bc: bare.ByteCursor): ToEnvoyTunnelMessageKind {
|
|
1564
|
+
const offset = bc.offset
|
|
1565
|
+
const tag = bare.readU8(bc)
|
|
1566
|
+
switch (tag) {
|
|
1567
|
+
case 0:
|
|
1568
|
+
return { tag: "ToEnvoyRequestStart", val: readToEnvoyRequestStart(bc) }
|
|
1569
|
+
case 1:
|
|
1570
|
+
return { tag: "ToEnvoyRequestChunk", val: readToEnvoyRequestChunk(bc) }
|
|
1571
|
+
case 2:
|
|
1572
|
+
return { tag: "ToEnvoyRequestAbort", val: null }
|
|
1573
|
+
case 3:
|
|
1574
|
+
return { tag: "ToEnvoyWebSocketOpen", val: readToEnvoyWebSocketOpen(bc) }
|
|
1575
|
+
case 4:
|
|
1576
|
+
return { tag: "ToEnvoyWebSocketMessage", val: readToEnvoyWebSocketMessage(bc) }
|
|
1577
|
+
case 5:
|
|
1578
|
+
return { tag: "ToEnvoyWebSocketClose", val: readToEnvoyWebSocketClose(bc) }
|
|
1579
|
+
default: {
|
|
1580
|
+
bc.offset = offset
|
|
1581
|
+
throw new bare.BareError(offset, "invalid tag")
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
export function writeToEnvoyTunnelMessageKind(bc: bare.ByteCursor, x: ToEnvoyTunnelMessageKind): void {
|
|
1587
|
+
switch (x.tag) {
|
|
1588
|
+
case "ToEnvoyRequestStart": {
|
|
1589
|
+
bare.writeU8(bc, 0)
|
|
1590
|
+
writeToEnvoyRequestStart(bc, x.val)
|
|
1591
|
+
break
|
|
1592
|
+
}
|
|
1593
|
+
case "ToEnvoyRequestChunk": {
|
|
1594
|
+
bare.writeU8(bc, 1)
|
|
1595
|
+
writeToEnvoyRequestChunk(bc, x.val)
|
|
1596
|
+
break
|
|
1597
|
+
}
|
|
1598
|
+
case "ToEnvoyRequestAbort": {
|
|
1599
|
+
bare.writeU8(bc, 2)
|
|
1600
|
+
break
|
|
1601
|
+
}
|
|
1602
|
+
case "ToEnvoyWebSocketOpen": {
|
|
1603
|
+
bare.writeU8(bc, 3)
|
|
1604
|
+
writeToEnvoyWebSocketOpen(bc, x.val)
|
|
1605
|
+
break
|
|
1606
|
+
}
|
|
1607
|
+
case "ToEnvoyWebSocketMessage": {
|
|
1608
|
+
bare.writeU8(bc, 4)
|
|
1609
|
+
writeToEnvoyWebSocketMessage(bc, x.val)
|
|
1610
|
+
break
|
|
1611
|
+
}
|
|
1612
|
+
case "ToEnvoyWebSocketClose": {
|
|
1613
|
+
bare.writeU8(bc, 5)
|
|
1614
|
+
writeToEnvoyWebSocketClose(bc, x.val)
|
|
1615
|
+
break
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
export type ToEnvoyTunnelMessage = {
|
|
1621
|
+
readonly messageId: MessageId
|
|
1622
|
+
readonly messageKind: ToEnvoyTunnelMessageKind
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1625
|
+
export function readToEnvoyTunnelMessage(bc: bare.ByteCursor): ToEnvoyTunnelMessage {
|
|
1626
|
+
return {
|
|
1627
|
+
messageId: readMessageId(bc),
|
|
1628
|
+
messageKind: readToEnvoyTunnelMessageKind(bc),
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1632
|
+
export function writeToEnvoyTunnelMessage(bc: bare.ByteCursor, x: ToEnvoyTunnelMessage): void {
|
|
1633
|
+
writeMessageId(bc, x.messageId)
|
|
1634
|
+
writeToEnvoyTunnelMessageKind(bc, x.messageKind)
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
export type ToEnvoyPing = {
|
|
1638
|
+
readonly ts: i64
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
export function readToEnvoyPing(bc: bare.ByteCursor): ToEnvoyPing {
|
|
1642
|
+
return {
|
|
1643
|
+
ts: bare.readI64(bc),
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
export function writeToEnvoyPing(bc: bare.ByteCursor, x: ToEnvoyPing): void {
|
|
1648
|
+
bare.writeI64(bc, x.ts)
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
function read13(bc: bare.ByteCursor): ReadonlyMap<string, ActorName> {
|
|
1652
|
+
const len = bare.readUintSafe(bc)
|
|
1653
|
+
const result = new Map<string, ActorName>()
|
|
1654
|
+
for (let i = 0; i < len; i++) {
|
|
1655
|
+
const offset = bc.offset
|
|
1656
|
+
const key = bare.readString(bc)
|
|
1657
|
+
if (result.has(key)) {
|
|
1658
|
+
bc.offset = offset
|
|
1659
|
+
throw new bare.BareError(offset, "duplicated key")
|
|
1660
|
+
}
|
|
1661
|
+
result.set(key, readActorName(bc))
|
|
1662
|
+
}
|
|
1663
|
+
return result
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
function write13(bc: bare.ByteCursor, x: ReadonlyMap<string, ActorName>): void {
|
|
1667
|
+
bare.writeUintSafe(bc, x.size)
|
|
1668
|
+
for (const kv of x) {
|
|
1669
|
+
bare.writeString(bc, kv[0])
|
|
1670
|
+
writeActorName(bc, kv[1])
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
function read14(bc: bare.ByteCursor): ReadonlyMap<string, ActorName> | null {
|
|
1675
|
+
return bare.readBool(bc) ? read13(bc) : null
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
function write14(bc: bare.ByteCursor, x: ReadonlyMap<string, ActorName> | null): void {
|
|
1679
|
+
bare.writeBool(bc, x != null)
|
|
1680
|
+
if (x != null) {
|
|
1681
|
+
write13(bc, x)
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
function read15(bc: bare.ByteCursor): Json | null {
|
|
1686
|
+
return bare.readBool(bc) ? readJson(bc) : null
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
function write15(bc: bare.ByteCursor, x: Json | null): void {
|
|
1690
|
+
bare.writeBool(bc, x != null)
|
|
1691
|
+
if (x != null) {
|
|
1692
|
+
writeJson(bc, x)
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
/**
|
|
1697
|
+
* MARK: To Rivet
|
|
1698
|
+
*/
|
|
1699
|
+
export type ToRivetInit = {
|
|
1700
|
+
readonly envoyKey: string
|
|
1701
|
+
readonly version: u32
|
|
1702
|
+
readonly prepopulateActorNames: ReadonlyMap<string, ActorName> | null
|
|
1703
|
+
readonly metadata: Json | null
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
export function readToRivetInit(bc: bare.ByteCursor): ToRivetInit {
|
|
1707
|
+
return {
|
|
1708
|
+
envoyKey: bare.readString(bc),
|
|
1709
|
+
version: bare.readU32(bc),
|
|
1710
|
+
prepopulateActorNames: read14(bc),
|
|
1711
|
+
metadata: read15(bc),
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
export function writeToRivetInit(bc: bare.ByteCursor, x: ToRivetInit): void {
|
|
1716
|
+
bare.writeString(bc, x.envoyKey)
|
|
1717
|
+
bare.writeU32(bc, x.version)
|
|
1718
|
+
write14(bc, x.prepopulateActorNames)
|
|
1719
|
+
write15(bc, x.metadata)
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
export type ToRivetEvents = readonly EventWrapper[]
|
|
1723
|
+
|
|
1724
|
+
export function readToRivetEvents(bc: bare.ByteCursor): ToRivetEvents {
|
|
1725
|
+
const len = bare.readUintSafe(bc)
|
|
1726
|
+
if (len === 0) {
|
|
1727
|
+
return []
|
|
1728
|
+
}
|
|
1729
|
+
const result = [readEventWrapper(bc)]
|
|
1730
|
+
for (let i = 1; i < len; i++) {
|
|
1731
|
+
result[i] = readEventWrapper(bc)
|
|
1732
|
+
}
|
|
1733
|
+
return result
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
export function writeToRivetEvents(bc: bare.ByteCursor, x: ToRivetEvents): void {
|
|
1737
|
+
bare.writeUintSafe(bc, x.length)
|
|
1738
|
+
for (let i = 0; i < x.length; i++) {
|
|
1739
|
+
writeEventWrapper(bc, x[i])
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
function read16(bc: bare.ByteCursor): readonly ActorCheckpoint[] {
|
|
1744
|
+
const len = bare.readUintSafe(bc)
|
|
1745
|
+
if (len === 0) {
|
|
1746
|
+
return []
|
|
1747
|
+
}
|
|
1748
|
+
const result = [readActorCheckpoint(bc)]
|
|
1749
|
+
for (let i = 1; i < len; i++) {
|
|
1750
|
+
result[i] = readActorCheckpoint(bc)
|
|
1751
|
+
}
|
|
1752
|
+
return result
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
function write16(bc: bare.ByteCursor, x: readonly ActorCheckpoint[]): void {
|
|
1756
|
+
bare.writeUintSafe(bc, x.length)
|
|
1757
|
+
for (let i = 0; i < x.length; i++) {
|
|
1758
|
+
writeActorCheckpoint(bc, x[i])
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
export type ToRivetAckCommands = {
|
|
1763
|
+
readonly lastCommandCheckpoints: readonly ActorCheckpoint[]
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
export function readToRivetAckCommands(bc: bare.ByteCursor): ToRivetAckCommands {
|
|
1767
|
+
return {
|
|
1768
|
+
lastCommandCheckpoints: read16(bc),
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
export function writeToRivetAckCommands(bc: bare.ByteCursor, x: ToRivetAckCommands): void {
|
|
1773
|
+
write16(bc, x.lastCommandCheckpoints)
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
export type ToRivetStopping = null
|
|
1777
|
+
|
|
1778
|
+
export type ToRivetPong = {
|
|
1779
|
+
readonly ts: i64
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1782
|
+
export function readToRivetPong(bc: bare.ByteCursor): ToRivetPong {
|
|
1783
|
+
return {
|
|
1784
|
+
ts: bare.readI64(bc),
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
export function writeToRivetPong(bc: bare.ByteCursor, x: ToRivetPong): void {
|
|
1789
|
+
bare.writeI64(bc, x.ts)
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
export type ToRivetKvRequest = {
|
|
1793
|
+
readonly actorId: Id
|
|
1794
|
+
readonly requestId: u32
|
|
1795
|
+
readonly data: KvRequestData
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1798
|
+
export function readToRivetKvRequest(bc: bare.ByteCursor): ToRivetKvRequest {
|
|
1799
|
+
return {
|
|
1800
|
+
actorId: readId(bc),
|
|
1801
|
+
requestId: bare.readU32(bc),
|
|
1802
|
+
data: readKvRequestData(bc),
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
export function writeToRivetKvRequest(bc: bare.ByteCursor, x: ToRivetKvRequest): void {
|
|
1807
|
+
writeId(bc, x.actorId)
|
|
1808
|
+
bare.writeU32(bc, x.requestId)
|
|
1809
|
+
writeKvRequestData(bc, x.data)
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1812
|
+
export type ToRivet =
|
|
1813
|
+
| { readonly tag: "ToRivetInit"; readonly val: ToRivetInit }
|
|
1814
|
+
| { readonly tag: "ToRivetEvents"; readonly val: ToRivetEvents }
|
|
1815
|
+
| { readonly tag: "ToRivetAckCommands"; readonly val: ToRivetAckCommands }
|
|
1816
|
+
| { readonly tag: "ToRivetStopping"; readonly val: ToRivetStopping }
|
|
1817
|
+
| { readonly tag: "ToRivetPong"; readonly val: ToRivetPong }
|
|
1818
|
+
| { readonly tag: "ToRivetKvRequest"; readonly val: ToRivetKvRequest }
|
|
1819
|
+
| { readonly tag: "ToRivetTunnelMessage"; readonly val: ToRivetTunnelMessage }
|
|
1820
|
+
|
|
1821
|
+
export function readToRivet(bc: bare.ByteCursor): ToRivet {
|
|
1822
|
+
const offset = bc.offset
|
|
1823
|
+
const tag = bare.readU8(bc)
|
|
1824
|
+
switch (tag) {
|
|
1825
|
+
case 0:
|
|
1826
|
+
return { tag: "ToRivetInit", val: readToRivetInit(bc) }
|
|
1827
|
+
case 1:
|
|
1828
|
+
return { tag: "ToRivetEvents", val: readToRivetEvents(bc) }
|
|
1829
|
+
case 2:
|
|
1830
|
+
return { tag: "ToRivetAckCommands", val: readToRivetAckCommands(bc) }
|
|
1831
|
+
case 3:
|
|
1832
|
+
return { tag: "ToRivetStopping", val: null }
|
|
1833
|
+
case 4:
|
|
1834
|
+
return { tag: "ToRivetPong", val: readToRivetPong(bc) }
|
|
1835
|
+
case 5:
|
|
1836
|
+
return { tag: "ToRivetKvRequest", val: readToRivetKvRequest(bc) }
|
|
1837
|
+
case 6:
|
|
1838
|
+
return { tag: "ToRivetTunnelMessage", val: readToRivetTunnelMessage(bc) }
|
|
1839
|
+
default: {
|
|
1840
|
+
bc.offset = offset
|
|
1841
|
+
throw new bare.BareError(offset, "invalid tag")
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1846
|
+
export function writeToRivet(bc: bare.ByteCursor, x: ToRivet): void {
|
|
1847
|
+
switch (x.tag) {
|
|
1848
|
+
case "ToRivetInit": {
|
|
1849
|
+
bare.writeU8(bc, 0)
|
|
1850
|
+
writeToRivetInit(bc, x.val)
|
|
1851
|
+
break
|
|
1852
|
+
}
|
|
1853
|
+
case "ToRivetEvents": {
|
|
1854
|
+
bare.writeU8(bc, 1)
|
|
1855
|
+
writeToRivetEvents(bc, x.val)
|
|
1856
|
+
break
|
|
1857
|
+
}
|
|
1858
|
+
case "ToRivetAckCommands": {
|
|
1859
|
+
bare.writeU8(bc, 2)
|
|
1860
|
+
writeToRivetAckCommands(bc, x.val)
|
|
1861
|
+
break
|
|
1862
|
+
}
|
|
1863
|
+
case "ToRivetStopping": {
|
|
1864
|
+
bare.writeU8(bc, 3)
|
|
1865
|
+
break
|
|
1866
|
+
}
|
|
1867
|
+
case "ToRivetPong": {
|
|
1868
|
+
bare.writeU8(bc, 4)
|
|
1869
|
+
writeToRivetPong(bc, x.val)
|
|
1870
|
+
break
|
|
1871
|
+
}
|
|
1872
|
+
case "ToRivetKvRequest": {
|
|
1873
|
+
bare.writeU8(bc, 5)
|
|
1874
|
+
writeToRivetKvRequest(bc, x.val)
|
|
1875
|
+
break
|
|
1876
|
+
}
|
|
1877
|
+
case "ToRivetTunnelMessage": {
|
|
1878
|
+
bare.writeU8(bc, 6)
|
|
1879
|
+
writeToRivetTunnelMessage(bc, x.val)
|
|
1880
|
+
break
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
export function encodeToRivet(x: ToRivet, config?: Partial<bare.Config>): Uint8Array {
|
|
1886
|
+
const fullConfig = config != null ? bare.Config(config) : DEFAULT_CONFIG
|
|
1887
|
+
const bc = new bare.ByteCursor(
|
|
1888
|
+
new Uint8Array(fullConfig.initialBufferLength),
|
|
1889
|
+
fullConfig,
|
|
1890
|
+
)
|
|
1891
|
+
writeToRivet(bc, x)
|
|
1892
|
+
return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset)
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
export function decodeToRivet(bytes: Uint8Array): ToRivet {
|
|
1896
|
+
const bc = new bare.ByteCursor(bytes, DEFAULT_CONFIG)
|
|
1897
|
+
const result = readToRivet(bc)
|
|
1898
|
+
if (bc.offset < bc.view.byteLength) {
|
|
1899
|
+
throw new bare.BareError(bc.offset, "remaining bytes")
|
|
1900
|
+
}
|
|
1901
|
+
return result
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
/**
|
|
1905
|
+
* MARK: To Envoy
|
|
1906
|
+
*/
|
|
1907
|
+
export type ProtocolMetadata = {
|
|
1908
|
+
readonly envoyLostThreshold: i64
|
|
1909
|
+
readonly actorStopThreshold: i64
|
|
1910
|
+
readonly serverlessDrainGracePeriod: i64 | null
|
|
1911
|
+
readonly maxResponsePayloadSize: u64
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
export function readProtocolMetadata(bc: bare.ByteCursor): ProtocolMetadata {
|
|
1915
|
+
return {
|
|
1916
|
+
envoyLostThreshold: bare.readI64(bc),
|
|
1917
|
+
actorStopThreshold: bare.readI64(bc),
|
|
1918
|
+
serverlessDrainGracePeriod: read7(bc),
|
|
1919
|
+
maxResponsePayloadSize: bare.readU64(bc),
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
export function writeProtocolMetadata(bc: bare.ByteCursor, x: ProtocolMetadata): void {
|
|
1924
|
+
bare.writeI64(bc, x.envoyLostThreshold)
|
|
1925
|
+
bare.writeI64(bc, x.actorStopThreshold)
|
|
1926
|
+
write7(bc, x.serverlessDrainGracePeriod)
|
|
1927
|
+
bare.writeU64(bc, x.maxResponsePayloadSize)
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1930
|
+
export type ToEnvoyInit = {
|
|
1931
|
+
readonly metadata: ProtocolMetadata
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1934
|
+
export function readToEnvoyInit(bc: bare.ByteCursor): ToEnvoyInit {
|
|
1935
|
+
return {
|
|
1936
|
+
metadata: readProtocolMetadata(bc),
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
export function writeToEnvoyInit(bc: bare.ByteCursor, x: ToEnvoyInit): void {
|
|
1941
|
+
writeProtocolMetadata(bc, x.metadata)
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1944
|
+
export type ToEnvoyCommands = readonly CommandWrapper[]
|
|
1945
|
+
|
|
1946
|
+
export function readToEnvoyCommands(bc: bare.ByteCursor): ToEnvoyCommands {
|
|
1947
|
+
const len = bare.readUintSafe(bc)
|
|
1948
|
+
if (len === 0) {
|
|
1949
|
+
return []
|
|
1950
|
+
}
|
|
1951
|
+
const result = [readCommandWrapper(bc)]
|
|
1952
|
+
for (let i = 1; i < len; i++) {
|
|
1953
|
+
result[i] = readCommandWrapper(bc)
|
|
1954
|
+
}
|
|
1955
|
+
return result
|
|
1956
|
+
}
|
|
1957
|
+
|
|
1958
|
+
export function writeToEnvoyCommands(bc: bare.ByteCursor, x: ToEnvoyCommands): void {
|
|
1959
|
+
bare.writeUintSafe(bc, x.length)
|
|
1960
|
+
for (let i = 0; i < x.length; i++) {
|
|
1961
|
+
writeCommandWrapper(bc, x[i])
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
|
|
1965
|
+
export type ToEnvoyAckEvents = {
|
|
1966
|
+
readonly lastEventCheckpoints: readonly ActorCheckpoint[]
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
export function readToEnvoyAckEvents(bc: bare.ByteCursor): ToEnvoyAckEvents {
|
|
1970
|
+
return {
|
|
1971
|
+
lastEventCheckpoints: read16(bc),
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
|
|
1975
|
+
export function writeToEnvoyAckEvents(bc: bare.ByteCursor, x: ToEnvoyAckEvents): void {
|
|
1976
|
+
write16(bc, x.lastEventCheckpoints)
|
|
1977
|
+
}
|
|
1978
|
+
|
|
1979
|
+
export type ToEnvoyKvResponse = {
|
|
1980
|
+
readonly requestId: u32
|
|
1981
|
+
readonly data: KvResponseData
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
export function readToEnvoyKvResponse(bc: bare.ByteCursor): ToEnvoyKvResponse {
|
|
1985
|
+
return {
|
|
1986
|
+
requestId: bare.readU32(bc),
|
|
1987
|
+
data: readKvResponseData(bc),
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
export function writeToEnvoyKvResponse(bc: bare.ByteCursor, x: ToEnvoyKvResponse): void {
|
|
1992
|
+
bare.writeU32(bc, x.requestId)
|
|
1993
|
+
writeKvResponseData(bc, x.data)
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
export type ToEnvoy =
|
|
1997
|
+
| { readonly tag: "ToEnvoyInit"; readonly val: ToEnvoyInit }
|
|
1998
|
+
| { readonly tag: "ToEnvoyCommands"; readonly val: ToEnvoyCommands }
|
|
1999
|
+
| { readonly tag: "ToEnvoyAckEvents"; readonly val: ToEnvoyAckEvents }
|
|
2000
|
+
| { readonly tag: "ToEnvoyKvResponse"; readonly val: ToEnvoyKvResponse }
|
|
2001
|
+
| { readonly tag: "ToEnvoyTunnelMessage"; readonly val: ToEnvoyTunnelMessage }
|
|
2002
|
+
| { readonly tag: "ToEnvoyPing"; readonly val: ToEnvoyPing }
|
|
2003
|
+
|
|
2004
|
+
export function readToEnvoy(bc: bare.ByteCursor): ToEnvoy {
|
|
2005
|
+
const offset = bc.offset
|
|
2006
|
+
const tag = bare.readU8(bc)
|
|
2007
|
+
switch (tag) {
|
|
2008
|
+
case 0:
|
|
2009
|
+
return { tag: "ToEnvoyInit", val: readToEnvoyInit(bc) }
|
|
2010
|
+
case 1:
|
|
2011
|
+
return { tag: "ToEnvoyCommands", val: readToEnvoyCommands(bc) }
|
|
2012
|
+
case 2:
|
|
2013
|
+
return { tag: "ToEnvoyAckEvents", val: readToEnvoyAckEvents(bc) }
|
|
2014
|
+
case 3:
|
|
2015
|
+
return { tag: "ToEnvoyKvResponse", val: readToEnvoyKvResponse(bc) }
|
|
2016
|
+
case 4:
|
|
2017
|
+
return { tag: "ToEnvoyTunnelMessage", val: readToEnvoyTunnelMessage(bc) }
|
|
2018
|
+
case 5:
|
|
2019
|
+
return { tag: "ToEnvoyPing", val: readToEnvoyPing(bc) }
|
|
2020
|
+
default: {
|
|
2021
|
+
bc.offset = offset
|
|
2022
|
+
throw new bare.BareError(offset, "invalid tag")
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2027
|
+
export function writeToEnvoy(bc: bare.ByteCursor, x: ToEnvoy): void {
|
|
2028
|
+
switch (x.tag) {
|
|
2029
|
+
case "ToEnvoyInit": {
|
|
2030
|
+
bare.writeU8(bc, 0)
|
|
2031
|
+
writeToEnvoyInit(bc, x.val)
|
|
2032
|
+
break
|
|
2033
|
+
}
|
|
2034
|
+
case "ToEnvoyCommands": {
|
|
2035
|
+
bare.writeU8(bc, 1)
|
|
2036
|
+
writeToEnvoyCommands(bc, x.val)
|
|
2037
|
+
break
|
|
2038
|
+
}
|
|
2039
|
+
case "ToEnvoyAckEvents": {
|
|
2040
|
+
bare.writeU8(bc, 2)
|
|
2041
|
+
writeToEnvoyAckEvents(bc, x.val)
|
|
2042
|
+
break
|
|
2043
|
+
}
|
|
2044
|
+
case "ToEnvoyKvResponse": {
|
|
2045
|
+
bare.writeU8(bc, 3)
|
|
2046
|
+
writeToEnvoyKvResponse(bc, x.val)
|
|
2047
|
+
break
|
|
2048
|
+
}
|
|
2049
|
+
case "ToEnvoyTunnelMessage": {
|
|
2050
|
+
bare.writeU8(bc, 4)
|
|
2051
|
+
writeToEnvoyTunnelMessage(bc, x.val)
|
|
2052
|
+
break
|
|
2053
|
+
}
|
|
2054
|
+
case "ToEnvoyPing": {
|
|
2055
|
+
bare.writeU8(bc, 5)
|
|
2056
|
+
writeToEnvoyPing(bc, x.val)
|
|
2057
|
+
break
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
|
|
2062
|
+
export function encodeToEnvoy(x: ToEnvoy, config?: Partial<bare.Config>): Uint8Array {
|
|
2063
|
+
const fullConfig = config != null ? bare.Config(config) : DEFAULT_CONFIG
|
|
2064
|
+
const bc = new bare.ByteCursor(
|
|
2065
|
+
new Uint8Array(fullConfig.initialBufferLength),
|
|
2066
|
+
fullConfig,
|
|
2067
|
+
)
|
|
2068
|
+
writeToEnvoy(bc, x)
|
|
2069
|
+
return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset)
|
|
2070
|
+
}
|
|
2071
|
+
|
|
2072
|
+
export function decodeToEnvoy(bytes: Uint8Array): ToEnvoy {
|
|
2073
|
+
const bc = new bare.ByteCursor(bytes, DEFAULT_CONFIG)
|
|
2074
|
+
const result = readToEnvoy(bc)
|
|
2075
|
+
if (bc.offset < bc.view.byteLength) {
|
|
2076
|
+
throw new bare.BareError(bc.offset, "remaining bytes")
|
|
2077
|
+
}
|
|
2078
|
+
return result
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
/**
|
|
2082
|
+
* MARK: To Envoy Conn
|
|
2083
|
+
*/
|
|
2084
|
+
export type ToEnvoyConnPing = {
|
|
2085
|
+
readonly gatewayId: GatewayId
|
|
2086
|
+
readonly requestId: RequestId
|
|
2087
|
+
readonly ts: i64
|
|
2088
|
+
}
|
|
2089
|
+
|
|
2090
|
+
export function readToEnvoyConnPing(bc: bare.ByteCursor): ToEnvoyConnPing {
|
|
2091
|
+
return {
|
|
2092
|
+
gatewayId: readGatewayId(bc),
|
|
2093
|
+
requestId: readRequestId(bc),
|
|
2094
|
+
ts: bare.readI64(bc),
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
|
|
2098
|
+
export function writeToEnvoyConnPing(bc: bare.ByteCursor, x: ToEnvoyConnPing): void {
|
|
2099
|
+
writeGatewayId(bc, x.gatewayId)
|
|
2100
|
+
writeRequestId(bc, x.requestId)
|
|
2101
|
+
bare.writeI64(bc, x.ts)
|
|
2102
|
+
}
|
|
2103
|
+
|
|
2104
|
+
export type ToEnvoyConnClose = null
|
|
2105
|
+
|
|
2106
|
+
export type ToEnvoyConn =
|
|
2107
|
+
| { readonly tag: "ToEnvoyConnPing"; readonly val: ToEnvoyConnPing }
|
|
2108
|
+
| { readonly tag: "ToEnvoyConnClose"; readonly val: ToEnvoyConnClose }
|
|
2109
|
+
| { readonly tag: "ToEnvoyCommands"; readonly val: ToEnvoyCommands }
|
|
2110
|
+
| { readonly tag: "ToEnvoyAckEvents"; readonly val: ToEnvoyAckEvents }
|
|
2111
|
+
| { readonly tag: "ToEnvoyTunnelMessage"; readonly val: ToEnvoyTunnelMessage }
|
|
2112
|
+
|
|
2113
|
+
export function readToEnvoyConn(bc: bare.ByteCursor): ToEnvoyConn {
|
|
2114
|
+
const offset = bc.offset
|
|
2115
|
+
const tag = bare.readU8(bc)
|
|
2116
|
+
switch (tag) {
|
|
2117
|
+
case 0:
|
|
2118
|
+
return { tag: "ToEnvoyConnPing", val: readToEnvoyConnPing(bc) }
|
|
2119
|
+
case 1:
|
|
2120
|
+
return { tag: "ToEnvoyConnClose", val: null }
|
|
2121
|
+
case 2:
|
|
2122
|
+
return { tag: "ToEnvoyCommands", val: readToEnvoyCommands(bc) }
|
|
2123
|
+
case 3:
|
|
2124
|
+
return { tag: "ToEnvoyAckEvents", val: readToEnvoyAckEvents(bc) }
|
|
2125
|
+
case 4:
|
|
2126
|
+
return { tag: "ToEnvoyTunnelMessage", val: readToEnvoyTunnelMessage(bc) }
|
|
2127
|
+
default: {
|
|
2128
|
+
bc.offset = offset
|
|
2129
|
+
throw new bare.BareError(offset, "invalid tag")
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
|
|
2134
|
+
export function writeToEnvoyConn(bc: bare.ByteCursor, x: ToEnvoyConn): void {
|
|
2135
|
+
switch (x.tag) {
|
|
2136
|
+
case "ToEnvoyConnPing": {
|
|
2137
|
+
bare.writeU8(bc, 0)
|
|
2138
|
+
writeToEnvoyConnPing(bc, x.val)
|
|
2139
|
+
break
|
|
2140
|
+
}
|
|
2141
|
+
case "ToEnvoyConnClose": {
|
|
2142
|
+
bare.writeU8(bc, 1)
|
|
2143
|
+
break
|
|
2144
|
+
}
|
|
2145
|
+
case "ToEnvoyCommands": {
|
|
2146
|
+
bare.writeU8(bc, 2)
|
|
2147
|
+
writeToEnvoyCommands(bc, x.val)
|
|
2148
|
+
break
|
|
2149
|
+
}
|
|
2150
|
+
case "ToEnvoyAckEvents": {
|
|
2151
|
+
bare.writeU8(bc, 3)
|
|
2152
|
+
writeToEnvoyAckEvents(bc, x.val)
|
|
2153
|
+
break
|
|
2154
|
+
}
|
|
2155
|
+
case "ToEnvoyTunnelMessage": {
|
|
2156
|
+
bare.writeU8(bc, 4)
|
|
2157
|
+
writeToEnvoyTunnelMessage(bc, x.val)
|
|
2158
|
+
break
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
2162
|
+
|
|
2163
|
+
export function encodeToEnvoyConn(x: ToEnvoyConn, config?: Partial<bare.Config>): Uint8Array {
|
|
2164
|
+
const fullConfig = config != null ? bare.Config(config) : DEFAULT_CONFIG
|
|
2165
|
+
const bc = new bare.ByteCursor(
|
|
2166
|
+
new Uint8Array(fullConfig.initialBufferLength),
|
|
2167
|
+
fullConfig,
|
|
2168
|
+
)
|
|
2169
|
+
writeToEnvoyConn(bc, x)
|
|
2170
|
+
return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset)
|
|
2171
|
+
}
|
|
2172
|
+
|
|
2173
|
+
export function decodeToEnvoyConn(bytes: Uint8Array): ToEnvoyConn {
|
|
2174
|
+
const bc = new bare.ByteCursor(bytes, DEFAULT_CONFIG)
|
|
2175
|
+
const result = readToEnvoyConn(bc)
|
|
2176
|
+
if (bc.offset < bc.view.byteLength) {
|
|
2177
|
+
throw new bare.BareError(bc.offset, "remaining bytes")
|
|
2178
|
+
}
|
|
2179
|
+
return result
|
|
2180
|
+
}
|
|
2181
|
+
|
|
2182
|
+
/**
|
|
2183
|
+
* MARK: To Gateway
|
|
2184
|
+
*/
|
|
2185
|
+
export type ToGatewayPong = {
|
|
2186
|
+
readonly requestId: RequestId
|
|
2187
|
+
readonly ts: i64
|
|
2188
|
+
}
|
|
2189
|
+
|
|
2190
|
+
export function readToGatewayPong(bc: bare.ByteCursor): ToGatewayPong {
|
|
2191
|
+
return {
|
|
2192
|
+
requestId: readRequestId(bc),
|
|
2193
|
+
ts: bare.readI64(bc),
|
|
2194
|
+
}
|
|
2195
|
+
}
|
|
2196
|
+
|
|
2197
|
+
export function writeToGatewayPong(bc: bare.ByteCursor, x: ToGatewayPong): void {
|
|
2198
|
+
writeRequestId(bc, x.requestId)
|
|
2199
|
+
bare.writeI64(bc, x.ts)
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
export type ToGateway =
|
|
2203
|
+
| { readonly tag: "ToGatewayPong"; readonly val: ToGatewayPong }
|
|
2204
|
+
| { readonly tag: "ToRivetTunnelMessage"; readonly val: ToRivetTunnelMessage }
|
|
2205
|
+
|
|
2206
|
+
export function readToGateway(bc: bare.ByteCursor): ToGateway {
|
|
2207
|
+
const offset = bc.offset
|
|
2208
|
+
const tag = bare.readU8(bc)
|
|
2209
|
+
switch (tag) {
|
|
2210
|
+
case 0:
|
|
2211
|
+
return { tag: "ToGatewayPong", val: readToGatewayPong(bc) }
|
|
2212
|
+
case 1:
|
|
2213
|
+
return { tag: "ToRivetTunnelMessage", val: readToRivetTunnelMessage(bc) }
|
|
2214
|
+
default: {
|
|
2215
|
+
bc.offset = offset
|
|
2216
|
+
throw new bare.BareError(offset, "invalid tag")
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
|
|
2221
|
+
export function writeToGateway(bc: bare.ByteCursor, x: ToGateway): void {
|
|
2222
|
+
switch (x.tag) {
|
|
2223
|
+
case "ToGatewayPong": {
|
|
2224
|
+
bare.writeU8(bc, 0)
|
|
2225
|
+
writeToGatewayPong(bc, x.val)
|
|
2226
|
+
break
|
|
2227
|
+
}
|
|
2228
|
+
case "ToRivetTunnelMessage": {
|
|
2229
|
+
bare.writeU8(bc, 1)
|
|
2230
|
+
writeToRivetTunnelMessage(bc, x.val)
|
|
2231
|
+
break
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2236
|
+
export function encodeToGateway(x: ToGateway, config?: Partial<bare.Config>): Uint8Array {
|
|
2237
|
+
const fullConfig = config != null ? bare.Config(config) : DEFAULT_CONFIG
|
|
2238
|
+
const bc = new bare.ByteCursor(
|
|
2239
|
+
new Uint8Array(fullConfig.initialBufferLength),
|
|
2240
|
+
fullConfig,
|
|
2241
|
+
)
|
|
2242
|
+
writeToGateway(bc, x)
|
|
2243
|
+
return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset)
|
|
2244
|
+
}
|
|
2245
|
+
|
|
2246
|
+
export function decodeToGateway(bytes: Uint8Array): ToGateway {
|
|
2247
|
+
const bc = new bare.ByteCursor(bytes, DEFAULT_CONFIG)
|
|
2248
|
+
const result = readToGateway(bc)
|
|
2249
|
+
if (bc.offset < bc.view.byteLength) {
|
|
2250
|
+
throw new bare.BareError(bc.offset, "remaining bytes")
|
|
2251
|
+
}
|
|
2252
|
+
return result
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2255
|
+
/**
|
|
2256
|
+
* MARK: To Outbound
|
|
2257
|
+
*/
|
|
2258
|
+
export type ToOutboundActorStart = {
|
|
2259
|
+
readonly namespaceId: Id
|
|
2260
|
+
readonly poolName: string
|
|
2261
|
+
readonly checkpoint: ActorCheckpoint
|
|
2262
|
+
readonly actorConfig: ActorConfig
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
export function readToOutboundActorStart(bc: bare.ByteCursor): ToOutboundActorStart {
|
|
2266
|
+
return {
|
|
2267
|
+
namespaceId: readId(bc),
|
|
2268
|
+
poolName: bare.readString(bc),
|
|
2269
|
+
checkpoint: readActorCheckpoint(bc),
|
|
2270
|
+
actorConfig: readActorConfig(bc),
|
|
2271
|
+
}
|
|
2272
|
+
}
|
|
2273
|
+
|
|
2274
|
+
export function writeToOutboundActorStart(bc: bare.ByteCursor, x: ToOutboundActorStart): void {
|
|
2275
|
+
writeId(bc, x.namespaceId)
|
|
2276
|
+
bare.writeString(bc, x.poolName)
|
|
2277
|
+
writeActorCheckpoint(bc, x.checkpoint)
|
|
2278
|
+
writeActorConfig(bc, x.actorConfig)
|
|
2279
|
+
}
|
|
2280
|
+
|
|
2281
|
+
export type ToOutbound =
|
|
2282
|
+
| { readonly tag: "ToOutboundActorStart"; readonly val: ToOutboundActorStart }
|
|
2283
|
+
|
|
2284
|
+
export function readToOutbound(bc: bare.ByteCursor): ToOutbound {
|
|
2285
|
+
const offset = bc.offset
|
|
2286
|
+
const tag = bare.readU8(bc)
|
|
2287
|
+
switch (tag) {
|
|
2288
|
+
case 0:
|
|
2289
|
+
return { tag: "ToOutboundActorStart", val: readToOutboundActorStart(bc) }
|
|
2290
|
+
default: {
|
|
2291
|
+
bc.offset = offset
|
|
2292
|
+
throw new bare.BareError(offset, "invalid tag")
|
|
2293
|
+
}
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2296
|
+
|
|
2297
|
+
export function writeToOutbound(bc: bare.ByteCursor, x: ToOutbound): void {
|
|
2298
|
+
switch (x.tag) {
|
|
2299
|
+
case "ToOutboundActorStart": {
|
|
2300
|
+
bare.writeU8(bc, 0)
|
|
2301
|
+
writeToOutboundActorStart(bc, x.val)
|
|
2302
|
+
break
|
|
2303
|
+
}
|
|
2304
|
+
}
|
|
2305
|
+
}
|
|
2306
|
+
|
|
2307
|
+
export function encodeToOutbound(x: ToOutbound, config?: Partial<bare.Config>): Uint8Array {
|
|
2308
|
+
const fullConfig = config != null ? bare.Config(config) : DEFAULT_CONFIG
|
|
2309
|
+
const bc = new bare.ByteCursor(
|
|
2310
|
+
new Uint8Array(fullConfig.initialBufferLength),
|
|
2311
|
+
fullConfig,
|
|
2312
|
+
)
|
|
2313
|
+
writeToOutbound(bc, x)
|
|
2314
|
+
return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset)
|
|
2315
|
+
}
|
|
2316
|
+
|
|
2317
|
+
export function decodeToOutbound(bytes: Uint8Array): ToOutbound {
|
|
2318
|
+
const bc = new bare.ByteCursor(bytes, DEFAULT_CONFIG)
|
|
2319
|
+
const result = readToOutbound(bc)
|
|
2320
|
+
if (bc.offset < bc.view.byteLength) {
|
|
2321
|
+
throw new bare.BareError(bc.offset, "remaining bytes")
|
|
2322
|
+
}
|
|
2323
|
+
return result
|
|
2324
|
+
}
|
|
2325
|
+
|
|
2326
|
+
|
|
2327
|
+
function assert(condition: boolean, message?: string): asserts condition {
|
|
2328
|
+
if (!condition) throw new Error(message ?? "Assertion failed")
|
|
2329
|
+
}
|
|
2330
|
+
|
|
2331
|
+
export const VERSION = 1;
|