@rivetkit/engine 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +203 -0
- package/artifacts/errors/actor.destroyed_during_creation.json +5 -0
- package/artifacts/errors/actor.destroyed_while_waiting_for_ready.json +5 -0
- package/artifacts/errors/actor.duplicate_key.json +5 -0
- package/artifacts/errors/actor.empty_key.json +5 -0
- package/artifacts/errors/actor.input_too_large.json +5 -0
- package/artifacts/errors/actor.key_reserved_in_different_datacenter.json +5 -0
- package/artifacts/errors/actor.key_too_large.json +5 -0
- package/artifacts/errors/actor.kv_key_not_found.json +5 -0
- package/artifacts/errors/actor.namespace_not_found.json +5 -0
- package/artifacts/errors/actor.no_runners_available.json +5 -0
- package/artifacts/errors/actor.not_found.json +5 -0
- package/artifacts/errors/api.bad_request.json +5 -0
- package/artifacts/errors/api.forbidden.json +5 -0
- package/artifacts/errors/api.internal_error.json +5 -0
- package/artifacts/errors/api.not_found.json +5 -0
- package/artifacts/errors/api.rate_limited.json +5 -0
- package/artifacts/errors/api.unauthorized.json +5 -0
- package/artifacts/errors/datacenter.not_found.json +5 -0
- package/artifacts/errors/guard.actor_destroyed.json +5 -0
- package/artifacts/errors/guard.actor_not_found.json +5 -0
- package/artifacts/errors/guard.actor_ready_timeout.json +5 -0
- package/artifacts/errors/guard.connection_error.json +5 -0
- package/artifacts/errors/guard.http_request_build_failed.json +5 -0
- package/artifacts/errors/guard.missing_header.json +5 -0
- package/artifacts/errors/guard.must_use_regional_host.json +5 -0
- package/artifacts/errors/guard.no_route.json +5 -0
- package/artifacts/errors/guard.no_route_targets.json +5 -0
- package/artifacts/errors/guard.rate_limit.json +5 -0
- package/artifacts/errors/guard.request_build_error.json +5 -0
- package/artifacts/errors/guard.request_timeout.json +5 -0
- package/artifacts/errors/guard.retry_attempts_exceeded.json +5 -0
- package/artifacts/errors/guard.service_unavailable.json +5 -0
- package/artifacts/errors/guard.target_changed.json +5 -0
- package/artifacts/errors/guard.upstream_error.json +5 -0
- package/artifacts/errors/guard.uri_parse_error.json +5 -0
- package/artifacts/errors/guard.websocket_pending_limit_reached.json +5 -0
- package/artifacts/errors/guard.websocket_service_hibernate.json +5 -0
- package/artifacts/errors/guard.websocket_service_timeout.json +5 -0
- package/artifacts/errors/guard.websocket_service_unavailable.json +5 -0
- package/artifacts/errors/guard.wrong_addr_protocol.json +5 -0
- package/artifacts/errors/kv.leader_forwarding_failed.json +5 -0
- package/artifacts/errors/kv.no_leader_elected.json +5 -0
- package/artifacts/errors/kv.not_leader.json +5 -0
- package/artifacts/errors/kv.response_channel_closed.json +5 -0
- package/artifacts/errors/namespace.failed_to_create.json +5 -0
- package/artifacts/errors/namespace.invalid_name.json +5 -0
- package/artifacts/errors/namespace.invalid_update.json +5 -0
- package/artifacts/errors/namespace.name_not_unique.json +5 -0
- package/artifacts/errors/namespace.not_found.json +5 -0
- package/artifacts/errors/namespace.not_leader.json +5 -0
- package/artifacts/errors/runner.not_found.json +5 -0
- package/artifacts/errors/runner_config.invalid.json +5 -0
- package/artifacts/errors/runner_config.not_found.json +5 -0
- package/artifacts/errors/test.input_too_large.json +5 -0
- package/artifacts/errors/test.key_too_large.json +5 -0
- package/artifacts/errors/test.meta_error.json +5 -0
- package/artifacts/errors/test.not_found.json +5 -0
- package/artifacts/errors/test.simple_error.json +5 -0
- package/artifacts/errors/test.test_error.json +5 -0
- package/artifacts/errors/ups.publish_failed.json +5 -0
- package/artifacts/errors/ups.request_timeout.json +5 -0
- package/artifacts/errors/validation.invalid_input.json +5 -0
- package/artifacts/errors/validation.no_keys.json +5 -0
- package/artifacts/errors/validation.race_condition.json +5 -0
- package/artifacts/errors/validation.too_many_actor_ids.json +5 -0
- package/artifacts/errors/ws.connection_closed.json +5 -0
- package/artifacts/errors/ws.eviction.json +5 -0
- package/artifacts/errors/ws.invalid_initial_packet.json +5 -0
- package/artifacts/errors/ws.invalid_packet.json +5 -0
- package/artifacts/errors/ws.invalid_url.json +5 -0
- package/artifacts/errors/ws.timed_out_waiting_for_init.json +5 -0
- package/artifacts/openapi.json +1833 -0
- package/contrib-docs/ACTOR_KEY_RESERVATION.md +101 -0
- package/contrib-docs/API.md +11 -0
- package/contrib-docs/DOCKER.md +5 -0
- package/contrib-docs/ERRORS.md +13 -0
- package/contrib-docs/GUARD.md +76 -0
- package/contrib-docs/PEGBOARD_TUNNEL_RETRIES.md +83 -0
- package/contrib-docs/RUNNER_LIFECYCLE.md +172 -0
- package/contrib-docs/SDKS.md +9 -0
- package/contrib-docs/TEST_DEPENDENCIES.md +43 -0
- package/contrib-docs/design-choicse/EMBEDDED_KV.md +80 -0
- package/contrib-docs/operate/TRACING_RECONFIGURE.md +78 -0
- package/docker/dev/.gitattributes +1 -0
- package/docker/dev/README.md +74 -0
- package/docker/dev/clickhouse/client-config.xml +5 -0
- package/docker/dev/clickhouse/config.xml +52 -0
- package/docker/dev/clickhouse/init/01-create-otel-table.sql +107 -0
- package/docker/dev/clickhouse/users.xml +35 -0
- package/docker/dev/docker-compose.yml +217 -0
- package/docker/dev/grafana/dashboards/api.json +1240 -0
- package/docker/dev/grafana/dashboards/cache.json +1075 -0
- package/docker/dev/grafana/dashboards/futures.json +230 -0
- package/docker/dev/grafana/dashboards/gasoline.json +2477 -0
- package/docker/dev/grafana/dashboards/guard.json +1274 -0
- package/docker/dev/grafana/dashboards/tokio.json +1005 -0
- package/docker/dev/grafana/dashboards/traces.json +957 -0
- package/docker/dev/grafana/grafana.ini +14 -0
- package/docker/dev/grafana/provisioning/dashboards/dashboards.yaml +10 -0
- package/docker/dev/grafana/provisioning/datasources/datasources.yaml +30 -0
- package/docker/dev/otel-collector-client/config.yaml +39 -0
- package/docker/dev/otel-collector-server/config.yaml +72 -0
- package/docker/dev/postgres/init-db.sh +6 -0
- package/docker/dev/rivet-engine/config.jsonc +48 -0
- package/docker/dev/vector-client/vector.yaml +31 -0
- package/docker/dev/vector-server/vector.yaml +61 -0
- package/docker/dev-host/.gitattributes +1 -0
- package/docker/dev-host/README.md +74 -0
- package/docker/dev-host/clickhouse/client-config.xml +5 -0
- package/docker/dev-host/clickhouse/config.xml +52 -0
- package/docker/dev-host/clickhouse/init/01-create-otel-table.sql +107 -0
- package/docker/dev-host/clickhouse/users.xml +35 -0
- package/docker/dev-host/docker-compose.yml +190 -0
- package/docker/dev-host/grafana/dashboards/api.json +1240 -0
- package/docker/dev-host/grafana/dashboards/cache.json +1075 -0
- package/docker/dev-host/grafana/dashboards/futures.json +230 -0
- package/docker/dev-host/grafana/dashboards/gasoline.json +2477 -0
- package/docker/dev-host/grafana/dashboards/guard.json +1274 -0
- package/docker/dev-host/grafana/dashboards/tokio.json +1005 -0
- package/docker/dev-host/grafana/dashboards/traces.json +957 -0
- package/docker/dev-host/grafana/grafana.ini +14 -0
- package/docker/dev-host/grafana/provisioning/dashboards/dashboards.yaml +10 -0
- package/docker/dev-host/grafana/provisioning/datasources/datasources.yaml +30 -0
- package/docker/dev-host/otel-collector-client/config.yaml +39 -0
- package/docker/dev-host/otel-collector-server/config.yaml +72 -0
- package/docker/dev-host/postgres/init-db.sh +6 -0
- package/docker/dev-host/rivet-engine/config.jsonc +48 -0
- package/docker/dev-host/vector-client/vector.yaml +31 -0
- package/docker/dev-host/vector-server/vector.yaml +61 -0
- package/docker/dev-multidc/.gitattributes +1 -0
- package/docker/dev-multidc/README.md +86 -0
- package/docker/dev-multidc/core/clickhouse/client-config.xml +5 -0
- package/docker/dev-multidc/core/clickhouse/config.xml +52 -0
- package/docker/dev-multidc/core/clickhouse/init/01-create-otel-table.sql +107 -0
- package/docker/dev-multidc/core/clickhouse/users.xml +35 -0
- package/docker/dev-multidc/core/grafana/dashboards/api.json +1240 -0
- package/docker/dev-multidc/core/grafana/dashboards/cache.json +1075 -0
- package/docker/dev-multidc/core/grafana/dashboards/futures.json +230 -0
- package/docker/dev-multidc/core/grafana/dashboards/gasoline.json +2477 -0
- package/docker/dev-multidc/core/grafana/dashboards/guard.json +1274 -0
- package/docker/dev-multidc/core/grafana/dashboards/tokio.json +1005 -0
- package/docker/dev-multidc/core/grafana/dashboards/traces.json +957 -0
- package/docker/dev-multidc/core/grafana/grafana.ini +14 -0
- package/docker/dev-multidc/core/grafana/provisioning/dashboards/dashboards.yaml +10 -0
- package/docker/dev-multidc/core/grafana/provisioning/datasources/datasources.yaml +30 -0
- package/docker/dev-multidc/datacenters/dc-a/otel-collector-client/config.yaml +39 -0
- package/docker/dev-multidc/datacenters/dc-a/otel-collector-server/config.yaml +72 -0
- package/docker/dev-multidc/datacenters/dc-a/postgres/init-db.sh +6 -0
- package/docker/dev-multidc/datacenters/dc-a/rivet-engine/config.jsonc +62 -0
- package/docker/dev-multidc/datacenters/dc-a/vector-client/vector.yaml +31 -0
- package/docker/dev-multidc/datacenters/dc-a/vector-server/vector.yaml +61 -0
- package/docker/dev-multidc/datacenters/dc-b/otel-collector-client/config.yaml +39 -0
- package/docker/dev-multidc/datacenters/dc-b/otel-collector-server/config.yaml +72 -0
- package/docker/dev-multidc/datacenters/dc-b/postgres/init-db.sh +6 -0
- package/docker/dev-multidc/datacenters/dc-b/rivet-engine/config.jsonc +62 -0
- package/docker/dev-multidc/datacenters/dc-b/vector-client/vector.yaml +31 -0
- package/docker/dev-multidc/datacenters/dc-b/vector-server/vector.yaml +61 -0
- package/docker/dev-multidc/datacenters/dc-c/otel-collector-client/config.yaml +39 -0
- package/docker/dev-multidc/datacenters/dc-c/otel-collector-server/config.yaml +72 -0
- package/docker/dev-multidc/datacenters/dc-c/postgres/init-db.sh +6 -0
- package/docker/dev-multidc/datacenters/dc-c/rivet-engine/config.jsonc +62 -0
- package/docker/dev-multidc/datacenters/dc-c/vector-client/vector.yaml +31 -0
- package/docker/dev-multidc/datacenters/dc-c/vector-server/vector.yaml +61 -0
- package/docker/dev-multidc/docker-compose.yml +546 -0
- package/docker/dev-multidc-multinode/.gitattributes +1 -0
- package/docker/dev-multidc-multinode/README.md +86 -0
- package/docker/dev-multidc-multinode/core/clickhouse/client-config.xml +5 -0
- package/docker/dev-multidc-multinode/core/clickhouse/config.xml +52 -0
- package/docker/dev-multidc-multinode/core/clickhouse/init/01-create-otel-table.sql +107 -0
- package/docker/dev-multidc-multinode/core/clickhouse/users.xml +35 -0
- package/docker/dev-multidc-multinode/core/grafana/dashboards/api.json +1240 -0
- package/docker/dev-multidc-multinode/core/grafana/dashboards/cache.json +1075 -0
- package/docker/dev-multidc-multinode/core/grafana/dashboards/futures.json +230 -0
- package/docker/dev-multidc-multinode/core/grafana/dashboards/gasoline.json +2477 -0
- package/docker/dev-multidc-multinode/core/grafana/dashboards/guard.json +1274 -0
- package/docker/dev-multidc-multinode/core/grafana/dashboards/tokio.json +1005 -0
- package/docker/dev-multidc-multinode/core/grafana/dashboards/traces.json +957 -0
- package/docker/dev-multidc-multinode/core/grafana/grafana.ini +14 -0
- package/docker/dev-multidc-multinode/core/grafana/provisioning/dashboards/dashboards.yaml +10 -0
- package/docker/dev-multidc-multinode/core/grafana/provisioning/datasources/datasources.yaml +30 -0
- package/docker/dev-multidc-multinode/datacenters/dc-a/otel-collector-client/config.yaml +39 -0
- package/docker/dev-multidc-multinode/datacenters/dc-a/otel-collector-server/config.yaml +72 -0
- package/docker/dev-multidc-multinode/datacenters/dc-a/postgres/init-db.sh +6 -0
- package/docker/dev-multidc-multinode/datacenters/dc-a/rivet-engine/0/config.jsonc +62 -0
- package/docker/dev-multidc-multinode/datacenters/dc-a/rivet-engine/1/config.jsonc +62 -0
- package/docker/dev-multidc-multinode/datacenters/dc-a/rivet-engine/2/config.jsonc +62 -0
- package/docker/dev-multidc-multinode/datacenters/dc-a/vector-client/vector.yaml +31 -0
- package/docker/dev-multidc-multinode/datacenters/dc-a/vector-server/vector.yaml +61 -0
- package/docker/dev-multidc-multinode/datacenters/dc-b/otel-collector-client/config.yaml +39 -0
- package/docker/dev-multidc-multinode/datacenters/dc-b/otel-collector-server/config.yaml +72 -0
- package/docker/dev-multidc-multinode/datacenters/dc-b/postgres/init-db.sh +6 -0
- package/docker/dev-multidc-multinode/datacenters/dc-b/rivet-engine/0/config.jsonc +62 -0
- package/docker/dev-multidc-multinode/datacenters/dc-b/rivet-engine/1/config.jsonc +62 -0
- package/docker/dev-multidc-multinode/datacenters/dc-b/rivet-engine/2/config.jsonc +62 -0
- package/docker/dev-multidc-multinode/datacenters/dc-b/vector-client/vector.yaml +31 -0
- package/docker/dev-multidc-multinode/datacenters/dc-b/vector-server/vector.yaml +61 -0
- package/docker/dev-multidc-multinode/datacenters/dc-c/otel-collector-client/config.yaml +39 -0
- package/docker/dev-multidc-multinode/datacenters/dc-c/otel-collector-server/config.yaml +72 -0
- package/docker/dev-multidc-multinode/datacenters/dc-c/postgres/init-db.sh +6 -0
- package/docker/dev-multidc-multinode/datacenters/dc-c/rivet-engine/0/config.jsonc +62 -0
- package/docker/dev-multidc-multinode/datacenters/dc-c/rivet-engine/1/config.jsonc +62 -0
- package/docker/dev-multidc-multinode/datacenters/dc-c/rivet-engine/2/config.jsonc +62 -0
- package/docker/dev-multidc-multinode/datacenters/dc-c/vector-client/vector.yaml +31 -0
- package/docker/dev-multidc-multinode/datacenters/dc-c/vector-server/vector.yaml +61 -0
- package/docker/dev-multidc-multinode/docker-compose.yml +888 -0
- package/docker/dev-multinode/.gitattributes +1 -0
- package/docker/dev-multinode/README.md +74 -0
- package/docker/dev-multinode/clickhouse/client-config.xml +5 -0
- package/docker/dev-multinode/clickhouse/config.xml +52 -0
- package/docker/dev-multinode/clickhouse/init/01-create-otel-table.sql +107 -0
- package/docker/dev-multinode/clickhouse/users.xml +35 -0
- package/docker/dev-multinode/docker-compose.yml +323 -0
- package/docker/dev-multinode/grafana/dashboards/api.json +1240 -0
- package/docker/dev-multinode/grafana/dashboards/cache.json +1075 -0
- package/docker/dev-multinode/grafana/dashboards/futures.json +230 -0
- package/docker/dev-multinode/grafana/dashboards/gasoline.json +2477 -0
- package/docker/dev-multinode/grafana/dashboards/guard.json +1274 -0
- package/docker/dev-multinode/grafana/dashboards/tokio.json +1005 -0
- package/docker/dev-multinode/grafana/dashboards/traces.json +957 -0
- package/docker/dev-multinode/grafana/grafana.ini +14 -0
- package/docker/dev-multinode/grafana/provisioning/dashboards/dashboards.yaml +10 -0
- package/docker/dev-multinode/grafana/provisioning/datasources/datasources.yaml +30 -0
- package/docker/dev-multinode/otel-collector-client/config.yaml +39 -0
- package/docker/dev-multinode/otel-collector-server/config.yaml +72 -0
- package/docker/dev-multinode/postgres/init-db.sh +6 -0
- package/docker/dev-multinode/rivet-engine/0/config.jsonc +48 -0
- package/docker/dev-multinode/rivet-engine/1/config.jsonc +48 -0
- package/docker/dev-multinode/rivet-engine/2/config.jsonc +48 -0
- package/docker/dev-multinode/vector-client/vector.yaml +31 -0
- package/docker/dev-multinode/vector-server/vector.yaml +61 -0
- package/docker/engine/build.sh +67 -0
- package/docker/engine/linux-aarch64.Dockerfile +97 -0
- package/docker/engine/linux-x86_64.Dockerfile +93 -0
- package/docker/engine/macos-aarch64.Dockerfile +92 -0
- package/docker/engine/macos-x86_64.Dockerfile +92 -0
- package/docker/engine/windows.Dockerfile +80 -0
- package/docker/prod-file-system/.gitattributes +1 -0
- package/docker/prod-file-system/README.md +76 -0
- package/docker/prod-file-system/docker-compose.yml +41 -0
- package/docker/prod-file-system/rivet-engine/config.jsonc +2 -0
- package/docker/template/README.md +20 -0
- package/docker/template/grafana-dashboards/api.json +1240 -0
- package/docker/template/grafana-dashboards/cache.json +1075 -0
- package/docker/template/grafana-dashboards/futures.json +230 -0
- package/docker/template/grafana-dashboards/gasoline.json +2477 -0
- package/docker/template/grafana-dashboards/guard.json +1274 -0
- package/docker/template/grafana-dashboards/tokio.json +1005 -0
- package/docker/template/grafana-dashboards/traces.json +957 -0
- package/docker/template/node_modules/.bin/js-yaml +21 -0
- package/docker/template/node_modules/.bin/tsc +21 -0
- package/docker/template/node_modules/.bin/tsserver +21 -0
- package/docker/template/node_modules/.bin/tsx +21 -0
- package/docker/template/package.json +23 -0
- package/docker/template/src/config.ts +104 -0
- package/docker/template/src/context.ts +216 -0
- package/docker/template/src/docker-compose.ts +368 -0
- package/docker/template/src/git.ts +8 -0
- package/docker/template/src/main.ts +65 -0
- package/docker/template/src/readme.ts +98 -0
- package/docker/template/src/services/core/clickhouse.ts +223 -0
- package/docker/template/src/services/core/grafana.ts +115 -0
- package/docker/template/src/services/edge/otel-collector-client.ts +64 -0
- package/docker/template/src/services/edge/otel-collector-server.ts +107 -0
- package/docker/template/src/services/edge/postgres.ts +23 -0
- package/docker/template/src/services/edge/rivet-engine.ts +87 -0
- package/docker/template/src/services/edge/runner.ts +7 -0
- package/docker/template/src/services/edge/vector-client.ts +55 -0
- package/docker/template/src/services/edge/vector-server.ts +111 -0
- package/docker/template/src/utils.ts +19 -0
- package/docker/template/tsconfig.json +18 -0
- package/docker/universal/Dockerfile +133 -0
- package/package.json +10 -0
- package/packages/actor-kv/Cargo.toml +31 -0
- package/packages/actor-kv/src/entry.rs +147 -0
- package/packages/actor-kv/src/key.rs +81 -0
- package/packages/actor-kv/src/lib.rs +357 -0
- package/packages/actor-kv/src/utils.rs +101 -0
- package/packages/actor-kv/tests/kv_operations.rs +294 -0
- package/packages/actor-kv/tests/list_edge_cases.rs +370 -0
- package/packages/api-builder/Cargo.toml +36 -0
- package/packages/api-builder/src/context.rs +98 -0
- package/packages/api-builder/src/error_response.rs +116 -0
- package/packages/api-builder/src/errors.rs +29 -0
- package/packages/api-builder/src/extract.rs +137 -0
- package/packages/api-builder/src/global_context.rs +31 -0
- package/packages/api-builder/src/lib.rs +19 -0
- package/packages/api-builder/src/metrics.rs +29 -0
- package/packages/api-builder/src/middleware.rs +232 -0
- package/packages/api-builder/src/prelude.rs +18 -0
- package/packages/api-builder/src/request_ids.rs +17 -0
- package/packages/api-builder/src/router.rs +89 -0
- package/packages/api-builder/src/wrappers.rs +138 -0
- package/packages/api-builder/tests/basic.rs +215 -0
- package/packages/api-builder/tests/errors.rs +104 -0
- package/packages/api-peer/Cargo.toml +34 -0
- package/packages/api-peer/src/actors/create.rs +40 -0
- package/packages/api-peer/src/actors/delete.rs +87 -0
- package/packages/api-peer/src/actors/kv_get.rs +67 -0
- package/packages/api-peer/src/actors/list.rs +98 -0
- package/packages/api-peer/src/actors/list_names.rs +56 -0
- package/packages/api-peer/src/actors/mod.rs +5 -0
- package/packages/api-peer/src/internal.rs +186 -0
- package/packages/api-peer/src/lib.rs +28 -0
- package/packages/api-peer/src/namespaces.rs +122 -0
- package/packages/api-peer/src/router.rs +51 -0
- package/packages/api-peer/src/runner_configs.rs +160 -0
- package/packages/api-peer/src/runners.rs +109 -0
- package/packages/api-public/Cargo.toml +38 -0
- package/packages/api-public/build.rs +45 -0
- package/packages/api-public/src/actors/create.rs +99 -0
- package/packages/api-public/src/actors/delete.rs +86 -0
- package/packages/api-public/src/actors/get_or_create.rs +170 -0
- package/packages/api-public/src/actors/kv_get.rs +79 -0
- package/packages/api-public/src/actors/list.rs +241 -0
- package/packages/api-public/src/actors/list_names.rs +76 -0
- package/packages/api-public/src/actors/mod.rs +7 -0
- package/packages/api-public/src/actors/utils.rs +216 -0
- package/packages/api-public/src/ctx.rs +70 -0
- package/packages/api-public/src/datacenters.rs +43 -0
- package/packages/api-public/src/errors.rs +30 -0
- package/packages/api-public/src/health.rs +166 -0
- package/packages/api-public/src/lib.rs +13 -0
- package/packages/api-public/src/metadata.rs +24 -0
- package/packages/api-public/src/namespaces.rs +89 -0
- package/packages/api-public/src/router.rs +182 -0
- package/packages/api-public/src/runner_configs/delete.rs +99 -0
- package/packages/api-public/src/runner_configs/list.rs +98 -0
- package/packages/api-public/src/runner_configs/mod.rs +12 -0
- package/packages/api-public/src/runner_configs/refresh_metadata.rs +116 -0
- package/packages/api-public/src/runner_configs/serverless_health_check.rs +81 -0
- package/packages/api-public/src/runner_configs/upsert.rs +194 -0
- package/packages/api-public/src/runner_configs/utils.rs +217 -0
- package/packages/api-public/src/runners.rs +144 -0
- package/packages/api-public/src/ui.rs +44 -0
- package/packages/api-types/Cargo.toml +17 -0
- package/packages/api-types/src/actors/create.rs +29 -0
- package/packages/api-types/src/actors/list.rs +23 -0
- package/packages/api-types/src/actors/list_names.rs +24 -0
- package/packages/api-types/src/actors/mod.rs +3 -0
- package/packages/api-types/src/datacenters/list.rs +12 -0
- package/packages/api-types/src/datacenters/mod.rs +1 -0
- package/packages/api-types/src/lib.rs +6 -0
- package/packages/api-types/src/namespaces/list.rs +21 -0
- package/packages/api-types/src/namespaces/mod.rs +2 -0
- package/packages/api-types/src/namespaces/runner_configs.rs +55 -0
- package/packages/api-types/src/pagination.rs +8 -0
- package/packages/api-types/src/runner_configs/list.rs +29 -0
- package/packages/api-types/src/runner_configs/mod.rs +1 -0
- package/packages/api-types/src/runners/list.rs +25 -0
- package/packages/api-types/src/runners/mod.rs +1 -0
- package/packages/api-util/Cargo.toml +22 -0
- package/packages/api-util/src/errors.rs +9 -0
- package/packages/api-util/src/lib.rs +209 -0
- package/packages/bootstrap/Cargo.toml +19 -0
- package/packages/bootstrap/src/lib.rs +102 -0
- package/packages/cache/Cargo.toml +28 -0
- package/packages/cache/src/driver.rs +346 -0
- package/packages/cache/src/errors.rs +23 -0
- package/packages/cache/src/getter_ctx.rs +138 -0
- package/packages/cache/src/inner.rs +60 -0
- package/packages/cache/src/key.rs +101 -0
- package/packages/cache/src/lib.rs +19 -0
- package/packages/cache/src/metrics.rs +34 -0
- package/packages/cache/src/purge.rs +13 -0
- package/packages/cache/src/rate_limit.rs +109 -0
- package/packages/cache/src/req_config.rs +443 -0
- package/packages/cache/tests/integration.rs +582 -0
- package/packages/cache-purge/Cargo.toml +17 -0
- package/packages/cache-purge/src/lib.rs +44 -0
- package/packages/cache-result/Cargo.toml +9 -0
- package/packages/cache-result/src/lib.rs +61 -0
- package/packages/clickhouse-inserter/Cargo.toml +17 -0
- package/packages/clickhouse-inserter/src/error.rs +16 -0
- package/packages/clickhouse-inserter/src/lib.rs +179 -0
- package/packages/clickhouse-user-query/Cargo.toml +16 -0
- package/packages/clickhouse-user-query/examples/case_sensitivity_demo.rs +100 -0
- package/packages/clickhouse-user-query/examples/group_by_example.rs +53 -0
- package/packages/clickhouse-user-query/examples/string_contains_demo.rs +96 -0
- package/packages/clickhouse-user-query/src/builder.rs +445 -0
- package/packages/clickhouse-user-query/src/error.rs +37 -0
- package/packages/clickhouse-user-query/src/lib.rs +61 -0
- package/packages/clickhouse-user-query/src/query.rs +143 -0
- package/packages/clickhouse-user-query/src/schema.rs +78 -0
- package/packages/clickhouse-user-query/tests/builder_tests.rs +619 -0
- package/packages/clickhouse-user-query/tests/case_sensitivity_tests.rs +307 -0
- package/packages/clickhouse-user-query/tests/integration_tests.rs +540 -0
- package/packages/clickhouse-user-query/tests/query_tests.rs +263 -0
- package/packages/clickhouse-user-query/tests/schema_tests.rs +44 -0
- package/packages/config/Cargo.toml +20 -0
- package/packages/config/src/config/api_peer.rs +21 -0
- package/packages/config/src/config/api_public.rs +25 -0
- package/packages/config/src/config/auth.rs +10 -0
- package/packages/config/src/config/cache.rs +24 -0
- package/packages/config/src/config/clickhouse.rs +49 -0
- package/packages/config/src/config/db.rs +52 -0
- package/packages/config/src/config/guard.rs +42 -0
- package/packages/config/src/config/logs.rs +10 -0
- package/packages/config/src/config/mod.rs +240 -0
- package/packages/config/src/config/pegboard.rs +94 -0
- package/packages/config/src/config/pubsub.rs +90 -0
- package/packages/config/src/config/runtime.rs +31 -0
- package/packages/config/src/config/telemetry.rs +14 -0
- package/packages/config/src/config/topology.rs +123 -0
- package/packages/config/src/config/vector.rs +18 -0
- package/packages/config/src/defaults.rs +11 -0
- package/packages/config/src/lib.rs +135 -0
- package/packages/config/src/paths.rs +25 -0
- package/packages/config/src/secret.rs +72 -0
- package/packages/dump-openapi/Cargo.toml +11 -0
- package/packages/dump-openapi/build.rs +26 -0
- package/packages/dump-openapi/src/lib.rs +1 -0
- package/packages/engine/Cargo.toml +74 -0
- package/packages/engine/src/commands/config.rs +18 -0
- package/packages/engine/src/commands/db/mod.rs +80 -0
- package/packages/engine/src/commands/mod.rs +7 -0
- package/packages/engine/src/commands/start.rs +143 -0
- package/packages/engine/src/commands/tracing.rs +86 -0
- package/packages/engine/src/commands/udb/cli.rs +562 -0
- package/packages/engine/src/commands/udb/mod.rs +132 -0
- package/packages/engine/src/commands/udb_keys.rs +200 -0
- package/packages/engine/src/commands/wf/mod.rs +125 -0
- package/packages/engine/src/commands/wf/signal.rs +80 -0
- package/packages/engine/src/keys.rs +47 -0
- package/packages/engine/src/lib.rs +55 -0
- package/packages/engine/src/main.rs +60 -0
- package/packages/engine/src/run_config.rs +53 -0
- package/packages/engine/src/util/db.rs +99 -0
- package/packages/engine/src/util/format.rs +69 -0
- package/packages/engine/src/util/mod.rs +13 -0
- package/packages/engine/src/util/udb.rs +687 -0
- package/packages/engine/src/util/wf/mod.rs +649 -0
- package/packages/engine/src/util/wf/signal.rs +126 -0
- package/packages/engine/tests/actors_create.rs +524 -0
- package/packages/engine/tests/actors_delete.rs +243 -0
- package/packages/engine/tests/actors_general.rs +191 -0
- package/packages/engine/tests/actors_get.rs +230 -0
- package/packages/engine/tests/actors_get_by_id.rs +170 -0
- package/packages/engine/tests/actors_get_or_create.rs +294 -0
- package/packages/engine/tests/actors_get_or_create_by_id.rs +147 -0
- package/packages/engine/tests/actors_lifecycle.rs +165 -0
- package/packages/engine/tests/actors_list.rs +798 -0
- package/packages/engine/tests/actors_list_names.rs +353 -0
- package/packages/engine/tests/common/actors.rs +554 -0
- package/packages/engine/tests/common/ctx.rs +201 -0
- package/packages/engine/tests/common/mod.rs +30 -0
- package/packages/engine/tests/common/ns.rs +36 -0
- package/packages/engine/tests/common/runner.rs +134 -0
- package/packages/engine/tests/common/test_helpers.rs +226 -0
- package/packages/engine/tests/runners_dupe_key.rs +27 -0
- package/packages/engine/tests/runners_version.rs +50 -0
- package/packages/env/Cargo.toml +14 -0
- package/packages/env/build.rs +8 -0
- package/packages/env/src/lib.rs +30 -0
- package/packages/epoxy/Cargo.toml +45 -0
- package/packages/epoxy/README.md +158 -0
- package/packages/epoxy/spec/KEYS.md +33 -0
- package/packages/epoxy/spec/PROPOSAL.md +125 -0
- package/packages/epoxy/spec/RECONFIGURE.md +40 -0
- package/packages/epoxy/src/consts.rs +42 -0
- package/packages/epoxy/src/errors.rs +21 -0
- package/packages/epoxy/src/http_client.rs +192 -0
- package/packages/epoxy/src/http_routes.rs +34 -0
- package/packages/epoxy/src/keys/keys.rs +99 -0
- package/packages/epoxy/src/keys/mod.rs +9 -0
- package/packages/epoxy/src/keys/replica.rs +283 -0
- package/packages/epoxy/src/lib.rs +25 -0
- package/packages/epoxy/src/ops/explicit_prepare.rs +342 -0
- package/packages/epoxy/src/ops/kv/get_local.rs +44 -0
- package/packages/epoxy/src/ops/kv/get_optimistic.rs +150 -0
- package/packages/epoxy/src/ops/kv/mod.rs +3 -0
- package/packages/epoxy/src/ops/kv/purge_local.rs +28 -0
- package/packages/epoxy/src/ops/mod.rs +4 -0
- package/packages/epoxy/src/ops/propose.rs +352 -0
- package/packages/epoxy/src/ops/read_cluster_config.rs +24 -0
- package/packages/epoxy/src/replica/ballot.rs +130 -0
- package/packages/epoxy/src/replica/commit_kv.rs +80 -0
- package/packages/epoxy/src/replica/decide_path.rs +51 -0
- package/packages/epoxy/src/replica/lead_consensus.rs +65 -0
- package/packages/epoxy/src/replica/log.rs +84 -0
- package/packages/epoxy/src/replica/message_request.rs +166 -0
- package/packages/epoxy/src/replica/messages/accept.rs +50 -0
- package/packages/epoxy/src/replica/messages/accepted.rs +35 -0
- package/packages/epoxy/src/replica/messages/commit.rs +46 -0
- package/packages/epoxy/src/replica/messages/committed.rs +41 -0
- package/packages/epoxy/src/replica/messages/download_instances.rs +69 -0
- package/packages/epoxy/src/replica/messages/mod.rs +15 -0
- package/packages/epoxy/src/replica/messages/pre_accept.rs +69 -0
- package/packages/epoxy/src/replica/messages/prepare.rs +89 -0
- package/packages/epoxy/src/replica/mod.rs +11 -0
- package/packages/epoxy/src/replica/update_config.rs +24 -0
- package/packages/epoxy/src/replica/utils.rs +111 -0
- package/packages/epoxy/src/types.rs +117 -0
- package/packages/epoxy/src/utils.rs +65 -0
- package/packages/epoxy/src/workflows/coordinator/mod.rs +121 -0
- package/packages/epoxy/src/workflows/coordinator/reconfigure.rs +291 -0
- package/packages/epoxy/src/workflows/coordinator/replica_status_change.rs +193 -0
- package/packages/epoxy/src/workflows/mod.rs +3 -0
- package/packages/epoxy/src/workflows/purger.rs +81 -0
- package/packages/epoxy/src/workflows/replica/mod.rs +39 -0
- package/packages/epoxy/src/workflows/replica/setup.rs +823 -0
- package/packages/epoxy/tests/common/api.rs +25 -0
- package/packages/epoxy/tests/common/mod.rs +301 -0
- package/packages/epoxy/tests/common/utils.rs +23 -0
- package/packages/epoxy/tests/kv.rs +187 -0
- package/packages/epoxy/tests/kv_get_optimistic.rs +179 -0
- package/packages/epoxy/tests/proposal.rs +38 -0
- package/packages/epoxy/tests/reconfigure.rs +618 -0
- package/packages/error/Cargo.toml +16 -0
- package/packages/error/src/error.rs +90 -0
- package/packages/error/src/lib.rs +13 -0
- package/packages/error/src/schema.rs +86 -0
- package/packages/error/tests/basic.rs +338 -0
- package/packages/error-macros/Cargo.toml +19 -0
- package/packages/error-macros/src/lib.rs +632 -0
- package/packages/gasoline/Cargo.toml +55 -0
- package/packages/gasoline/src/activity.rs +24 -0
- package/packages/gasoline/src/builder/common/message.rs +104 -0
- package/packages/gasoline/src/builder/common/mod.rs +5 -0
- package/packages/gasoline/src/builder/common/signal.rs +193 -0
- package/packages/gasoline/src/builder/common/workflow.rs +196 -0
- package/packages/gasoline/src/builder/mod.rs +60 -0
- package/packages/gasoline/src/builder/workflow/message.rs +147 -0
- package/packages/gasoline/src/builder/workflow/mod.rs +5 -0
- package/packages/gasoline/src/builder/workflow/signal.rs +227 -0
- package/packages/gasoline/src/builder/workflow/sub_workflow.rs +318 -0
- package/packages/gasoline/src/ctx/activity.rs +192 -0
- package/packages/gasoline/src/ctx/common.rs +153 -0
- package/packages/gasoline/src/ctx/listen.rs +121 -0
- package/packages/gasoline/src/ctx/message.rs +346 -0
- package/packages/gasoline/src/ctx/mod.rs +18 -0
- package/packages/gasoline/src/ctx/operation.rs +191 -0
- package/packages/gasoline/src/ctx/standalone.rs +228 -0
- package/packages/gasoline/src/ctx/test.rs +251 -0
- package/packages/gasoline/src/ctx/versioned_workflow.rs +198 -0
- package/packages/gasoline/src/ctx/workflow.rs +1459 -0
- package/packages/gasoline/src/db/debug.rs +199 -0
- package/packages/gasoline/src/db/kv/debug.rs +1493 -0
- package/packages/gasoline/src/db/kv/keys/history.rs +1780 -0
- package/packages/gasoline/src/db/kv/keys/metric.rs +170 -0
- package/packages/gasoline/src/db/kv/keys/mod.rs +6 -0
- package/packages/gasoline/src/db/kv/keys/signal.rs +401 -0
- package/packages/gasoline/src/db/kv/keys/wake.rs +310 -0
- package/packages/gasoline/src/db/kv/keys/worker.rs +185 -0
- package/packages/gasoline/src/db/kv/keys/workflow.rs +1175 -0
- package/packages/gasoline/src/db/kv/mod.rs +3044 -0
- package/packages/gasoline/src/db/kv/subjects.rs +13 -0
- package/packages/gasoline/src/db/kv/system.rs +33 -0
- package/packages/gasoline/src/db/mod.rs +344 -0
- package/packages/gasoline/src/error.rs +258 -0
- package/packages/gasoline/src/executable.rs +186 -0
- package/packages/gasoline/src/history/cursor.rs +779 -0
- package/packages/gasoline/src/history/event.rs +210 -0
- package/packages/gasoline/src/history/location.rs +185 -0
- package/packages/gasoline/src/history/mod.rs +8 -0
- package/packages/gasoline/src/history/removed.rs +94 -0
- package/packages/gasoline/src/lib.rs +18 -0
- package/packages/gasoline/src/listen.rs +24 -0
- package/packages/gasoline/src/message.rs +103 -0
- package/packages/gasoline/src/metrics.rs +156 -0
- package/packages/gasoline/src/operation.rs +21 -0
- package/packages/gasoline/src/prelude.rs +53 -0
- package/packages/gasoline/src/registry.rs +111 -0
- package/packages/gasoline/src/signal.rs +117 -0
- package/packages/gasoline/src/stub.rs +118 -0
- package/packages/gasoline/src/utils/mod.rs +20 -0
- package/packages/gasoline/src/utils/tags.rs +82 -0
- package/packages/gasoline/src/utils/time.rs +85 -0
- package/packages/gasoline/src/worker.rs +336 -0
- package/packages/gasoline/src/workflow.rs +64 -0
- package/packages/gasoline/tests/activity_ctx.rs +83 -0
- package/packages/gasoline/tests/workflow_ctx.rs +288 -0
- package/packages/gasoline/tests/workflows/activity_test.rs +33 -0
- package/packages/gasoline/tests/workflows/basic.rs +13 -0
- package/packages/gasoline/tests/workflows/eviction_test.rs +45 -0
- package/packages/gasoline/tests/workflows/listen_timeout.rs +27 -0
- package/packages/gasoline/tests/workflows/loop_test.rs +30 -0
- package/packages/gasoline/tests/workflows/mod.rs +11 -0
- package/packages/gasoline/tests/workflows/properties_test.rs +56 -0
- package/packages/gasoline/tests/workflows/signal_test.rs +24 -0
- package/packages/gasoline/tests/workflows/sleep_test.rs +15 -0
- package/packages/gasoline/tests/workflows/state_test.rs +69 -0
- package/packages/gasoline/tests/workflows/sub_test.rs +21 -0
- package/packages/gasoline/tests/workflows/tags_test.rs +40 -0
- package/packages/gasoline-macros/Cargo.toml +14 -0
- package/packages/gasoline-macros/src/lib.rs +527 -0
- package/packages/guard/Cargo.toml +56 -0
- package/packages/guard/src/cache/actor.rs +43 -0
- package/packages/guard/src/cache/mod.rs +69 -0
- package/packages/guard/src/errors.rs +62 -0
- package/packages/guard/src/lib.rs +58 -0
- package/packages/guard/src/middleware.rs +42 -0
- package/packages/guard/src/routing/api_public.rs +70 -0
- package/packages/guard/src/routing/mod.rs +245 -0
- package/packages/guard/src/routing/pegboard_gateway.rs +260 -0
- package/packages/guard/src/routing/runner.rs +129 -0
- package/packages/guard/src/shared_state.rs +31 -0
- package/packages/guard/src/tls.rs +224 -0
- package/packages/guard/tests/parse_actor_path.rs +240 -0
- package/packages/guard-core/Cargo.toml +58 -0
- package/packages/guard-core/src/analytics.rs +46 -0
- package/packages/guard-core/src/cert_resolver.rs +61 -0
- package/packages/guard-core/src/custom_serve.rs +52 -0
- package/packages/guard-core/src/errors.rs +113 -0
- package/packages/guard-core/src/lib.rs +25 -0
- package/packages/guard-core/src/metrics.rs +64 -0
- package/packages/guard-core/src/proxy_service.rs +2699 -0
- package/packages/guard-core/src/request_context.rs +184 -0
- package/packages/guard-core/src/server.rs +289 -0
- package/packages/guard-core/src/task_group.rs +57 -0
- package/packages/guard-core/src/types.rs +19 -0
- package/packages/guard-core/src/websocket_handle.rs +47 -0
- package/packages/guard-core/tests/common/mod.rs +678 -0
- package/packages/guard-core/tests/custom_serve.rs +392 -0
- package/packages/guard-core/tests/fixtures/tls/README.md +6 -0
- package/packages/guard-core/tests/fixtures/tls/api_cert.pem +51 -0
- package/packages/guard-core/tests/fixtures/tls/api_key.pem +7 -0
- package/packages/guard-core/tests/fixtures/tls/job_cert.pem +55 -0
- package/packages/guard-core/tests/fixtures/tls/job_key.pem +7 -0
- package/packages/guard-core/tests/https.rs +400 -0
- package/packages/guard-core/tests/metrics.rs +247 -0
- package/packages/guard-core/tests/proxy.rs +842 -0
- package/packages/guard-core/tests/simple_websocket.rs +258 -0
- package/packages/guard-core/tests/simple_websocket_echo.rs +318 -0
- package/packages/guard-core/tests/simple_websocket_test2.rs +120 -0
- package/packages/guard-core/tests/streaming_response.rs +265 -0
- package/packages/guard-core/tests/websocket.rs +1113 -0
- package/packages/internal/Cargo.toml +13 -0
- package/packages/internal/README.md +1 -0
- package/packages/internal/src/lib.rs +1 -0
- package/packages/internal/src/ops/bump_serverless_autoscaler_global.rs +64 -0
- package/packages/internal/src/ops/cache/mod.rs +1 -0
- package/packages/internal/src/ops/cache/purge_global.rs +81 -0
- package/packages/internal/src/ops/mod.rs +2 -0
- package/packages/logs/Cargo.toml +20 -0
- package/packages/logs/src/lib.rs +9 -0
- package/packages/logs/src/unix.rs +201 -0
- package/packages/logs/src/windows.rs +240 -0
- package/packages/metrics/Cargo.toml +20 -0
- package/packages/metrics/src/buckets.rs +32 -0
- package/packages/metrics/src/lib.rs +8 -0
- package/packages/metrics/src/providers.rs +183 -0
- package/packages/namespace/Cargo.toml +28 -0
- package/packages/namespace/src/errors.rs +39 -0
- package/packages/namespace/src/keys/mod.rs +190 -0
- package/packages/namespace/src/keys/runner_config.rs +211 -0
- package/packages/namespace/src/lib.rs +16 -0
- package/packages/namespace/src/ops/get_global.rs +58 -0
- package/packages/namespace/src/ops/get_local.rs +69 -0
- package/packages/namespace/src/ops/list.rs +69 -0
- package/packages/namespace/src/ops/mod.rs +6 -0
- package/packages/namespace/src/ops/resolve_for_name_global.rs +57 -0
- package/packages/namespace/src/ops/resolve_for_name_local.rs +41 -0
- package/packages/namespace/src/ops/runner_config/delete.rs +53 -0
- package/packages/namespace/src/ops/runner_config/get.rs +94 -0
- package/packages/namespace/src/ops/runner_config/list.rs +94 -0
- package/packages/namespace/src/ops/runner_config/mod.rs +4 -0
- package/packages/namespace/src/ops/runner_config/upsert.rs +148 -0
- package/packages/namespace/src/utils.rs +11 -0
- package/packages/namespace/src/workflows/mod.rs +1 -0
- package/packages/namespace/src/workflows/namespace.rs +178 -0
- package/packages/pegboard/Cargo.toml +34 -0
- package/packages/pegboard/src/errors.rs +76 -0
- package/packages/pegboard/src/keys/actor.rs +443 -0
- package/packages/pegboard/src/keys/epoxy/mod.rs +1 -0
- package/packages/pegboard/src/keys/epoxy/ns.rs +68 -0
- package/packages/pegboard/src/keys/hibernating_request.rs +72 -0
- package/packages/pegboard/src/keys/mod.rs +15 -0
- package/packages/pegboard/src/keys/ns.rs +1367 -0
- package/packages/pegboard/src/keys/runner.rs +818 -0
- package/packages/pegboard/src/lib.rs +19 -0
- package/packages/pegboard/src/metrics.rs +19 -0
- package/packages/pegboard/src/ops/actor/create.rs +159 -0
- package/packages/pegboard/src/ops/actor/get.rs +100 -0
- package/packages/pegboard/src/ops/actor/get_for_gateway.rs +70 -0
- package/packages/pegboard/src/ops/actor/get_for_key.rs +93 -0
- package/packages/pegboard/src/ops/actor/get_reservation_for_key.rs +46 -0
- package/packages/pegboard/src/ops/actor/get_runner.rs +64 -0
- package/packages/pegboard/src/ops/actor/hibernating_request/delete.rs +41 -0
- package/packages/pegboard/src/ops/actor/hibernating_request/list.rs +65 -0
- package/packages/pegboard/src/ops/actor/hibernating_request/mod.rs +3 -0
- package/packages/pegboard/src/ops/actor/hibernating_request/upsert.rs +51 -0
- package/packages/pegboard/src/ops/actor/list_for_ns.rs +207 -0
- package/packages/pegboard/src/ops/actor/list_names.rs +62 -0
- package/packages/pegboard/src/ops/actor/mod.rs +9 -0
- package/packages/pegboard/src/ops/mod.rs +2 -0
- package/packages/pegboard/src/ops/runner/find_dc_with_runner.rs +222 -0
- package/packages/pegboard/src/ops/runner/get.rs +143 -0
- package/packages/pegboard/src/ops/runner/get_by_key.rs +51 -0
- package/packages/pegboard/src/ops/runner/list_for_ns.rs +209 -0
- package/packages/pegboard/src/ops/runner/list_names.rs +60 -0
- package/packages/pegboard/src/ops/runner/mod.rs +6 -0
- package/packages/pegboard/src/ops/runner/update_alloc_idx.rs +208 -0
- package/packages/pegboard/src/pubsub_subjects.rs +80 -0
- package/packages/pegboard/src/utils.rs +29 -0
- package/packages/pegboard/src/workflows/actor/destroy.rs +264 -0
- package/packages/pegboard/src/workflows/actor/keys.rs +283 -0
- package/packages/pegboard/src/workflows/actor/mod.rs +804 -0
- package/packages/pegboard/src/workflows/actor/runtime.rs +909 -0
- package/packages/pegboard/src/workflows/actor/setup.rs +175 -0
- package/packages/pegboard/src/workflows/mod.rs +2 -0
- package/packages/pegboard/src/workflows/runner.rs +1182 -0
- package/packages/pegboard-gateway/Cargo.toml +35 -0
- package/packages/pegboard-gateway/src/keepalive_task.rs +61 -0
- package/packages/pegboard-gateway/src/lib.rs +698 -0
- package/packages/pegboard-gateway/src/metrics.rs +14 -0
- package/packages/pegboard-gateway/src/ping_task.rs +23 -0
- package/packages/pegboard-gateway/src/shared_state.rs +588 -0
- package/packages/pegboard-gateway/src/tunnel_to_ws_task.rs +85 -0
- package/packages/pegboard-gateway/src/ws_to_tunnel_task.rs +65 -0
- package/packages/pegboard-runner/Cargo.toml +38 -0
- package/packages/pegboard-runner/src/conn.rs +183 -0
- package/packages/pegboard-runner/src/errors.rs +33 -0
- package/packages/pegboard-runner/src/lib.rs +249 -0
- package/packages/pegboard-runner/src/ping_task.rs +66 -0
- package/packages/pegboard-runner/src/tunnel_to_ws_task.rs +137 -0
- package/packages/pegboard-runner/src/utils.rs +40 -0
- package/packages/pegboard-runner/src/ws_to_tunnel_task.rs +443 -0
- package/packages/pegboard-serverless/Cargo.toml +25 -0
- package/packages/pegboard-serverless/src/lib.rs +523 -0
- package/packages/pools/Cargo.toml +38 -0
- package/packages/pools/src/db/clickhouse.rs +37 -0
- package/packages/pools/src/db/mod.rs +3 -0
- package/packages/pools/src/db/udb.rs +37 -0
- package/packages/pools/src/db/ups.rs +91 -0
- package/packages/pools/src/error.rs +41 -0
- package/packages/pools/src/lib.rs +16 -0
- package/packages/pools/src/metrics.rs +32 -0
- package/packages/pools/src/pools.rs +114 -0
- package/packages/pools/src/prelude.rs +3 -0
- package/packages/pools/src/reqwest.rs +25 -0
- package/packages/runtime/Cargo.lock +1394 -0
- package/packages/runtime/Cargo.toml +29 -0
- package/packages/runtime/src/lib.rs +154 -0
- package/packages/runtime/src/metrics.rs +34 -0
- package/packages/runtime/src/term_signal.rs +113 -0
- package/packages/runtime/src/traces.rs +158 -0
- package/packages/service-manager/Cargo.toml +19 -0
- package/packages/service-manager/src/lib.rs +359 -0
- package/packages/telemetry/Cargo.toml +13 -0
- package/packages/telemetry/README.md +12 -0
- package/packages/telemetry/src/lib.rs +39 -0
- package/packages/test-deps/Cargo.toml +19 -0
- package/packages/test-deps/src/datacenter.rs +109 -0
- package/packages/test-deps/src/lib.rs +131 -0
- package/packages/test-deps-docker/Cargo.toml +14 -0
- package/packages/test-deps-docker/src/database.rs +135 -0
- package/packages/test-deps-docker/src/lib.rs +280 -0
- package/packages/test-deps-docker/src/pubsub.rs +76 -0
- package/packages/tracing-reconfigure/Cargo.toml +18 -0
- package/packages/tracing-reconfigure/src/lib.rs +78 -0
- package/packages/tracing-utils/Cargo.toml +12 -0
- package/packages/tracing-utils/src/lib.rs +91 -0
- package/packages/types/Cargo.toml +19 -0
- package/packages/types/README.md +3 -0
- package/packages/types/src/actors.rs +79 -0
- package/packages/types/src/datacenters.rs +10 -0
- package/packages/types/src/keys/mod.rs +2 -0
- package/packages/types/src/keys/namespace/mod.rs +1 -0
- package/packages/types/src/keys/namespace/runner_config.rs +28 -0
- package/packages/types/src/keys/pegboard/mod.rs +7 -0
- package/packages/types/src/keys/pegboard/ns.rs +109 -0
- package/packages/types/src/lib.rs +7 -0
- package/packages/types/src/msgs/mod.rs +1 -0
- package/packages/types/src/msgs/pegboard.rs +5 -0
- package/packages/types/src/namespaces.rs +10 -0
- package/packages/types/src/runner_configs.rs +96 -0
- package/packages/types/src/runners.rs +24 -0
- package/packages/universaldb/Cargo.toml +32 -0
- package/packages/universaldb/src/atomic.rs +190 -0
- package/packages/universaldb/src/database.rs +56 -0
- package/packages/universaldb/src/driver/mod.rs +87 -0
- package/packages/universaldb/src/driver/postgres/database.rs +244 -0
- package/packages/universaldb/src/driver/postgres/mod.rs +5 -0
- package/packages/universaldb/src/driver/postgres/transaction.rs +337 -0
- package/packages/universaldb/src/driver/postgres/transaction_task.rs +538 -0
- package/packages/universaldb/src/driver/rocksdb/database.rs +129 -0
- package/packages/universaldb/src/driver/rocksdb/mod.rs +6 -0
- package/packages/universaldb/src/driver/rocksdb/transaction.rs +354 -0
- package/packages/universaldb/src/driver/rocksdb/transaction_conflict_tracker.rs +109 -0
- package/packages/universaldb/src/driver/rocksdb/transaction_task.rs +526 -0
- package/packages/universaldb/src/error.rs +30 -0
- package/packages/universaldb/src/key_selector.rs +97 -0
- package/packages/universaldb/src/lib.rs +24 -0
- package/packages/universaldb/src/metrics.rs +27 -0
- package/packages/universaldb/src/options.rs +284 -0
- package/packages/universaldb/src/prelude.rs +8 -0
- package/packages/universaldb/src/range_option.rs +159 -0
- package/packages/universaldb/src/transaction.rs +378 -0
- package/packages/universaldb/src/tx_ops.rs +425 -0
- package/packages/universaldb/src/utils/cherry_pick.rs +88 -0
- package/packages/universaldb/src/utils/codes.rs +9 -0
- package/packages/universaldb/src/utils/ext.rs +58 -0
- package/packages/universaldb/src/utils/formal_key.rs +23 -0
- package/packages/universaldb/src/utils/keys.rs +134 -0
- package/packages/universaldb/src/utils/mod.rs +92 -0
- package/packages/universaldb/src/utils/subspace.rs +95 -0
- package/packages/universaldb/src/value.rs +159 -0
- package/packages/universaldb/src/versionstamp.rs +173 -0
- package/packages/universaldb/tests/integration.rs +2733 -0
- package/packages/universaldb/tests/integration_gas.rs +264 -0
- package/packages/universaldb/tests/rocksdb.rs +141 -0
- package/packages/universaldb/tests/versionstamp.rs +184 -0
- package/packages/universalpubsub/Cargo.toml +38 -0
- package/packages/universalpubsub/benches/simple.rs +932 -0
- package/packages/universalpubsub/src/chunking.rs +226 -0
- package/packages/universalpubsub/src/driver/memory/mod.rs +91 -0
- package/packages/universalpubsub/src/driver/mod.rs +58 -0
- package/packages/universalpubsub/src/driver/nats/mod.rs +79 -0
- package/packages/universalpubsub/src/driver/postgres/mod.rs +443 -0
- package/packages/universalpubsub/src/errors.rs +11 -0
- package/packages/universalpubsub/src/lib.rs +7 -0
- package/packages/universalpubsub/src/pubsub.rs +415 -0
- package/packages/universalpubsub/tests/integration.rs +441 -0
- package/packages/universalpubsub/tests/reconnect.rs +359 -0
- package/packages/util/Cargo.toml +41 -0
- package/packages/util/build.rs +13 -0
- package/packages/util/src/backoff.rs +109 -0
- package/packages/util/src/billing.rs +3 -0
- package/packages/util/src/build_meta.rs +33 -0
- package/packages/util/src/check.rs +222 -0
- package/packages/util/src/duration.rs +77 -0
- package/packages/util/src/faker.rs +81 -0
- package/packages/util/src/format.rs +185 -0
- package/packages/util/src/future.rs +1 -0
- package/packages/util/src/geo.rs +5 -0
- package/packages/util/src/lib.rs +40 -0
- package/packages/util/src/math.rs +35 -0
- package/packages/util/src/req.rs +41 -0
- package/packages/util/src/serde.rs +516 -0
- package/packages/util/src/size.rs +27 -0
- package/packages/util/src/sort.rs +13 -0
- package/packages/util/src/timestamp.rs +58 -0
- package/packages/util/src/url.rs +3 -0
- package/packages/util-id/Cargo.toml +13 -0
- package/packages/util-id/src/lib.rs +329 -0
- package/packages/workflow-worker/Cargo.toml +16 -0
- package/packages/workflow-worker/src/lib.rs +15 -0
- package/sdks/api/fern/fern.config.json +4 -0
- package/sdks/api/fern/generators.yml +25 -0
- package/sdks/go/api-full/client/client.go +459 -0
- package/sdks/go/api-full/client/client_test.go +43 -0
- package/sdks/go/api-full/client/options.go +39 -0
- package/sdks/go/api-full/core/client_option.go +44 -0
- package/sdks/go/api-full/core/core.go +220 -0
- package/sdks/go/api-full/core/core_test.go +219 -0
- package/sdks/go/api-full/core/stringer.go +13 -0
- package/sdks/go/api-full/datacenters/client.go +50 -0
- package/sdks/go/api-full/go.mod +8 -0
- package/sdks/go/api-full/go.sum +12 -0
- package/sdks/go/api-full/health/client.go +50 -0
- package/sdks/go/api-full/namespaces/client.go +92 -0
- package/sdks/go/api-full/namespaces.go +15 -0
- package/sdks/go/api-full/pointer.go +103 -0
- package/sdks/go/api-full/runners/client.go +111 -0
- package/sdks/go/api-full/runners.go +18 -0
- package/sdks/go/api-full/types.go +1638 -0
- package/sdks/rust/api-full/.openapi-generator/FILES +28 -0
- package/sdks/rust/api-full/.openapi-generator/VERSION +1 -0
- package/sdks/rust/api-full/.openapi-generator-ignore +23 -0
- package/sdks/rust/api-full/.travis.yml +1 -0
- package/sdks/rust/api-full/Cargo.toml +15 -0
- package/sdks/rust/api-full/README.md +53 -0
- package/sdks/rust/api-full/docs/Actor.md +19 -0
- package/sdks/rust/api-full/docs/ActorLifecycle.md +12 -0
- package/sdks/rust/api-full/docs/ActorsApi.md +37 -0
- package/sdks/rust/api-full/docs/ActorsCreateRequest.md +13 -0
- package/sdks/rust/api-full/docs/ActorsCreateResponse.md +11 -0
- package/sdks/rust/api-full/docs/Namespace.md +14 -0
- package/sdks/rust/api-full/docs/NamespacesCreateRequest.md +12 -0
- package/sdks/rust/api-full/docs/NamespacesCreateResponse.md +11 -0
- package/sdks/rust/api-full/docs/NsApi.md +37 -0
- package/sdks/rust/api-full/git_push.sh +57 -0
- package/sdks/rust/api-full/rust/.openapi-generator/FILES +140 -0
- package/sdks/rust/api-full/rust/.openapi-generator/VERSION +1 -0
- package/sdks/rust/api-full/rust/.openapi-generator-ignore +23 -0
- package/sdks/rust/api-full/rust/.travis.yml +1 -0
- package/sdks/rust/api-full/rust/Cargo.toml +15 -0
- package/sdks/rust/api-full/rust/README.md +111 -0
- package/sdks/rust/api-full/rust/docs/Actor.md +24 -0
- package/sdks/rust/api-full/rust/docs/ActorName.md +11 -0
- package/sdks/rust/api-full/rust/docs/ActorsCreateApi.md +40 -0
- package/sdks/rust/api-full/rust/docs/ActorsCreateRequest.md +16 -0
- package/sdks/rust/api-full/rust/docs/ActorsCreateResponse.md +11 -0
- package/sdks/rust/api-full/rust/docs/ActorsDeleteApi.md +40 -0
- package/sdks/rust/api-full/rust/docs/ActorsGetOrCreateApi.md +40 -0
- package/sdks/rust/api-full/rust/docs/ActorsGetOrCreateRequest.md +16 -0
- package/sdks/rust/api-full/rust/docs/ActorsGetOrCreateResponse.md +12 -0
- package/sdks/rust/api-full/rust/docs/ActorsKvGetApi.md +38 -0
- package/sdks/rust/api-full/rust/docs/ActorsKvGetResponse.md +12 -0
- package/sdks/rust/api-full/rust/docs/ActorsListApi.md +45 -0
- package/sdks/rust/api-full/rust/docs/ActorsListNamesApi.md +41 -0
- package/sdks/rust/api-full/rust/docs/ActorsListNamesResponse.md +12 -0
- package/sdks/rust/api-full/rust/docs/ActorsListResponse.md +12 -0
- package/sdks/rust/api-full/rust/docs/CrashPolicy.md +14 -0
- package/sdks/rust/api-full/rust/docs/Datacenter.md +13 -0
- package/sdks/rust/api-full/rust/docs/DatacenterHealth.md +16 -0
- package/sdks/rust/api-full/rust/docs/DatacentersApi.md +34 -0
- package/sdks/rust/api-full/rust/docs/DatacentersListResponse.md +12 -0
- package/sdks/rust/api-full/rust/docs/HealthApi.md +34 -0
- package/sdks/rust/api-full/rust/docs/HealthFanoutResponse.md +11 -0
- package/sdks/rust/api-full/rust/docs/HealthResponse.md +13 -0
- package/sdks/rust/api-full/rust/docs/HealthStatus.md +13 -0
- package/sdks/rust/api-full/rust/docs/Namespace.md +14 -0
- package/sdks/rust/api-full/rust/docs/NamespaceListResponse.md +12 -0
- package/sdks/rust/api-full/rust/docs/NamespacesApi.md +69 -0
- package/sdks/rust/api-full/rust/docs/NamespacesCreateRequest.md +12 -0
- package/sdks/rust/api-full/rust/docs/NamespacesCreateResponse.md +11 -0
- package/sdks/rust/api-full/rust/docs/Pagination.md +11 -0
- package/sdks/rust/api-full/rust/docs/Runner.md +25 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfig.md +13 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigKind.md +12 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigKindOneOf.md +11 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigKindOneOf1.md +11 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigKindOneOf1Serverless.md +17 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigVariant.md +13 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigsDeleteApi.md +38 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigsListApi.md +41 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigsListResponse.md +12 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigsListResponseRunnerConfigsValue.md +11 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigsRefreshMetadataApi.md +39 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigsServerlessHealthCheckApi.md +38 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigsServerlessHealthCheckRequest.md +12 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigsServerlessHealthCheckResponse.md +12 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigsServerlessHealthCheckResponseOneOf.md +11 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigsServerlessHealthCheckResponseOneOf1.md +11 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigsServerlessHealthCheckResponseOneOf1Failure.md +11 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigsServerlessHealthCheckResponseOneOfSuccess.md +11 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigsServerlessMetadataError.md +16 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigsServerlessMetadataErrorOneOf.md +11 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigsServerlessMetadataErrorOneOf1.md +11 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigsServerlessMetadataErrorOneOf2.md +11 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigsServerlessMetadataErrorOneOf3.md +11 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigsServerlessMetadataErrorOneOf3NonSuccessStatus.md +12 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigsServerlessMetadataErrorOneOf4.md +11 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigsServerlessMetadataErrorOneOf4InvalidResponseJson.md +11 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigsServerlessMetadataErrorOneOf5.md +11 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigsServerlessMetadataErrorOneOf5InvalidResponseSchema.md +12 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigsUpsertApi.md +39 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigsUpsertRequestBody.md +11 -0
- package/sdks/rust/api-full/rust/docs/RunnerConfigsUpsertResponse.md +11 -0
- package/sdks/rust/api-full/rust/docs/RunnersApi.md +75 -0
- package/sdks/rust/api-full/rust/docs/RunnersListNamesResponse.md +12 -0
- package/sdks/rust/api-full/rust/docs/RunnersListResponse.md +12 -0
- package/sdks/rust/api-full/rust/git_push.sh +57 -0
- package/sdks/rust/api-full/rust/src/apis/actors_create_api.rs +68 -0
- package/sdks/rust/api-full/rust/src/apis/actors_delete_api.rs +69 -0
- package/sdks/rust/api-full/rust/src/apis/actors_get_or_create_api.rs +68 -0
- package/sdks/rust/api-full/rust/src/apis/actors_kv_get_api.rs +65 -0
- package/sdks/rust/api-full/rust/src/apis/actors_list_api.rs +90 -0
- package/sdks/rust/api-full/rust/src/apis/actors_list_names_api.rs +74 -0
- package/sdks/rust/api-full/rust/src/apis/configuration.rs +51 -0
- package/sdks/rust/api-full/rust/src/apis/datacenters_api.rs +62 -0
- package/sdks/rust/api-full/rust/src/apis/health_api.rs +62 -0
- package/sdks/rust/api-full/rust/src/apis/mod.rs +130 -0
- package/sdks/rust/api-full/rust/src/apis/namespaces_api.rs +126 -0
- package/sdks/rust/api-full/rust/src/apis/runner_configs_delete_api.rs +66 -0
- package/sdks/rust/api-full/rust/src/apis/runner_configs_list_api.rs +81 -0
- package/sdks/rust/api-full/rust/src/apis/runner_configs_refresh_metadata_api.rs +68 -0
- package/sdks/rust/api-full/rust/src/apis/runner_configs_serverless_health_check_api.rs +67 -0
- package/sdks/rust/api-full/rust/src/apis/runner_configs_upsert_api.rs +68 -0
- package/sdks/rust/api-full/rust/src/apis/runners_api.rs +141 -0
- package/sdks/rust/api-full/rust/src/lib.rs +11 -0
- package/sdks/rust/api-full/rust/src/models/actor.rs +73 -0
- package/sdks/rust/api-full/rust/src/models/actor_name.rs +27 -0
- package/sdks/rust/api-full/rust/src/models/actors_create_request.rs +42 -0
- package/sdks/rust/api-full/rust/src/models/actors_create_response.rs +27 -0
- package/sdks/rust/api-full/rust/src/models/actors_get_or_create_request.rs +42 -0
- package/sdks/rust/api-full/rust/src/models/actors_get_or_create_response.rs +30 -0
- package/sdks/rust/api-full/rust/src/models/actors_kv_get_response.rs +30 -0
- package/sdks/rust/api-full/rust/src/models/actors_list_names_response.rs +30 -0
- package/sdks/rust/api-full/rust/src/models/actors_list_response.rs +30 -0
- package/sdks/rust/api-full/rust/src/models/crash_policy.rs +41 -0
- package/sdks/rust/api-full/rust/src/models/datacenter.rs +33 -0
- package/sdks/rust/api-full/rust/src/models/datacenter_health.rs +42 -0
- package/sdks/rust/api-full/rust/src/models/datacenters_list_response.rs +30 -0
- package/sdks/rust/api-full/rust/src/models/health_fanout_response.rs +27 -0
- package/sdks/rust/api-full/rust/src/models/health_response.rs +33 -0
- package/sdks/rust/api-full/rust/src/models/health_status.rs +38 -0
- package/sdks/rust/api-full/rust/src/models/mod.rs +100 -0
- package/sdks/rust/api-full/rust/src/models/namespace.rs +36 -0
- package/sdks/rust/api-full/rust/src/models/namespace_list_response.rs +30 -0
- package/sdks/rust/api-full/rust/src/models/namespaces_create_request.rs +30 -0
- package/sdks/rust/api-full/rust/src/models/namespaces_create_response.rs +27 -0
- package/sdks/rust/api-full/rust/src/models/pagination.rs +27 -0
- package/sdks/rust/api-full/rust/src/models/runner.rs +69 -0
- package/sdks/rust/api-full/rust/src/models/runner_config.rs +33 -0
- package/sdks/rust/api-full/rust/src/models/runner_config_kind.rs +26 -0
- package/sdks/rust/api-full/rust/src/models/runner_config_kind_one_of.rs +27 -0
- package/sdks/rust/api-full/rust/src/models/runner_config_kind_one_of_1.rs +27 -0
- package/sdks/rust/api-full/rust/src/models/runner_config_kind_one_of_1_serverless.rs +46 -0
- package/sdks/rust/api-full/rust/src/models/runner_config_variant.rs +38 -0
- package/sdks/rust/api-full/rust/src/models/runner_configs_list_response.rs +30 -0
- package/sdks/rust/api-full/rust/src/models/runner_configs_list_response_runner_configs_value.rs +27 -0
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_health_check_request.rs +30 -0
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_health_check_response.rs +26 -0
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_health_check_response_one_of.rs +27 -0
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_health_check_response_one_of_1.rs +27 -0
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_health_check_response_one_of_1_failure.rs +27 -0
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_health_check_response_one_of_success.rs +27 -0
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error.rs +30 -0
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error_one_of.rs +27 -0
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error_one_of_1.rs +27 -0
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error_one_of_2.rs +27 -0
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error_one_of_3.rs +27 -0
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error_one_of_3_non_success_status.rs +30 -0
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error_one_of_4.rs +27 -0
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error_one_of_4_invalid_response_json.rs +27 -0
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error_one_of_5.rs +27 -0
- package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error_one_of_5_invalid_response_schema.rs +30 -0
- package/sdks/rust/api-full/rust/src/models/runner_configs_upsert_request_body.rs +27 -0
- package/sdks/rust/api-full/rust/src/models/runner_configs_upsert_response.rs +27 -0
- package/sdks/rust/api-full/rust/src/models/runners_list_names_response.rs +30 -0
- package/sdks/rust/api-full/rust/src/models/runners_list_response.rs +30 -0
- package/sdks/rust/api-full/src/apis/actors_api.rs +67 -0
- package/sdks/rust/api-full/src/apis/configuration.rs +48 -0
- package/sdks/rust/api-full/src/apis/mod.rs +119 -0
- package/sdks/rust/api-full/src/apis/ns_api.rs +67 -0
- package/sdks/rust/api-full/src/lib.rs +11 -0
- package/sdks/rust/api-full/src/models/actor.rs +72 -0
- package/sdks/rust/api-full/src/models/actor_lifecycle.rs +29 -0
- package/sdks/rust/api-full/src/models/actors_create_request.rs +36 -0
- package/sdks/rust/api-full/src/models/actors_create_response.rs +26 -0
- package/sdks/rust/api-full/src/models/mod.rs +14 -0
- package/sdks/rust/api-full/src/models/namespace.rs +40 -0
- package/sdks/rust/api-full/src/models/namespaces_create_request.rs +26 -0
- package/sdks/rust/api-full/src/models/namespaces_create_response.rs +26 -0
- package/sdks/rust/data/Cargo.toml +18 -0
- package/sdks/rust/data/build.rs +15 -0
- package/sdks/rust/data/src/converted.rs +137 -0
- package/sdks/rust/data/src/generated.rs +1 -0
- package/sdks/rust/data/src/lib.rs +11 -0
- package/sdks/rust/data/src/versioned/mod.rs +178 -0
- package/sdks/rust/data/src/versioned/namespace_runner_config.rs +125 -0
- package/sdks/rust/epoxy-protocol/Cargo.toml +17 -0
- package/sdks/rust/epoxy-protocol/build.rs +18 -0
- package/sdks/rust/epoxy-protocol/src/generated.rs +1 -0
- package/sdks/rust/epoxy-protocol/src/lib.rs +7 -0
- package/sdks/rust/epoxy-protocol/src/versioned.rs +206 -0
- package/sdks/rust/runner-protocol/Cargo.toml +23 -0
- package/sdks/rust/runner-protocol/build.rs +115 -0
- package/sdks/rust/runner-protocol/src/compat.rs +7 -0
- package/sdks/rust/runner-protocol/src/generated.rs +1 -0
- package/sdks/rust/runner-protocol/src/lib.rs +10 -0
- package/sdks/rust/runner-protocol/src/util.rs +14 -0
- package/sdks/rust/runner-protocol/src/uuid_compat.rs +209 -0
- package/sdks/rust/runner-protocol/src/versioned.rs +1734 -0
- package/sdks/rust/ups-protocol/Cargo.toml +17 -0
- package/sdks/rust/ups-protocol/build.rs +18 -0
- package/sdks/rust/ups-protocol/src/generated.rs +1 -0
- package/sdks/rust/ups-protocol/src/lib.rs +7 -0
- package/sdks/rust/ups-protocol/src/versioned.rs +48 -0
- package/sdks/schemas/README.md +6 -0
- package/sdks/schemas/data/namespace.runner_config.v1.bare +13 -0
- package/sdks/schemas/data/namespace.runner_config.v2.bare +23 -0
- package/sdks/schemas/data/pegboard.namespace.actor_by_key.v1.bare +6 -0
- package/sdks/schemas/data/pegboard.namespace.actor_name.v1.bare +5 -0
- package/sdks/schemas/data/pegboard.namespace.runner_alloc_idx.v1.bare +7 -0
- package/sdks/schemas/data/pegboard.namespace.runner_by_key.v1.bare +6 -0
- package/sdks/schemas/data/pegboard.runner.metadata.v1.bare +5 -0
- package/sdks/schemas/epoxy-protocol/v1.bare +260 -0
- package/sdks/schemas/runner-protocol/v1.bare +393 -0
- package/sdks/schemas/runner-protocol/v2.bare +403 -0
- package/sdks/schemas/runner-protocol/v3.bare +436 -0
- package/sdks/schemas/ups-protocol/v1.bare +23 -0
- package/sdks/typescript/api-full/.turbo/turbo-build.log +42 -0
- package/sdks/typescript/api-full/build.js +69 -0
- package/sdks/typescript/api-full/package.json +59 -0
- package/sdks/typescript/api-full/rivetkit-engine-api-full-25.5.3.tgz +0 -0
- package/sdks/typescript/api-full/src/Client.ts +984 -0
- package/sdks/typescript/api-full/src/api/client/index.ts +1 -0
- package/sdks/typescript/api-full/src/api/client/requests/ActorsCreateRequest.ts +24 -0
- package/sdks/typescript/api-full/src/api/client/requests/ActorsDeleteRequest.ts +11 -0
- package/sdks/typescript/api-full/src/api/client/requests/ActorsGetOrCreateRequest.ts +25 -0
- package/sdks/typescript/api-full/src/api/client/requests/ActorsListNamesRequest.ts +15 -0
- package/sdks/typescript/api-full/src/api/client/requests/ActorsListRequest.ts +19 -0
- package/sdks/typescript/api-full/src/api/client/requests/RunnerConfigsDeleteRequest.ts +13 -0
- package/sdks/typescript/api-full/src/api/client/requests/RunnerConfigsListRequest.ts +19 -0
- package/sdks/typescript/api-full/src/api/client/requests/RunnerConfigsRefreshMetadataRequest.ts +19 -0
- package/sdks/typescript/api-full/src/api/client/requests/RunnerConfigsServerlessHealthCheckRequest.ts +16 -0
- package/sdks/typescript/api-full/src/api/client/requests/RunnerConfigsUpsertRequestBody.ts +19 -0
- package/sdks/typescript/api-full/src/api/client/requests/index.ts +10 -0
- package/sdks/typescript/api-full/src/api/index.ts +3 -0
- package/sdks/typescript/api-full/src/api/resources/datacenters/client/Client.ts +97 -0
- package/sdks/typescript/api-full/src/api/resources/datacenters/client/index.ts +1 -0
- package/sdks/typescript/api-full/src/api/resources/datacenters/index.ts +1 -0
- package/sdks/typescript/api-full/src/api/resources/health/client/Client.ts +97 -0
- package/sdks/typescript/api-full/src/api/resources/health/client/index.ts +1 -0
- package/sdks/typescript/api-full/src/api/resources/health/index.ts +1 -0
- package/sdks/typescript/api-full/src/api/resources/index.ts +6 -0
- package/sdks/typescript/api-full/src/api/resources/namespaces/client/Client.ts +187 -0
- package/sdks/typescript/api-full/src/api/resources/namespaces/client/index.ts +1 -0
- package/sdks/typescript/api-full/src/api/resources/namespaces/client/requests/NamespacesCreateRequest.ts +15 -0
- package/sdks/typescript/api-full/src/api/resources/namespaces/client/requests/NamespacesListRequest.ts +14 -0
- package/sdks/typescript/api-full/src/api/resources/namespaces/client/requests/index.ts +2 -0
- package/sdks/typescript/api-full/src/api/resources/namespaces/index.ts +1 -0
- package/sdks/typescript/api-full/src/api/resources/runners/client/Client.ts +209 -0
- package/sdks/typescript/api-full/src/api/resources/runners/client/index.ts +1 -0
- package/sdks/typescript/api-full/src/api/resources/runners/client/requests/RunnersListNamesRequest.ts +15 -0
- package/sdks/typescript/api-full/src/api/resources/runners/client/requests/RunnersListRequest.ts +18 -0
- package/sdks/typescript/api-full/src/api/resources/runners/client/requests/index.ts +2 -0
- package/sdks/typescript/api-full/src/api/resources/runners/index.ts +1 -0
- package/sdks/typescript/api-full/src/api/types/Actor.ts +32 -0
- package/sdks/typescript/api-full/src/api/types/ActorName.ts +7 -0
- package/sdks/typescript/api-full/src/api/types/ActorsCreateResponse.ts +9 -0
- package/sdks/typescript/api-full/src/api/types/ActorsDeleteResponse.ts +5 -0
- package/sdks/typescript/api-full/src/api/types/ActorsGetOrCreateResponse.ts +10 -0
- package/sdks/typescript/api-full/src/api/types/ActorsKvGetResponse.ts +8 -0
- package/sdks/typescript/api-full/src/api/types/ActorsListNamesResponse.ts +10 -0
- package/sdks/typescript/api-full/src/api/types/ActorsListResponse.ts +10 -0
- package/sdks/typescript/api-full/src/api/types/CrashPolicy.ts +10 -0
- package/sdks/typescript/api-full/src/api/types/Datacenter.ts +9 -0
- package/sdks/typescript/api-full/src/api/types/DatacenterHealth.ts +14 -0
- package/sdks/typescript/api-full/src/api/types/DatacentersListResponse.ts +10 -0
- package/sdks/typescript/api-full/src/api/types/HealthFanoutResponse.ts +9 -0
- package/sdks/typescript/api-full/src/api/types/HealthResponse.ts +9 -0
- package/sdks/typescript/api-full/src/api/types/HealthStatus.ts +9 -0
- package/sdks/typescript/api-full/src/api/types/Namespace.ts +12 -0
- package/sdks/typescript/api-full/src/api/types/NamespaceListResponse.ts +10 -0
- package/sdks/typescript/api-full/src/api/types/NamespacesCreateResponse.ts +9 -0
- package/sdks/typescript/api-full/src/api/types/Pagination.ts +7 -0
- package/sdks/typescript/api-full/src/api/types/RivetId.ts +5 -0
- package/sdks/typescript/api-full/src/api/types/Runner.ts +23 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfig.ts +11 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigKind.ts +7 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigKindNormal.ts +7 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigKindServerless.ts +9 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigKindServerlessServerless.ts +14 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigServerless.ts +14 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigVariant.ts +9 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigsDeleteResponse.ts +5 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigsListResponse.ts +10 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigsListResponseRunnerConfigsValue.ts +9 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigsRefreshMetadataRequestBody.ts +5 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigsRefreshMetadataResponse.ts +5 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigsServerlessHealthCheckResponse.ts +9 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigsServerlessHealthCheckResponseFailure.ts +9 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigsServerlessHealthCheckResponseFailureFailure.ts +9 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigsServerlessHealthCheckResponseSuccess.ts +9 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigsServerlessHealthCheckResponseSuccessSuccess.ts +7 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigsServerlessMetadataError.ts +13 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigsServerlessMetadataErrorInvalidRequest.ts +7 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigsServerlessMetadataErrorInvalidResponseJson.ts +9 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigsServerlessMetadataErrorInvalidResponseJsonInvalidResponseJson.ts +7 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigsServerlessMetadataErrorInvalidResponseSchema.ts +9 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigsServerlessMetadataErrorInvalidResponseSchemaInvalidResponseSchema.ts +8 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigsServerlessMetadataErrorNonSuccessStatus.ts +9 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigsServerlessMetadataErrorNonSuccessStatusNonSuccessStatus.ts +8 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigsServerlessMetadataErrorRequestFailed.ts +7 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigsServerlessMetadataErrorRequestTimedOut.ts +7 -0
- package/sdks/typescript/api-full/src/api/types/RunnerConfigsUpsertResponse.ts +7 -0
- package/sdks/typescript/api-full/src/api/types/RunnersListNamesResponse.ts +10 -0
- package/sdks/typescript/api-full/src/api/types/RunnersListResponse.ts +10 -0
- package/sdks/typescript/api-full/src/api/types/index.ts +51 -0
- package/sdks/typescript/api-full/src/core/auth/BasicAuth.ts +31 -0
- package/sdks/typescript/api-full/src/core/auth/BearerToken.ts +15 -0
- package/sdks/typescript/api-full/src/core/auth/index.ts +2 -0
- package/sdks/typescript/api-full/src/core/fetcher/APIResponse.ts +12 -0
- package/sdks/typescript/api-full/src/core/fetcher/Fetcher.ts +144 -0
- package/sdks/typescript/api-full/src/core/fetcher/Supplier.ts +11 -0
- package/sdks/typescript/api-full/src/core/fetcher/createRequestUrl.ts +10 -0
- package/sdks/typescript/api-full/src/core/fetcher/getFetchFn.ts +25 -0
- package/sdks/typescript/api-full/src/core/fetcher/getHeader.ts +8 -0
- package/sdks/typescript/api-full/src/core/fetcher/getRequestBody.ts +16 -0
- package/sdks/typescript/api-full/src/core/fetcher/getResponseBody.ts +34 -0
- package/sdks/typescript/api-full/src/core/fetcher/index.ts +5 -0
- package/sdks/typescript/api-full/src/core/fetcher/makeRequest.ts +44 -0
- package/sdks/typescript/api-full/src/core/fetcher/requestWithRetries.ts +33 -0
- package/sdks/typescript/api-full/src/core/fetcher/signals.ts +38 -0
- package/sdks/typescript/api-full/src/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.ts +257 -0
- package/sdks/typescript/api-full/src/core/fetcher/stream-wrappers/NodePre18StreamWrapper.ts +107 -0
- package/sdks/typescript/api-full/src/core/fetcher/stream-wrappers/UndiciStreamWrapper.ts +243 -0
- package/sdks/typescript/api-full/src/core/fetcher/stream-wrappers/chooseStreamWrapper.ts +34 -0
- package/sdks/typescript/api-full/src/core/index.ts +4 -0
- package/sdks/typescript/api-full/src/core/json.ts +27 -0
- package/sdks/typescript/api-full/src/core/runtime/index.ts +1 -0
- package/sdks/typescript/api-full/src/core/runtime/runtime.ts +131 -0
- package/sdks/typescript/api-full/src/core/schemas/Schema.ts +101 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/bigint/bigint.ts +55 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/bigint/index.ts +1 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/date/date.ts +65 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/date/index.ts +1 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/enum/enum.ts +43 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/enum/index.ts +1 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/index.ts +14 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/lazy/index.ts +3 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/lazy/lazy.ts +32 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/lazy/lazyObject.ts +20 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/list/index.ts +1 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/list/list.ts +73 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/literals/booleanLiteral.ts +29 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/literals/index.ts +2 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/literals/stringLiteral.ts +29 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/object/index.ts +22 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/object/object.ts +366 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/object/objectWithoutOptionalProperties.ts +18 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/object/property.ts +23 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/object/types.ts +58 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/object-like/getObjectLikeUtils.ts +79 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/object-like/index.ts +2 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/object-like/types.ts +11 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/primitives/any.ts +4 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/primitives/boolean.ts +25 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/primitives/index.ts +5 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/primitives/number.ts +25 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/primitives/string.ts +25 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/primitives/unknown.ts +4 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/record/index.ts +2 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/record/record.ts +129 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/record/types.ts +17 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/schema-utils/JsonError.ts +9 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/schema-utils/ParseError.ts +9 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/schema-utils/getSchemaUtils.ts +181 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/schema-utils/index.ts +4 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/schema-utils/stringifyValidationErrors.ts +8 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/set/index.ts +1 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/set/set.ts +43 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/undiscriminated-union/index.ts +6 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/undiscriminated-union/types.ts +10 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.ts +60 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/union/discriminant.ts +14 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/union/index.ts +10 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/union/types.ts +26 -0
- package/sdks/typescript/api-full/src/core/schemas/builders/union/union.ts +170 -0
- package/sdks/typescript/api-full/src/core/schemas/index.ts +2 -0
- package/sdks/typescript/api-full/src/core/schemas/utils/MaybePromise.ts +1 -0
- package/sdks/typescript/api-full/src/core/schemas/utils/addQuestionMarksToNullableProperties.ts +9 -0
- package/sdks/typescript/api-full/src/core/schemas/utils/createIdentitySchemaCreator.ts +21 -0
- package/sdks/typescript/api-full/src/core/schemas/utils/entries.ts +3 -0
- package/sdks/typescript/api-full/src/core/schemas/utils/filterObject.ts +13 -0
- package/sdks/typescript/api-full/src/core/schemas/utils/getErrorMessageForIncorrectType.ts +25 -0
- package/sdks/typescript/api-full/src/core/schemas/utils/isPlainObject.ts +17 -0
- package/sdks/typescript/api-full/src/core/schemas/utils/keys.ts +3 -0
- package/sdks/typescript/api-full/src/core/schemas/utils/maybeSkipValidation.ts +38 -0
- package/sdks/typescript/api-full/src/core/schemas/utils/partition.ts +12 -0
- package/sdks/typescript/api-full/src/errors/RivetError.ts +47 -0
- package/sdks/typescript/api-full/src/errors/RivetTimeoutError.ts +10 -0
- package/sdks/typescript/api-full/src/errors/index.ts +2 -0
- package/sdks/typescript/api-full/src/index.ts +4 -0
- package/sdks/typescript/api-full/src/serialization/client/index.ts +1 -0
- package/sdks/typescript/api-full/src/serialization/client/requests/ActorsCreateRequest.ts +31 -0
- package/sdks/typescript/api-full/src/serialization/client/requests/ActorsGetOrCreateRequest.ts +31 -0
- package/sdks/typescript/api-full/src/serialization/client/requests/RunnerConfigsServerlessHealthCheckRequest.ts +22 -0
- package/sdks/typescript/api-full/src/serialization/client/requests/RunnerConfigsUpsertRequestBody.ts +21 -0
- package/sdks/typescript/api-full/src/serialization/client/requests/index.ts +4 -0
- package/sdks/typescript/api-full/src/serialization/index.ts +3 -0
- package/sdks/typescript/api-full/src/serialization/resources/index.ts +2 -0
- package/sdks/typescript/api-full/src/serialization/resources/namespaces/client/index.ts +1 -0
- package/sdks/typescript/api-full/src/serialization/resources/namespaces/client/requests/NamespacesCreateRequest.ts +22 -0
- package/sdks/typescript/api-full/src/serialization/resources/namespaces/client/requests/index.ts +1 -0
- package/sdks/typescript/api-full/src/serialization/resources/namespaces/index.ts +1 -0
- package/sdks/typescript/api-full/src/serialization/types/Actor.ts +45 -0
- package/sdks/typescript/api-full/src/serialization/types/ActorName.ts +18 -0
- package/sdks/typescript/api-full/src/serialization/types/ActorsCreateResponse.ts +21 -0
- package/sdks/typescript/api-full/src/serialization/types/ActorsDeleteResponse.ts +16 -0
- package/sdks/typescript/api-full/src/serialization/types/ActorsGetOrCreateResponse.ts +23 -0
- package/sdks/typescript/api-full/src/serialization/types/ActorsKvGetResponse.ts +22 -0
- package/sdks/typescript/api-full/src/serialization/types/ActorsListNamesResponse.ts +24 -0
- package/sdks/typescript/api-full/src/serialization/types/ActorsListResponse.ts +24 -0
- package/sdks/typescript/api-full/src/serialization/types/CrashPolicy.ts +14 -0
- package/sdks/typescript/api-full/src/serialization/types/Datacenter.ts +22 -0
- package/sdks/typescript/api-full/src/serialization/types/DatacenterHealth.ts +32 -0
- package/sdks/typescript/api-full/src/serialization/types/DatacentersListResponse.ts +24 -0
- package/sdks/typescript/api-full/src/serialization/types/HealthFanoutResponse.ts +21 -0
- package/sdks/typescript/api-full/src/serialization/types/HealthResponse.ts +22 -0
- package/sdks/typescript/api-full/src/serialization/types/HealthStatus.ts +14 -0
- package/sdks/typescript/api-full/src/serialization/types/Namespace.ts +25 -0
- package/sdks/typescript/api-full/src/serialization/types/NamespaceListResponse.ts +24 -0
- package/sdks/typescript/api-full/src/serialization/types/NamespacesCreateResponse.ts +21 -0
- package/sdks/typescript/api-full/src/serialization/types/Pagination.ts +18 -0
- package/sdks/typescript/api-full/src/serialization/types/RivetId.ts +13 -0
- package/sdks/typescript/api-full/src/serialization/types/Runner.ts +46 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfig.ts +23 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigKind.ts +16 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigKindNormal.ts +20 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigKindServerless.ts +21 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigKindServerlessServerless.ts +32 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigServerless.ts +32 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigVariant.ts +16 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigsDeleteResponse.ts +16 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigsListResponse.ts +27 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigsListResponseRunnerConfigsValue.ts +21 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigsRefreshMetadataRequestBody.ts +16 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigsRefreshMetadataResponse.ts +16 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigsServerlessHealthCheckResponse.ts +23 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigsServerlessHealthCheckResponseFailure.ts +21 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigsServerlessHealthCheckResponseFailureFailure.ts +21 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigsServerlessHealthCheckResponseSuccess.ts +21 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigsServerlessHealthCheckResponseSuccessSuccess.ts +20 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigsServerlessMetadataError.ts +35 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigsServerlessMetadataErrorInvalidRequest.ts +23 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigsServerlessMetadataErrorInvalidResponseJson.ts +24 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigsServerlessMetadataErrorInvalidResponseJsonInvalidResponseJson.ts +20 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigsServerlessMetadataErrorInvalidResponseSchema.ts +24 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigsServerlessMetadataErrorInvalidResponseSchemaInvalidResponseSchema.ts +22 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigsServerlessMetadataErrorNonSuccessStatus.ts +24 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigsServerlessMetadataErrorNonSuccessStatusNonSuccessStatus.ts +22 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigsServerlessMetadataErrorRequestFailed.ts +23 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigsServerlessMetadataErrorRequestTimedOut.ts +23 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnerConfigsUpsertResponse.ts +20 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnersListNamesResponse.ts +23 -0
- package/sdks/typescript/api-full/src/serialization/types/RunnersListResponse.ts +24 -0
- package/sdks/typescript/api-full/src/serialization/types/index.ts +51 -0
- package/sdks/typescript/api-full/tsconfig.json +24 -0
- package/sdks/typescript/runner/.turbo/turbo-build.log +22 -0
- package/sdks/typescript/runner/benches/actor-lifecycle.bench.ts +190 -0
- package/sdks/typescript/runner/benches/utils.ts +143 -0
- package/sdks/typescript/runner/dist/mod.cjs +2951 -0
- package/sdks/typescript/runner/dist/mod.cjs.map +1 -0
- package/sdks/typescript/runner/dist/mod.d.cts +326 -0
- package/sdks/typescript/runner/dist/mod.d.ts +326 -0
- package/sdks/typescript/runner/dist/mod.js +2951 -0
- package/sdks/typescript/runner/dist/mod.js.map +1 -0
- package/sdks/typescript/runner/node_modules/.bin/pino +21 -0
- package/sdks/typescript/runner/node_modules/.bin/tsc +21 -0
- package/sdks/typescript/runner/node_modules/.bin/tsserver +21 -0
- package/sdks/typescript/runner/node_modules/.bin/tsup +21 -0
- package/sdks/typescript/runner/node_modules/.bin/tsup-node +21 -0
- package/sdks/typescript/runner/node_modules/.bin/tsx +21 -0
- package/sdks/typescript/runner/node_modules/.bin/uuid +21 -0
- package/sdks/typescript/runner/node_modules/.bin/vitest +21 -0
- package/sdks/typescript/runner/package.json +37 -0
- package/sdks/typescript/runner/src/actor.ts +196 -0
- package/sdks/typescript/runner/src/log.ts +11 -0
- package/sdks/typescript/runner/src/mod.ts +1755 -0
- package/sdks/typescript/runner/src/stringify.ts +354 -0
- package/sdks/typescript/runner/src/tunnel.ts +1178 -0
- package/sdks/typescript/runner/src/utils.ts +159 -0
- package/sdks/typescript/runner/src/websocket-tunnel-adapter.ts +567 -0
- package/sdks/typescript/runner/src/websocket.ts +43 -0
- package/sdks/typescript/runner/tests/lifecycle.test.ts +596 -0
- package/sdks/typescript/runner/tests/utils.test.ts +194 -0
- package/sdks/typescript/runner/tsconfig.json +11 -0
- package/sdks/typescript/runner/tsup.config.ts +4 -0
- package/sdks/typescript/runner/turbo.json +4 -0
- package/sdks/typescript/runner/vitest.config.ts +16 -0
- package/sdks/typescript/runner-protocol/.turbo/turbo-build.log +22 -0
- package/sdks/typescript/runner-protocol/dist/index.cjs +1632 -0
- package/sdks/typescript/runner-protocol/dist/index.cjs.map +1 -0
- package/sdks/typescript/runner-protocol/dist/index.d.cts +666 -0
- package/sdks/typescript/runner-protocol/dist/index.d.ts +666 -0
- package/sdks/typescript/runner-protocol/dist/index.js +1632 -0
- package/sdks/typescript/runner-protocol/dist/index.js.map +1 -0
- package/sdks/typescript/runner-protocol/node_modules/.bin/tsc +21 -0
- package/sdks/typescript/runner-protocol/node_modules/.bin/tsserver +21 -0
- package/sdks/typescript/runner-protocol/node_modules/.bin/tsup +21 -0
- package/sdks/typescript/runner-protocol/node_modules/.bin/tsup-node +21 -0
- package/sdks/typescript/runner-protocol/package.json +34 -0
- package/sdks/typescript/runner-protocol/src/index.ts +2121 -0
- package/sdks/typescript/runner-protocol/tsconfig.json +17 -0
- package/sdks/typescript/runner-protocol/tsup.config.ts +4 -0
- package/sdks/typescript/runner-protocol/turbo.json +4 -0
- package/sdks/typescript/test-runner/.turbo/turbo-build.log +17 -0
- package/sdks/typescript/test-runner/Dockerfile +26 -0
- package/sdks/typescript/test-runner/dist/index.d.ts +6 -0
- package/sdks/typescript/test-runner/dist/index.js +345 -0
- package/sdks/typescript/test-runner/dist/index.js.map +1 -0
- package/sdks/typescript/test-runner/node_modules/.bin/pino +21 -0
- package/sdks/typescript/test-runner/node_modules/.bin/tsc +21 -0
- package/sdks/typescript/test-runner/node_modules/.bin/tsserver +21 -0
- package/sdks/typescript/test-runner/node_modules/.bin/tsup +21 -0
- package/sdks/typescript/test-runner/node_modules/.bin/tsup-node +21 -0
- package/sdks/typescript/test-runner/node_modules/.bin/tsx +21 -0
- package/sdks/typescript/test-runner/node_modules/.bin/vitest +21 -0
- package/sdks/typescript/test-runner/package.json +27 -0
- package/sdks/typescript/test-runner/src/index.ts +287 -0
- package/sdks/typescript/test-runner/src/log.ts +194 -0
- package/sdks/typescript/test-runner/tsconfig.json +11 -0
- package/sdks/typescript/test-runner/tsup.config.ts +7 -0
- package/sdks/typescript/test-runner/turbo.json +4 -0
- package/sdks/typescript/test-runner/vitest.config.ts +16 -0
- package/tests/load/README.md +28 -0
- package/tests/load/actor-lifecycle/README.md +26 -0
- package/tests/load/actor-lifecycle/actor.ts +41 -0
- package/tests/load/actor-lifecycle/config.ts +14 -0
- package/tests/load/actor-lifecycle/index.ts +62 -0
- package/tests/load/actor-lifecycle/rivet_api.ts +140 -0
- package/tests/load/actor-lifecycle/types.ts +17 -0
- package/tests/load/node_modules/.bin/biome +21 -0
- package/tests/load/node_modules/.bin/tsc +21 -0
- package/tests/load/node_modules/.bin/tsserver +21 -0
- package/tests/load/package.json +15 -0
- package/tests/load/tsconfig.json +20 -0
- package/tests/smoke/README.md +32 -0
- package/tests/smoke/package.json +19 -0
- package/tests/smoke/scripts/connect.ts +41 -0
- package/tests/smoke/src/server/registry.ts +32 -0
- package/tests/smoke/src/server/server.ts +7 -0
- package/tests/smoke/src/smoke-test/index.ts +161 -0
- package/tests/smoke/src/smoke-test/spawn-actor.ts +109 -0
- package/tests/smoke/tsconfig.json +43 -0
- package/tests/smoke/turbo.json +4 -0
|
@@ -0,0 +1,1459 @@
|
|
|
1
|
+
use std::{
|
|
2
|
+
ops::Deref,
|
|
3
|
+
sync::Arc,
|
|
4
|
+
time::{Duration, Instant},
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
use anyhow::Result;
|
|
8
|
+
use futures_util::StreamExt;
|
|
9
|
+
use opentelemetry::trace::SpanContext;
|
|
10
|
+
use rivet_util::Id;
|
|
11
|
+
use serde::{Serialize, de::DeserializeOwned};
|
|
12
|
+
use tokio::sync::{Mutex, watch};
|
|
13
|
+
use tracing::Instrument;
|
|
14
|
+
use tracing_opentelemetry::OpenTelemetrySpanExt;
|
|
15
|
+
|
|
16
|
+
use rivet_metrics::KeyValue;
|
|
17
|
+
|
|
18
|
+
use crate::{
|
|
19
|
+
activity::{Activity, ActivityInput},
|
|
20
|
+
builder::{WorkflowRepr, workflow as builder},
|
|
21
|
+
ctx::{ActivityCtx, ListenCtx, MessageCtx, VersionedWorkflowCtx},
|
|
22
|
+
db::{BumpSubSubject, DatabaseHandle, PulledWorkflowData},
|
|
23
|
+
error::{WorkflowError, WorkflowResult},
|
|
24
|
+
executable::{AsyncResult, Executable},
|
|
25
|
+
history::{
|
|
26
|
+
History,
|
|
27
|
+
cursor::{Cursor, HistoryResult},
|
|
28
|
+
event::SleepState,
|
|
29
|
+
location::{Coordinate, Location},
|
|
30
|
+
removed::Removed,
|
|
31
|
+
},
|
|
32
|
+
listen::{CustomListener, Listen},
|
|
33
|
+
message::Message,
|
|
34
|
+
metrics,
|
|
35
|
+
registry::RegistryHandle,
|
|
36
|
+
signal::Signal,
|
|
37
|
+
utils::time::{DurationToMillis, TsToMillis},
|
|
38
|
+
workflow::{Workflow, WorkflowInput},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/// Retry interval for failed db actions
|
|
42
|
+
const DB_ACTION_RETRY: Duration = Duration::from_millis(150);
|
|
43
|
+
/// Most db action retries
|
|
44
|
+
const MAX_DB_ACTION_RETRIES: usize = 5;
|
|
45
|
+
|
|
46
|
+
// NOTE: Cloneable because of inner arcs
|
|
47
|
+
#[derive(Clone)]
|
|
48
|
+
pub struct WorkflowCtx {
|
|
49
|
+
workflow_id: Id,
|
|
50
|
+
/// Name of the workflow to run in the registry.
|
|
51
|
+
name: String,
|
|
52
|
+
create_ts: i64,
|
|
53
|
+
ray_id: Id,
|
|
54
|
+
version: usize,
|
|
55
|
+
// Used for activity retry backoff
|
|
56
|
+
wake_deadline_ts: Option<i64>,
|
|
57
|
+
|
|
58
|
+
registry: RegistryHandle,
|
|
59
|
+
db: DatabaseHandle,
|
|
60
|
+
|
|
61
|
+
config: rivet_config::Config,
|
|
62
|
+
pools: rivet_pools::Pools,
|
|
63
|
+
cache: rivet_cache::Cache,
|
|
64
|
+
|
|
65
|
+
/// Input data passed to this workflow.
|
|
66
|
+
input: Arc<serde_json::value::RawValue>,
|
|
67
|
+
/// Data that can be manipulated via activities over the course of the workflows entire lifetime.
|
|
68
|
+
state: Arc<Mutex<Box<serde_json::value::RawValue>>>,
|
|
69
|
+
/// All events that have ever been recorded on this workflow.
|
|
70
|
+
event_history: History,
|
|
71
|
+
cursor: Cursor,
|
|
72
|
+
|
|
73
|
+
/// If this context is currently in a loop, this is the location of the where the loop started.
|
|
74
|
+
loop_location: Option<Location>,
|
|
75
|
+
|
|
76
|
+
msg_ctx: MessageCtx,
|
|
77
|
+
/// Used to stop workflow execution by the worker.
|
|
78
|
+
stop: watch::Receiver<()>,
|
|
79
|
+
|
|
80
|
+
/// Whether or not this ctx is used as part of a .join
|
|
81
|
+
parallelized: bool,
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
impl WorkflowCtx {
|
|
85
|
+
#[tracing::instrument(skip_all, fields(workflow_id=%data.workflow_id, workflow_name=%data.workflow_name, ray_id=%data.ray_id))]
|
|
86
|
+
pub fn new(
|
|
87
|
+
registry: RegistryHandle,
|
|
88
|
+
db: DatabaseHandle,
|
|
89
|
+
config: rivet_config::Config,
|
|
90
|
+
pools: rivet_pools::Pools,
|
|
91
|
+
cache: rivet_cache::Cache,
|
|
92
|
+
data: PulledWorkflowData,
|
|
93
|
+
stop: watch::Receiver<()>,
|
|
94
|
+
) -> Result<Self> {
|
|
95
|
+
let msg_ctx = MessageCtx::new(&config, &pools, &cache, data.ray_id)?;
|
|
96
|
+
let event_history = Arc::new(data.events);
|
|
97
|
+
|
|
98
|
+
Ok(WorkflowCtx {
|
|
99
|
+
workflow_id: data.workflow_id,
|
|
100
|
+
name: data.workflow_name,
|
|
101
|
+
create_ts: data.create_ts,
|
|
102
|
+
ray_id: data.ray_id,
|
|
103
|
+
version: 1,
|
|
104
|
+
wake_deadline_ts: data.wake_deadline_ts,
|
|
105
|
+
|
|
106
|
+
registry,
|
|
107
|
+
db,
|
|
108
|
+
|
|
109
|
+
config,
|
|
110
|
+
pools,
|
|
111
|
+
cache,
|
|
112
|
+
|
|
113
|
+
input: Arc::from(data.input),
|
|
114
|
+
state: Arc::new(Mutex::new(data.state)),
|
|
115
|
+
|
|
116
|
+
event_history: event_history.clone(),
|
|
117
|
+
cursor: Cursor::new(event_history, Location::empty()),
|
|
118
|
+
loop_location: None,
|
|
119
|
+
|
|
120
|
+
msg_ctx,
|
|
121
|
+
stop,
|
|
122
|
+
|
|
123
|
+
parallelized: false,
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/// Creates a workflow ctx reference with a given version.
|
|
128
|
+
pub fn v(&mut self, version: usize) -> VersionedWorkflowCtx<'_> {
|
|
129
|
+
VersionedWorkflowCtx::new(self, version)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/// Errors if the given version is less than the current version.
|
|
133
|
+
pub(crate) fn compare_version(
|
|
134
|
+
&self,
|
|
135
|
+
step: impl std::fmt::Display,
|
|
136
|
+
version: usize,
|
|
137
|
+
) -> WorkflowResult<()> {
|
|
138
|
+
if version < self.version {
|
|
139
|
+
Err(WorkflowError::HistoryDiverged(format!(
|
|
140
|
+
"version of {step} at {} is less than that of the current context (v{} < v{})",
|
|
141
|
+
version,
|
|
142
|
+
self.cursor.current_location(),
|
|
143
|
+
self.version,
|
|
144
|
+
)))
|
|
145
|
+
} else {
|
|
146
|
+
Ok(())
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
#[tracing::instrument(name="workflow", skip_all, fields(workflow_id=%self.workflow_id, workflow_name=%self.name, ray_id=%self.ray_id))]
|
|
151
|
+
pub(crate) async fn run(mut self, parent_span_ctx: SpanContext) -> WorkflowResult<()> {
|
|
152
|
+
tracing::Span::current().add_link(parent_span_ctx);
|
|
153
|
+
|
|
154
|
+
tracing::debug!("running workflow");
|
|
155
|
+
|
|
156
|
+
// Check for stop before running
|
|
157
|
+
self.check_stop()?;
|
|
158
|
+
|
|
159
|
+
// Lookup workflow
|
|
160
|
+
let workflow = self.registry.get_workflow(&self.name)?;
|
|
161
|
+
|
|
162
|
+
// Run workflow
|
|
163
|
+
let mut res = (workflow.run)(&mut self).await;
|
|
164
|
+
|
|
165
|
+
// Validate no leftover events
|
|
166
|
+
if res.is_ok() {
|
|
167
|
+
if let Err(err) = self.cursor().check_clear() {
|
|
168
|
+
res = Err(err);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
match res {
|
|
173
|
+
Ok(output) => {
|
|
174
|
+
tracing::debug!("workflow completed");
|
|
175
|
+
|
|
176
|
+
let mut retries = 0;
|
|
177
|
+
let mut interval = tokio::time::interval(DB_ACTION_RETRY);
|
|
178
|
+
interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
|
|
179
|
+
|
|
180
|
+
// Retry loop
|
|
181
|
+
loop {
|
|
182
|
+
interval.tick().await;
|
|
183
|
+
|
|
184
|
+
// Write output
|
|
185
|
+
if let Err(err) = self
|
|
186
|
+
.db
|
|
187
|
+
.complete_workflow(self.workflow_id, &self.name, &output)
|
|
188
|
+
.await
|
|
189
|
+
{
|
|
190
|
+
if retries > MAX_DB_ACTION_RETRIES {
|
|
191
|
+
return Err(err);
|
|
192
|
+
}
|
|
193
|
+
retries += 1;
|
|
194
|
+
} else {
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
Err(err) => {
|
|
200
|
+
let wake_immediate = err.wake_immediate();
|
|
201
|
+
|
|
202
|
+
// Retry the workflow if its recoverable
|
|
203
|
+
let wake_deadline_ts = if let Some(deadline_ts) = err.deadline_ts() {
|
|
204
|
+
Some(deadline_ts)
|
|
205
|
+
} else {
|
|
206
|
+
None
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
// These signals come from a `listen` call that did not receive any signals. The workflow will
|
|
210
|
+
// be retried when a signal is published
|
|
211
|
+
let wake_signals = err.signals();
|
|
212
|
+
|
|
213
|
+
// This sub workflow comes from a `wait_for_workflow` call on a workflow that did not
|
|
214
|
+
// finish. This workflow will be retried when the sub workflow completes
|
|
215
|
+
let wake_sub_workflow = err.sub_workflow();
|
|
216
|
+
|
|
217
|
+
if err.is_recoverable() && !err.is_retryable() {
|
|
218
|
+
tracing::debug!(?err, "workflow sleeping");
|
|
219
|
+
} else {
|
|
220
|
+
tracing::error!(?err, "workflow error");
|
|
221
|
+
|
|
222
|
+
metrics::WORKFLOW_ERRORS.add(
|
|
223
|
+
1,
|
|
224
|
+
&[
|
|
225
|
+
KeyValue::new("workflow_name", self.name.clone()),
|
|
226
|
+
KeyValue::new("error", err.to_string()),
|
|
227
|
+
],
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
let err_str = err.to_string();
|
|
232
|
+
|
|
233
|
+
let mut retries = 0;
|
|
234
|
+
let mut interval = tokio::time::interval(DB_ACTION_RETRY);
|
|
235
|
+
interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
|
|
236
|
+
|
|
237
|
+
// Retry loop
|
|
238
|
+
loop {
|
|
239
|
+
interval.tick().await;
|
|
240
|
+
|
|
241
|
+
// Write output
|
|
242
|
+
let res = self
|
|
243
|
+
.db
|
|
244
|
+
.commit_workflow(
|
|
245
|
+
self.workflow_id,
|
|
246
|
+
&self.name,
|
|
247
|
+
wake_immediate,
|
|
248
|
+
wake_deadline_ts,
|
|
249
|
+
wake_signals,
|
|
250
|
+
wake_sub_workflow,
|
|
251
|
+
&err_str,
|
|
252
|
+
)
|
|
253
|
+
.await;
|
|
254
|
+
|
|
255
|
+
if let Err(err) = res {
|
|
256
|
+
if retries > MAX_DB_ACTION_RETRIES {
|
|
257
|
+
return Err(err);
|
|
258
|
+
}
|
|
259
|
+
retries += 1;
|
|
260
|
+
} else {
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
Ok(())
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/// Run then handle the result of an activity.
|
|
271
|
+
#[tracing::instrument(skip_all, fields(activity_name=%A::NAME, %location))]
|
|
272
|
+
async fn run_activity<A: Activity>(
|
|
273
|
+
&mut self,
|
|
274
|
+
input: &A::Input,
|
|
275
|
+
location: &Location,
|
|
276
|
+
create_ts: i64,
|
|
277
|
+
) -> WorkflowResult<A::Output> {
|
|
278
|
+
tracing::debug!("running activity");
|
|
279
|
+
|
|
280
|
+
let ctx = ActivityCtx::new(
|
|
281
|
+
self.workflow_id,
|
|
282
|
+
self.name.clone(),
|
|
283
|
+
(*self
|
|
284
|
+
.state
|
|
285
|
+
.try_lock()
|
|
286
|
+
.map_err(|_| WorkflowError::WorkflowStateInaccessible("should not be locked"))?)
|
|
287
|
+
.to_owned(),
|
|
288
|
+
self.db.clone(),
|
|
289
|
+
&self.config,
|
|
290
|
+
&self.pools,
|
|
291
|
+
&self.cache,
|
|
292
|
+
create_ts,
|
|
293
|
+
self.ray_id,
|
|
294
|
+
A::NAME,
|
|
295
|
+
self.parallelized,
|
|
296
|
+
)?;
|
|
297
|
+
|
|
298
|
+
let start_instant = Instant::now();
|
|
299
|
+
|
|
300
|
+
let res = tokio::time::timeout(A::TIMEOUT, A::run(&ctx, input).in_current_span())
|
|
301
|
+
.await
|
|
302
|
+
.map_err(|_| WorkflowError::ActivityTimeout(0));
|
|
303
|
+
|
|
304
|
+
let dt = start_instant.elapsed().as_secs_f64();
|
|
305
|
+
|
|
306
|
+
match res {
|
|
307
|
+
Ok(Ok(output)) => {
|
|
308
|
+
tracing::debug!("activity success");
|
|
309
|
+
|
|
310
|
+
// Write output
|
|
311
|
+
let input_val = serde_json::value::to_raw_value(input)
|
|
312
|
+
.map_err(WorkflowError::SerializeActivityInput)?;
|
|
313
|
+
let output_val = serde_json::value::to_raw_value(&output)
|
|
314
|
+
.map_err(WorkflowError::SerializeActivityOutput)?;
|
|
315
|
+
|
|
316
|
+
tokio::try_join!(
|
|
317
|
+
self.db.commit_workflow_activity_event(
|
|
318
|
+
self.workflow_id,
|
|
319
|
+
location,
|
|
320
|
+
self.version,
|
|
321
|
+
A::NAME,
|
|
322
|
+
create_ts,
|
|
323
|
+
&input_val,
|
|
324
|
+
Ok(&output_val),
|
|
325
|
+
self.loop_location(),
|
|
326
|
+
),
|
|
327
|
+
async {
|
|
328
|
+
// Commit state if it was changed
|
|
329
|
+
if let Some(new_workflow_state) = ctx.into_new_workflow_state() {
|
|
330
|
+
let mut guard = self.state.try_lock().map_err(|_| {
|
|
331
|
+
WorkflowError::WorkflowStateInaccessible("should not be locked")
|
|
332
|
+
})?;
|
|
333
|
+
|
|
334
|
+
self.db
|
|
335
|
+
.update_workflow_state(self.workflow_id, &new_workflow_state)
|
|
336
|
+
.await?;
|
|
337
|
+
|
|
338
|
+
*guard = new_workflow_state;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
Ok(())
|
|
342
|
+
},
|
|
343
|
+
)?;
|
|
344
|
+
|
|
345
|
+
metrics::ACTIVITY_DURATION.record(
|
|
346
|
+
dt,
|
|
347
|
+
&[
|
|
348
|
+
KeyValue::new("workflow_name", self.name.clone()),
|
|
349
|
+
KeyValue::new("activity_name", A::NAME),
|
|
350
|
+
KeyValue::new("error_code", ""),
|
|
351
|
+
],
|
|
352
|
+
);
|
|
353
|
+
|
|
354
|
+
Ok(output)
|
|
355
|
+
}
|
|
356
|
+
Ok(Err(err)) => {
|
|
357
|
+
tracing::error!(?err, "activity error");
|
|
358
|
+
|
|
359
|
+
let err_str = err.to_string();
|
|
360
|
+
let input_val = serde_json::value::to_raw_value(input)
|
|
361
|
+
.map_err(WorkflowError::SerializeActivityInput)?;
|
|
362
|
+
|
|
363
|
+
// Write error (failed state)
|
|
364
|
+
self.db
|
|
365
|
+
.commit_workflow_activity_event(
|
|
366
|
+
self.workflow_id,
|
|
367
|
+
location,
|
|
368
|
+
self.version,
|
|
369
|
+
A::NAME,
|
|
370
|
+
create_ts,
|
|
371
|
+
&input_val,
|
|
372
|
+
Err(&err_str),
|
|
373
|
+
self.loop_location(),
|
|
374
|
+
)
|
|
375
|
+
.await?;
|
|
376
|
+
|
|
377
|
+
let is_recoverable = err
|
|
378
|
+
.chain()
|
|
379
|
+
.find_map(|x| x.downcast_ref::<WorkflowError>())
|
|
380
|
+
.map(|err| err.is_recoverable())
|
|
381
|
+
.unwrap_or_default();
|
|
382
|
+
|
|
383
|
+
if !is_recoverable {
|
|
384
|
+
metrics::ACTIVITY_ERRORS.add(
|
|
385
|
+
1,
|
|
386
|
+
&[
|
|
387
|
+
KeyValue::new("workflow_name", self.name.clone()),
|
|
388
|
+
KeyValue::new("activity_name", A::NAME),
|
|
389
|
+
KeyValue::new("error_code", err_str.clone()),
|
|
390
|
+
],
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
metrics::ACTIVITY_DURATION.record(
|
|
394
|
+
dt,
|
|
395
|
+
&[
|
|
396
|
+
KeyValue::new("workflow_name", self.name.clone()),
|
|
397
|
+
KeyValue::new("activity_name", A::NAME),
|
|
398
|
+
KeyValue::new("error_code", err_str.clone()),
|
|
399
|
+
],
|
|
400
|
+
);
|
|
401
|
+
|
|
402
|
+
Err(WorkflowError::ActivityFailure(err, 0))
|
|
403
|
+
}
|
|
404
|
+
Err(err) => {
|
|
405
|
+
tracing::debug!("activity timeout");
|
|
406
|
+
|
|
407
|
+
let err_str = err.to_string();
|
|
408
|
+
let input_val = serde_json::value::to_raw_value(input)
|
|
409
|
+
.map_err(WorkflowError::SerializeActivityInput)?;
|
|
410
|
+
|
|
411
|
+
self.db
|
|
412
|
+
.commit_workflow_activity_event(
|
|
413
|
+
self.workflow_id,
|
|
414
|
+
location,
|
|
415
|
+
self.version,
|
|
416
|
+
A::NAME,
|
|
417
|
+
create_ts,
|
|
418
|
+
&input_val,
|
|
419
|
+
Err(&err_str),
|
|
420
|
+
self.loop_location(),
|
|
421
|
+
)
|
|
422
|
+
.await?;
|
|
423
|
+
|
|
424
|
+
metrics::ACTIVITY_ERRORS.add(
|
|
425
|
+
1,
|
|
426
|
+
&[
|
|
427
|
+
KeyValue::new("workflow_name", self.name.clone()),
|
|
428
|
+
KeyValue::new("activity_name", A::NAME),
|
|
429
|
+
KeyValue::new("error_code", err_str.clone()),
|
|
430
|
+
],
|
|
431
|
+
);
|
|
432
|
+
metrics::ACTIVITY_DURATION.record(
|
|
433
|
+
dt,
|
|
434
|
+
&[
|
|
435
|
+
KeyValue::new("workflow_name", self.name.clone()),
|
|
436
|
+
KeyValue::new("activity_name", A::NAME),
|
|
437
|
+
KeyValue::new("error_code", err_str.clone()),
|
|
438
|
+
],
|
|
439
|
+
);
|
|
440
|
+
|
|
441
|
+
Err(err)
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
#[tracing::instrument(skip_all)]
|
|
447
|
+
pub(crate) fn set_parallelized(&mut self) {
|
|
448
|
+
self.parallelized = true;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/// Creates a new workflow run with one more depth in the location.
|
|
452
|
+
/// - **Not to be used directly by workflow users. For implementation uses only.**
|
|
453
|
+
/// - **Remember to validate latent history after this branch is used.**
|
|
454
|
+
#[tracing::instrument(skip_all)]
|
|
455
|
+
pub async fn branch(&mut self) -> WorkflowResult<Self> {
|
|
456
|
+
self.custom_branch(self.input.clone(), self.version).await
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
#[tracing::instrument(skip_all, fields(version))]
|
|
460
|
+
pub(crate) async fn custom_branch(
|
|
461
|
+
&mut self,
|
|
462
|
+
input: Arc<serde_json::value::RawValue>,
|
|
463
|
+
version: usize,
|
|
464
|
+
) -> WorkflowResult<Self> {
|
|
465
|
+
let history_res = self.cursor.compare_branch(version)?;
|
|
466
|
+
let location = self.cursor.current_location_for(&history_res);
|
|
467
|
+
|
|
468
|
+
// Validate history is consistent
|
|
469
|
+
if !matches!(history_res, HistoryResult::Event(_)) {
|
|
470
|
+
self.db
|
|
471
|
+
.commit_workflow_branch_event(
|
|
472
|
+
self.workflow_id,
|
|
473
|
+
&location,
|
|
474
|
+
version,
|
|
475
|
+
self.loop_location.as_ref(),
|
|
476
|
+
)
|
|
477
|
+
.await?;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
Ok(self.branch_inner(input, version, location))
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/// `custom_branch` with no history validation.
|
|
484
|
+
pub(crate) fn branch_inner(
|
|
485
|
+
&mut self,
|
|
486
|
+
input: Arc<serde_json::value::RawValue>,
|
|
487
|
+
version: usize,
|
|
488
|
+
location: Location,
|
|
489
|
+
) -> WorkflowCtx {
|
|
490
|
+
WorkflowCtx {
|
|
491
|
+
workflow_id: self.workflow_id,
|
|
492
|
+
name: self.name.clone(),
|
|
493
|
+
create_ts: self.create_ts,
|
|
494
|
+
ray_id: self.ray_id,
|
|
495
|
+
version,
|
|
496
|
+
wake_deadline_ts: self.wake_deadline_ts,
|
|
497
|
+
|
|
498
|
+
registry: self.registry.clone(),
|
|
499
|
+
db: self.db.clone(),
|
|
500
|
+
|
|
501
|
+
config: self.config.clone(),
|
|
502
|
+
pools: self.pools.clone(),
|
|
503
|
+
cache: self.cache.clone(),
|
|
504
|
+
|
|
505
|
+
input,
|
|
506
|
+
state: self.state.clone(),
|
|
507
|
+
|
|
508
|
+
event_history: self.event_history.clone(),
|
|
509
|
+
cursor: Cursor::new(self.event_history.clone(), location),
|
|
510
|
+
loop_location: self.loop_location.clone(),
|
|
511
|
+
|
|
512
|
+
msg_ctx: self.msg_ctx.clone(),
|
|
513
|
+
stop: self.stop.clone(),
|
|
514
|
+
|
|
515
|
+
parallelized: self.parallelized,
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/// Like `branch` but it does not add another layer of depth.
|
|
520
|
+
pub fn step(&mut self) -> Self {
|
|
521
|
+
let branch = self.clone();
|
|
522
|
+
|
|
523
|
+
self.cursor.inc();
|
|
524
|
+
|
|
525
|
+
branch
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
pub(crate) fn check_stop(&self) -> WorkflowResult<()> {
|
|
529
|
+
if self.stop.has_changed().unwrap_or(true) {
|
|
530
|
+
Err(WorkflowError::WorkflowEvicted)
|
|
531
|
+
} else {
|
|
532
|
+
Ok(())
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
pub(crate) async fn wait_stop(&self) -> WorkflowResult<()> {
|
|
537
|
+
// We have to clone here because this function can't have a mutable reference to self. The state of
|
|
538
|
+
// the stop channel doesn't matter because it only ever receives one message
|
|
539
|
+
let _ = self.stop.clone().changed().await;
|
|
540
|
+
Err(WorkflowError::WorkflowEvicted)
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
impl WorkflowCtx {
|
|
545
|
+
/// Creates a sub workflow builder.
|
|
546
|
+
pub fn workflow<I>(
|
|
547
|
+
&mut self,
|
|
548
|
+
input: impl WorkflowRepr<I>,
|
|
549
|
+
) -> builder::sub_workflow::SubWorkflowBuilder<'_, impl WorkflowRepr<I>, I>
|
|
550
|
+
where
|
|
551
|
+
I: WorkflowInput,
|
|
552
|
+
<I as WorkflowInput>::Workflow: Workflow<Input = I>,
|
|
553
|
+
{
|
|
554
|
+
builder::sub_workflow::SubWorkflowBuilder::new(self, self.version, input)
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/// Run activity. Will replay on failure.
|
|
558
|
+
#[tracing::instrument(skip_all, fields(activity_name=%I::Activity::NAME))]
|
|
559
|
+
pub async fn activity<I>(
|
|
560
|
+
&mut self,
|
|
561
|
+
input: I,
|
|
562
|
+
) -> Result<<<I as ActivityInput>::Activity as Activity>::Output>
|
|
563
|
+
where
|
|
564
|
+
I: ActivityInput,
|
|
565
|
+
<I as ActivityInput>::Activity: Activity<Input = I>,
|
|
566
|
+
{
|
|
567
|
+
self.check_stop()?;
|
|
568
|
+
|
|
569
|
+
let history_res = self
|
|
570
|
+
.cursor
|
|
571
|
+
.compare_activity(self.version, I::Activity::NAME)?;
|
|
572
|
+
let location = self.cursor.current_location_for(&history_res);
|
|
573
|
+
|
|
574
|
+
// Activity was ran before
|
|
575
|
+
let output = if let HistoryResult::Event(activity) = history_res {
|
|
576
|
+
tracing::debug!("replaying activity");
|
|
577
|
+
|
|
578
|
+
// Activity succeeded
|
|
579
|
+
if let Some(output) = activity.parse_output()? {
|
|
580
|
+
output
|
|
581
|
+
}
|
|
582
|
+
// Activity failed, retry
|
|
583
|
+
else {
|
|
584
|
+
let error_count = activity.error_count;
|
|
585
|
+
|
|
586
|
+
// Backoff
|
|
587
|
+
if let Some(wake_deadline_ts) = self.wake_deadline_ts {
|
|
588
|
+
tracing::debug!("sleeping for activity backoff");
|
|
589
|
+
|
|
590
|
+
let duration = (u64::try_from(wake_deadline_ts)?)
|
|
591
|
+
.saturating_sub(u64::try_from(rivet_util::timestamp::now())?);
|
|
592
|
+
tokio::time::sleep(Duration::from_millis(duration))
|
|
593
|
+
.instrument(tracing::info_span!("backoff_sleep"))
|
|
594
|
+
.await;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
match self
|
|
598
|
+
.run_activity::<I::Activity>(&input, &location, activity.create_ts)
|
|
599
|
+
.await
|
|
600
|
+
{
|
|
601
|
+
Err(err) => {
|
|
602
|
+
// Convert error in the case of max retries exceeded. This will only act on retryable
|
|
603
|
+
// errors
|
|
604
|
+
let err = match err {
|
|
605
|
+
WorkflowError::ActivityFailure(err, _) => {
|
|
606
|
+
if error_count.saturating_add(1) >= I::Activity::MAX_RETRIES {
|
|
607
|
+
WorkflowError::ActivityMaxFailuresReached(err)
|
|
608
|
+
} else {
|
|
609
|
+
// Add error count to the error for backoff calculation
|
|
610
|
+
WorkflowError::ActivityFailure(err, error_count)
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
WorkflowError::ActivityTimeout(_) => {
|
|
614
|
+
if error_count.saturating_add(1) >= I::Activity::MAX_RETRIES {
|
|
615
|
+
WorkflowError::ActivityMaxFailuresReached(err.into())
|
|
616
|
+
} else {
|
|
617
|
+
// Add error count to the error for backoff calculation
|
|
618
|
+
WorkflowError::ActivityTimeout(error_count)
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
WorkflowError::OperationTimeout(_) => {
|
|
622
|
+
if error_count.saturating_add(1) >= I::Activity::MAX_RETRIES {
|
|
623
|
+
WorkflowError::ActivityMaxFailuresReached(err.into())
|
|
624
|
+
} else {
|
|
625
|
+
// Add error count to the error for backoff calculation
|
|
626
|
+
WorkflowError::OperationTimeout(error_count)
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
_ => err,
|
|
630
|
+
};
|
|
631
|
+
|
|
632
|
+
return Err(err.into());
|
|
633
|
+
}
|
|
634
|
+
x => x?,
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
// This is a new activity
|
|
639
|
+
else {
|
|
640
|
+
self.run_activity::<I::Activity>(&input, &location, rivet_util::timestamp::now())
|
|
641
|
+
.await?
|
|
642
|
+
};
|
|
643
|
+
|
|
644
|
+
// Move to next event
|
|
645
|
+
self.cursor.update(&location);
|
|
646
|
+
|
|
647
|
+
Ok(output)
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/// Joins multiple executable actions (activities, closures) and awaits them simultaneously. This does not
|
|
651
|
+
/// short circuit in the event of an error to make sure activity side effects are recorded.
|
|
652
|
+
#[tracing::instrument(skip_all)]
|
|
653
|
+
pub async fn join<T: Executable>(&mut self, exec: T) -> Result<T::Output> {
|
|
654
|
+
self.check_stop()?;
|
|
655
|
+
|
|
656
|
+
exec.execute(self).await
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
// TODO: Replace with some method on WorkflowError
|
|
660
|
+
// /// Tests if the given error is unrecoverable. If it is, allows the user to run recovery code safely.
|
|
661
|
+
// /// Should always be used when trying to handle activity errors manually.
|
|
662
|
+
// #[tracing::instrument(skip_all)]
|
|
663
|
+
// pub fn catch_unrecoverable<T>(&mut self, res: Result<T>) -> Result<Result<T>> {
|
|
664
|
+
// match res {
|
|
665
|
+
// Err(err) => {
|
|
666
|
+
// // TODO: This should check .chain() for the error
|
|
667
|
+
// match err.downcast::<WorkflowError>() {
|
|
668
|
+
// Ok(inner_err) => {
|
|
669
|
+
// // Despite "history diverged" errors being unrecoverable, they should not have be returned
|
|
670
|
+
// // by this function because the state of the history is already messed up and no new
|
|
671
|
+
// // workflow items should be run.
|
|
672
|
+
// if !inner_err.is_recoverable()
|
|
673
|
+
// && !matches!(inner_err, WorkflowError::HistoryDiverged(_))
|
|
674
|
+
// {
|
|
675
|
+
// self.cursor.inc();
|
|
676
|
+
|
|
677
|
+
// Ok(Err(inner_err.into()))
|
|
678
|
+
// } else {
|
|
679
|
+
// Err(inner_err.into())
|
|
680
|
+
// }
|
|
681
|
+
// }
|
|
682
|
+
// Err(err) => Err(err),
|
|
683
|
+
// }
|
|
684
|
+
// }
|
|
685
|
+
// Ok(x) => Ok(Ok(x)),
|
|
686
|
+
// }
|
|
687
|
+
// }
|
|
688
|
+
|
|
689
|
+
/// Creates a signal builder.
|
|
690
|
+
pub fn signal<T: Signal + Serialize>(
|
|
691
|
+
&mut self,
|
|
692
|
+
body: T,
|
|
693
|
+
) -> builder::signal::SignalBuilder<'_, T> {
|
|
694
|
+
builder::signal::SignalBuilder::new(self, self.version, body)
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/// Listens for a signal for a short time before setting the workflow to sleep. Once the signal is
|
|
698
|
+
/// received, the workflow will be woken up and continue.
|
|
699
|
+
#[tracing::instrument(skip_all, fields(t=std::any::type_name::<T>()))]
|
|
700
|
+
pub async fn listen<T: Listen>(&mut self) -> Result<T> {
|
|
701
|
+
self.check_stop()?;
|
|
702
|
+
|
|
703
|
+
let history_res = self.cursor.compare_signal(self.version)?;
|
|
704
|
+
let location = self.cursor.current_location_for(&history_res);
|
|
705
|
+
|
|
706
|
+
// Signal received before
|
|
707
|
+
let signal = if let HistoryResult::Event(signal) = history_res {
|
|
708
|
+
tracing::debug!(
|
|
709
|
+
signal_name=%signal.name,
|
|
710
|
+
"replaying signal"
|
|
711
|
+
);
|
|
712
|
+
|
|
713
|
+
T::parse(&signal.name, &signal.body)?
|
|
714
|
+
}
|
|
715
|
+
// Listen for new signal
|
|
716
|
+
else {
|
|
717
|
+
tracing::debug!("listening for signal");
|
|
718
|
+
|
|
719
|
+
let mut bump_sub = self
|
|
720
|
+
.db
|
|
721
|
+
.bump_sub(BumpSubSubject::SignalPublish {
|
|
722
|
+
to_workflow_id: self.workflow_id,
|
|
723
|
+
})
|
|
724
|
+
.await?;
|
|
725
|
+
let mut retries = self.db.max_signal_poll_retries();
|
|
726
|
+
let mut interval = tokio::time::interval(self.db.signal_poll_interval());
|
|
727
|
+
interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
|
|
728
|
+
|
|
729
|
+
// Skip first tick, we wait after the db call instead of before
|
|
730
|
+
interval.tick().await;
|
|
731
|
+
|
|
732
|
+
let mut ctx = ListenCtx::new(self, &location);
|
|
733
|
+
|
|
734
|
+
loop {
|
|
735
|
+
ctx.reset(retries == 0);
|
|
736
|
+
|
|
737
|
+
match T::listen(&mut ctx).in_current_span().await {
|
|
738
|
+
Ok(res) => break res,
|
|
739
|
+
Err(err) if matches!(err, WorkflowError::NoSignalFound(_)) => {
|
|
740
|
+
if retries == 0 {
|
|
741
|
+
return Err(err.into());
|
|
742
|
+
}
|
|
743
|
+
retries -= 1;
|
|
744
|
+
}
|
|
745
|
+
Err(err) => return Err(err.into()),
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
// Poll and wait for a wake at the same time
|
|
749
|
+
tokio::select! {
|
|
750
|
+
_ = bump_sub.next() => {},
|
|
751
|
+
_ = interval.tick() => {},
|
|
752
|
+
res = self.wait_stop() => res?,
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
};
|
|
756
|
+
|
|
757
|
+
// Move to next event
|
|
758
|
+
self.cursor.update(&location);
|
|
759
|
+
|
|
760
|
+
Ok(signal)
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
/// Execute a custom listener.
|
|
764
|
+
#[tracing::instrument(skip_all, fields(t=std::any::type_name::<T>()))]
|
|
765
|
+
pub async fn custom_listener<T: CustomListener>(
|
|
766
|
+
&mut self,
|
|
767
|
+
listener: &T,
|
|
768
|
+
) -> Result<<T as CustomListener>::Output> {
|
|
769
|
+
self.check_stop()?;
|
|
770
|
+
|
|
771
|
+
let history_res = self.cursor.compare_signal(self.version)?;
|
|
772
|
+
let location = self.cursor.current_location_for(&history_res);
|
|
773
|
+
|
|
774
|
+
// Signal received before
|
|
775
|
+
let signal = if let HistoryResult::Event(signal) = history_res {
|
|
776
|
+
tracing::debug!(
|
|
777
|
+
signal_name=%signal.name,
|
|
778
|
+
"replaying signal",
|
|
779
|
+
);
|
|
780
|
+
|
|
781
|
+
T::parse(&signal.name, &signal.body)?
|
|
782
|
+
}
|
|
783
|
+
// Listen for new signal
|
|
784
|
+
else {
|
|
785
|
+
tracing::debug!("listening for signal");
|
|
786
|
+
|
|
787
|
+
let mut bump_sub = self
|
|
788
|
+
.db
|
|
789
|
+
.bump_sub(BumpSubSubject::SignalPublish {
|
|
790
|
+
to_workflow_id: self.workflow_id,
|
|
791
|
+
})
|
|
792
|
+
.await?;
|
|
793
|
+
let mut retries = self.db.max_signal_poll_retries();
|
|
794
|
+
let mut interval = tokio::time::interval(self.db.signal_poll_interval());
|
|
795
|
+
interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
|
|
796
|
+
|
|
797
|
+
// Skip first tick, we wait after the db call instead of before
|
|
798
|
+
interval.tick().await;
|
|
799
|
+
|
|
800
|
+
let mut ctx = ListenCtx::new(self, &location);
|
|
801
|
+
|
|
802
|
+
loop {
|
|
803
|
+
ctx.reset(retries == 0);
|
|
804
|
+
|
|
805
|
+
match listener.listen(&mut ctx).in_current_span().await {
|
|
806
|
+
Ok(res) => break res,
|
|
807
|
+
Err(err) if matches!(err, WorkflowError::NoSignalFound(_)) => {
|
|
808
|
+
if retries == 0 {
|
|
809
|
+
return Err(err.into());
|
|
810
|
+
}
|
|
811
|
+
retries -= 1;
|
|
812
|
+
}
|
|
813
|
+
Err(err) => return Err(err.into()),
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
// Poll and wait for a wake at the same time
|
|
817
|
+
tokio::select! {
|
|
818
|
+
_ = bump_sub.next() => {},
|
|
819
|
+
_ = interval.tick() => {},
|
|
820
|
+
res = self.wait_stop() => res?,
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
|
|
825
|
+
// Move to next event
|
|
826
|
+
self.cursor.update(&location);
|
|
827
|
+
|
|
828
|
+
Ok(signal)
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
/// Creates a message builder.
|
|
832
|
+
pub fn msg<M: Message>(&mut self, body: M) -> builder::message::MessageBuilder<'_, M> {
|
|
833
|
+
builder::message::MessageBuilder::new(self, self.version, body)
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
/// Runs workflow steps in a loop. If you need side causes, use `WorkflowCtx::loope`.
|
|
837
|
+
#[tracing::instrument(skip_all)]
|
|
838
|
+
pub async fn repeat<F, T>(&mut self, mut cb: F) -> Result<T>
|
|
839
|
+
where
|
|
840
|
+
F: for<'a> FnMut(&'a mut WorkflowCtx) -> AsyncResult<'a, Loop<T>>,
|
|
841
|
+
T: Serialize + DeserializeOwned,
|
|
842
|
+
{
|
|
843
|
+
self.loop_inner((), |ctx, _| cb(ctx))
|
|
844
|
+
.in_current_span()
|
|
845
|
+
.await
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
/// Runs workflow steps in a loop with state.
|
|
849
|
+
#[tracing::instrument(skip_all)]
|
|
850
|
+
pub async fn loope<S, F, T>(&mut self, state: S, cb: F) -> Result<T>
|
|
851
|
+
where
|
|
852
|
+
S: Serialize + DeserializeOwned,
|
|
853
|
+
F: for<'a> FnMut(&'a mut WorkflowCtx, &'a mut S) -> AsyncResult<'a, Loop<T>>,
|
|
854
|
+
T: Serialize + DeserializeOwned,
|
|
855
|
+
{
|
|
856
|
+
self.loop_inner(state, cb).in_current_span().await
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
async fn loop_inner<S, F, T>(&mut self, state: S, mut cb: F) -> Result<T>
|
|
860
|
+
where
|
|
861
|
+
S: Serialize + DeserializeOwned,
|
|
862
|
+
F: for<'a> FnMut(&'a mut WorkflowCtx, &'a mut S) -> AsyncResult<'a, Loop<T>>,
|
|
863
|
+
T: Serialize + DeserializeOwned,
|
|
864
|
+
{
|
|
865
|
+
self.check_stop()?;
|
|
866
|
+
|
|
867
|
+
let history_res = self.cursor.compare_loop(self.version)?;
|
|
868
|
+
let loop_location = self.cursor.current_location_for(&history_res);
|
|
869
|
+
|
|
870
|
+
// Loop existed before
|
|
871
|
+
let (mut iteration, mut state, output) =
|
|
872
|
+
if let HistoryResult::Event(loop_event) = history_res {
|
|
873
|
+
let state = loop_event.parse_state()?;
|
|
874
|
+
let output = loop_event.parse_output()?;
|
|
875
|
+
|
|
876
|
+
(loop_event.iteration, state, output)
|
|
877
|
+
} else {
|
|
878
|
+
let state_val = serde_json::value::to_raw_value(&state)
|
|
879
|
+
.map_err(WorkflowError::SerializeLoopOutput)?;
|
|
880
|
+
|
|
881
|
+
// Insert event before loop is run so the history is consistent
|
|
882
|
+
self.db
|
|
883
|
+
.upsert_workflow_loop_event(
|
|
884
|
+
self.workflow_id,
|
|
885
|
+
&self.name,
|
|
886
|
+
&loop_location,
|
|
887
|
+
self.version,
|
|
888
|
+
0,
|
|
889
|
+
&state_val,
|
|
890
|
+
None,
|
|
891
|
+
self.loop_location(),
|
|
892
|
+
)
|
|
893
|
+
.await?;
|
|
894
|
+
|
|
895
|
+
(0, state, None)
|
|
896
|
+
};
|
|
897
|
+
|
|
898
|
+
// Create a branch but no branch event (loop event takes its place)
|
|
899
|
+
let mut loop_branch =
|
|
900
|
+
self.branch_inner(self.input.clone(), self.version, loop_location.clone());
|
|
901
|
+
|
|
902
|
+
// Loop complete
|
|
903
|
+
let output = if let Some(output) = output {
|
|
904
|
+
tracing::debug!("replaying loop output");
|
|
905
|
+
|
|
906
|
+
output
|
|
907
|
+
}
|
|
908
|
+
// Run loop
|
|
909
|
+
else {
|
|
910
|
+
tracing::debug!("running loop");
|
|
911
|
+
|
|
912
|
+
loop {
|
|
913
|
+
self.check_stop()?;
|
|
914
|
+
|
|
915
|
+
let start_instant = Instant::now();
|
|
916
|
+
|
|
917
|
+
// Create a new branch for each iteration of the loop at location {...loop location, iteration idx}
|
|
918
|
+
let mut iteration_branch = loop_branch.branch_inner(
|
|
919
|
+
self.input.clone(),
|
|
920
|
+
self.version,
|
|
921
|
+
loop_branch
|
|
922
|
+
.cursor
|
|
923
|
+
.root()
|
|
924
|
+
.join(Coordinate::simple(iteration + 1)),
|
|
925
|
+
);
|
|
926
|
+
|
|
927
|
+
// Set branch loop location to the current loop
|
|
928
|
+
iteration_branch.loop_location = Some(loop_location.clone());
|
|
929
|
+
|
|
930
|
+
let i = iteration;
|
|
931
|
+
|
|
932
|
+
// Async block for instrumentation purposes
|
|
933
|
+
let (dt2, res) = async {
|
|
934
|
+
// Insert event if iteration is not a replay
|
|
935
|
+
if !loop_branch.cursor.compare_loop_branch(iteration)? {
|
|
936
|
+
self.db
|
|
937
|
+
.commit_workflow_branch_event(
|
|
938
|
+
self.workflow_id,
|
|
939
|
+
iteration_branch.cursor.root(),
|
|
940
|
+
self.version,
|
|
941
|
+
Some(&loop_location),
|
|
942
|
+
)
|
|
943
|
+
.await?;
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
let start_instant2 = Instant::now();
|
|
947
|
+
|
|
948
|
+
// Run loop
|
|
949
|
+
match cb(&mut iteration_branch, &mut state).await? {
|
|
950
|
+
Loop::Continue => {
|
|
951
|
+
let dt2 = start_instant2.elapsed().as_secs_f64();
|
|
952
|
+
iteration += 1;
|
|
953
|
+
|
|
954
|
+
let state_val = serde_json::value::to_raw_value(&state)
|
|
955
|
+
.map_err(WorkflowError::SerializeLoopOutput)?;
|
|
956
|
+
|
|
957
|
+
self.db
|
|
958
|
+
.upsert_workflow_loop_event(
|
|
959
|
+
self.workflow_id,
|
|
960
|
+
&self.name,
|
|
961
|
+
&loop_location,
|
|
962
|
+
self.version,
|
|
963
|
+
iteration,
|
|
964
|
+
&state_val,
|
|
965
|
+
None,
|
|
966
|
+
self.loop_location(),
|
|
967
|
+
)
|
|
968
|
+
.await?;
|
|
969
|
+
|
|
970
|
+
anyhow::Ok((dt2, None))
|
|
971
|
+
}
|
|
972
|
+
Loop::Break(res) => {
|
|
973
|
+
let dt2 = start_instant2.elapsed().as_secs_f64();
|
|
974
|
+
iteration += 1;
|
|
975
|
+
|
|
976
|
+
let state_val = serde_json::value::to_raw_value(&state)
|
|
977
|
+
.map_err(WorkflowError::SerializeLoopOutput)?;
|
|
978
|
+
let output_val = serde_json::value::to_raw_value(&res)
|
|
979
|
+
.map_err(WorkflowError::SerializeLoopOutput)?;
|
|
980
|
+
|
|
981
|
+
self.db
|
|
982
|
+
.upsert_workflow_loop_event(
|
|
983
|
+
self.workflow_id,
|
|
984
|
+
&self.name,
|
|
985
|
+
&loop_location,
|
|
986
|
+
self.version,
|
|
987
|
+
iteration,
|
|
988
|
+
&state_val,
|
|
989
|
+
Some(&output_val),
|
|
990
|
+
self.loop_location(),
|
|
991
|
+
)
|
|
992
|
+
.await?;
|
|
993
|
+
|
|
994
|
+
Ok((dt2, Some(res)))
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
.instrument(tracing::info_span!("iteration", iteration=%i))
|
|
999
|
+
.await?;
|
|
1000
|
+
|
|
1001
|
+
// Validate no leftover events
|
|
1002
|
+
iteration_branch.cursor.check_clear()?;
|
|
1003
|
+
|
|
1004
|
+
let dt = start_instant.elapsed().as_secs_f64();
|
|
1005
|
+
metrics::LOOP_ITERATION_DURATION.record(
|
|
1006
|
+
dt - dt2,
|
|
1007
|
+
&[KeyValue::new("workflow_name", self.name.clone())],
|
|
1008
|
+
);
|
|
1009
|
+
|
|
1010
|
+
if let Some(res) = res {
|
|
1011
|
+
break res;
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
};
|
|
1015
|
+
|
|
1016
|
+
// Move to next event
|
|
1017
|
+
self.cursor.update(&loop_location);
|
|
1018
|
+
|
|
1019
|
+
Ok(output)
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
#[tracing::instrument(skip_all)]
|
|
1023
|
+
pub async fn sleep(&mut self, duration: impl DurationToMillis) -> Result<()> {
|
|
1024
|
+
let ts = rivet_util::timestamp::now() as u64 + duration.to_millis()?;
|
|
1025
|
+
|
|
1026
|
+
self.sleep_until(ts as i64).await
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
#[tracing::instrument(skip_all, fields(duration))]
|
|
1030
|
+
pub async fn sleep_until(&mut self, time: impl TsToMillis) -> Result<()> {
|
|
1031
|
+
self.check_stop()?;
|
|
1032
|
+
|
|
1033
|
+
let history_res = self.cursor.compare_sleep(self.version)?;
|
|
1034
|
+
let location = self.cursor.current_location_for(&history_res);
|
|
1035
|
+
|
|
1036
|
+
// Slept before
|
|
1037
|
+
let (deadline_ts, replay) = if let HistoryResult::Event(sleep) = history_res {
|
|
1038
|
+
tracing::debug!("replaying sleep");
|
|
1039
|
+
|
|
1040
|
+
(sleep.deadline_ts, true)
|
|
1041
|
+
}
|
|
1042
|
+
// Sleep
|
|
1043
|
+
else {
|
|
1044
|
+
let deadline_ts = time.to_millis()?;
|
|
1045
|
+
|
|
1046
|
+
self.db
|
|
1047
|
+
.commit_workflow_sleep_event(
|
|
1048
|
+
self.workflow_id,
|
|
1049
|
+
&location,
|
|
1050
|
+
self.version,
|
|
1051
|
+
deadline_ts,
|
|
1052
|
+
self.loop_location(),
|
|
1053
|
+
)
|
|
1054
|
+
.await?;
|
|
1055
|
+
|
|
1056
|
+
(deadline_ts, false)
|
|
1057
|
+
};
|
|
1058
|
+
|
|
1059
|
+
let duration = deadline_ts.saturating_sub(rivet_util::timestamp::now());
|
|
1060
|
+
tracing::Span::current().record("duration", &duration);
|
|
1061
|
+
|
|
1062
|
+
// No-op
|
|
1063
|
+
if duration <= 0 {
|
|
1064
|
+
if !replay && duration < -25 {
|
|
1065
|
+
tracing::warn!(%duration, "tried to sleep for a negative duration");
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
// Sleep in memory if duration is shorter than the worker tick
|
|
1069
|
+
else if duration < self.db.worker_poll_interval().as_millis() as i64 + 1 {
|
|
1070
|
+
tracing::debug!(%deadline_ts, "sleeping in memory");
|
|
1071
|
+
|
|
1072
|
+
tokio::select! {
|
|
1073
|
+
_ = tokio::time::sleep(Duration::from_millis(duration.try_into()?)) => {},
|
|
1074
|
+
res = self.wait_stop() => res?,
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
// Workflow sleep
|
|
1078
|
+
else {
|
|
1079
|
+
tracing::debug!(%deadline_ts, "sleeping");
|
|
1080
|
+
|
|
1081
|
+
return Err(WorkflowError::Sleep(deadline_ts).into());
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
// Move to next event
|
|
1085
|
+
self.cursor.update(&location);
|
|
1086
|
+
|
|
1087
|
+
Ok(())
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
/// Listens for a signal with a timeout. Returns `None` if the timeout is reached.
|
|
1091
|
+
///
|
|
1092
|
+
/// Internally this is a sleep event and a signal event.
|
|
1093
|
+
#[tracing::instrument(skip_all, fields(t=std::any::type_name::<T>()))]
|
|
1094
|
+
pub async fn listen_with_timeout<T: Listen>(
|
|
1095
|
+
&mut self,
|
|
1096
|
+
duration: impl DurationToMillis,
|
|
1097
|
+
) -> Result<Option<T>> {
|
|
1098
|
+
let time = (rivet_util::timestamp::now() as u64 + duration.to_millis()?) as i64;
|
|
1099
|
+
|
|
1100
|
+
self.listen_until(time).await
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
// TODO: Potential bad transaction: if the signal gets pulled and saved in history but an error occurs
|
|
1104
|
+
// before the sleep event state is set to "interrupted", the next time this workflow is run it will error
|
|
1105
|
+
// because it tries to pull a signal again
|
|
1106
|
+
/// Listens for a signal until the given timestamp. Returns `None` if the timestamp is reached.
|
|
1107
|
+
///
|
|
1108
|
+
/// Internally this is a sleep event and a signal event.
|
|
1109
|
+
#[tracing::instrument(skip_all, fields(t=std::any::type_name::<T>(), duration))]
|
|
1110
|
+
pub async fn listen_until<T: Listen>(&mut self, time: impl TsToMillis) -> Result<Option<T>> {
|
|
1111
|
+
self.check_stop()?;
|
|
1112
|
+
|
|
1113
|
+
let history_res = self.cursor.compare_sleep(self.version)?;
|
|
1114
|
+
let history_res2 = history_res.equivalent();
|
|
1115
|
+
let sleep_location = self.cursor.current_location_for(&history_res);
|
|
1116
|
+
|
|
1117
|
+
// Slept before
|
|
1118
|
+
let (deadline_ts, state) = if let HistoryResult::Event(sleep) = history_res {
|
|
1119
|
+
tracing::debug!("replaying sleep");
|
|
1120
|
+
|
|
1121
|
+
(sleep.deadline_ts, sleep.state)
|
|
1122
|
+
}
|
|
1123
|
+
// Sleep
|
|
1124
|
+
else {
|
|
1125
|
+
let deadline_ts = TsToMillis::to_millis(time)?;
|
|
1126
|
+
|
|
1127
|
+
self.db
|
|
1128
|
+
.commit_workflow_sleep_event(
|
|
1129
|
+
self.workflow_id,
|
|
1130
|
+
&sleep_location,
|
|
1131
|
+
self.version,
|
|
1132
|
+
deadline_ts,
|
|
1133
|
+
self.loop_location(),
|
|
1134
|
+
)
|
|
1135
|
+
.await?;
|
|
1136
|
+
|
|
1137
|
+
(deadline_ts, SleepState::Normal)
|
|
1138
|
+
};
|
|
1139
|
+
|
|
1140
|
+
// Move to next event
|
|
1141
|
+
self.cursor.update(&sleep_location);
|
|
1142
|
+
|
|
1143
|
+
// Signal received before
|
|
1144
|
+
if matches!(state, SleepState::Interrupted) {
|
|
1145
|
+
let history_res = self.cursor.compare_signal(self.version)?;
|
|
1146
|
+
let signal_location = self.cursor.current_location_for(&history_res);
|
|
1147
|
+
|
|
1148
|
+
if let HistoryResult::Event(signal) = history_res {
|
|
1149
|
+
tracing::debug!(
|
|
1150
|
+
signal_name=%signal.name,
|
|
1151
|
+
"replaying signal",
|
|
1152
|
+
);
|
|
1153
|
+
|
|
1154
|
+
let signal = T::parse(&signal.name, &signal.body)?;
|
|
1155
|
+
|
|
1156
|
+
// Move to next event
|
|
1157
|
+
self.cursor.update(&signal_location);
|
|
1158
|
+
|
|
1159
|
+
// Short circuit
|
|
1160
|
+
return Ok(Some(signal));
|
|
1161
|
+
} else {
|
|
1162
|
+
return Err(WorkflowError::HistoryDiverged(format!(
|
|
1163
|
+
"expected signal at {}, found nothing",
|
|
1164
|
+
signal_location,
|
|
1165
|
+
))
|
|
1166
|
+
.into());
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
// Location of the signal event (comes after the sleep event)
|
|
1171
|
+
let signal_location = self.cursor.current_location_for(&history_res2);
|
|
1172
|
+
let duration = deadline_ts.saturating_sub(rivet_util::timestamp::now());
|
|
1173
|
+
tracing::Span::current().record("duration", &duration);
|
|
1174
|
+
|
|
1175
|
+
// Duration is now 0, timeout is over
|
|
1176
|
+
let signal = if duration <= 0 {
|
|
1177
|
+
// After timeout is over, check once for signal
|
|
1178
|
+
if matches!(state, SleepState::Normal) {
|
|
1179
|
+
let mut ctx = ListenCtx::new(self, &signal_location);
|
|
1180
|
+
|
|
1181
|
+
match T::listen(&mut ctx).in_current_span().await {
|
|
1182
|
+
Ok(x) => Some(x),
|
|
1183
|
+
Err(WorkflowError::NoSignalFound(_)) => None,
|
|
1184
|
+
Err(err) => return Err(err.into()),
|
|
1185
|
+
}
|
|
1186
|
+
} else {
|
|
1187
|
+
None
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
// Sleep in memory if duration is shorter than the worker tick
|
|
1191
|
+
else if duration < self.db.worker_poll_interval().as_millis() as i64 + 1 {
|
|
1192
|
+
tracing::debug!(%deadline_ts, "sleeping in memory");
|
|
1193
|
+
|
|
1194
|
+
let res = tokio::time::timeout(
|
|
1195
|
+
Duration::from_millis(duration.try_into()?),
|
|
1196
|
+
(async {
|
|
1197
|
+
tracing::debug!("listening for signal with timeout");
|
|
1198
|
+
|
|
1199
|
+
let mut bump_sub = self
|
|
1200
|
+
.db
|
|
1201
|
+
.bump_sub(BumpSubSubject::SignalPublish {
|
|
1202
|
+
to_workflow_id: self.workflow_id,
|
|
1203
|
+
})
|
|
1204
|
+
.await?;
|
|
1205
|
+
let mut interval = tokio::time::interval(self.db.signal_poll_interval());
|
|
1206
|
+
interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
|
|
1207
|
+
|
|
1208
|
+
// Skip first tick, we wait after the db call instead of before
|
|
1209
|
+
interval.tick().await;
|
|
1210
|
+
|
|
1211
|
+
let mut ctx = ListenCtx::new(self, &signal_location);
|
|
1212
|
+
|
|
1213
|
+
loop {
|
|
1214
|
+
ctx.reset(false);
|
|
1215
|
+
|
|
1216
|
+
match T::listen(&mut ctx).in_current_span().await {
|
|
1217
|
+
// Retry
|
|
1218
|
+
Err(WorkflowError::NoSignalFound(_)) => {}
|
|
1219
|
+
x => return x,
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
// Poll and wait for a wake at the same time
|
|
1223
|
+
tokio::select! {
|
|
1224
|
+
_ = bump_sub.next() => {},
|
|
1225
|
+
_ = interval.tick() => {},
|
|
1226
|
+
res = self.wait_stop() => res?,
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
})
|
|
1230
|
+
.in_current_span(),
|
|
1231
|
+
)
|
|
1232
|
+
.await;
|
|
1233
|
+
|
|
1234
|
+
match res {
|
|
1235
|
+
Ok(res) => Some(res?),
|
|
1236
|
+
Err(_) => {
|
|
1237
|
+
tracing::debug!("timed out listening for signal");
|
|
1238
|
+
|
|
1239
|
+
None
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
// Workflow sleep for long durations
|
|
1244
|
+
else {
|
|
1245
|
+
tracing::debug!("listening for signal with timeout");
|
|
1246
|
+
|
|
1247
|
+
let mut bump_sub = self
|
|
1248
|
+
.db
|
|
1249
|
+
.bump_sub(BumpSubSubject::SignalPublish {
|
|
1250
|
+
to_workflow_id: self.workflow_id,
|
|
1251
|
+
})
|
|
1252
|
+
.await?;
|
|
1253
|
+
let mut retries = self.db.max_signal_poll_retries();
|
|
1254
|
+
let mut interval = tokio::time::interval(self.db.signal_poll_interval());
|
|
1255
|
+
interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
|
|
1256
|
+
|
|
1257
|
+
// Skip first tick, we wait after the db call instead of before
|
|
1258
|
+
interval.tick().await;
|
|
1259
|
+
|
|
1260
|
+
let mut ctx = ListenCtx::new(self, &signal_location);
|
|
1261
|
+
|
|
1262
|
+
loop {
|
|
1263
|
+
ctx.reset(retries == 0);
|
|
1264
|
+
|
|
1265
|
+
match T::listen(&mut ctx).in_current_span().await {
|
|
1266
|
+
Ok(res) => break Some(res),
|
|
1267
|
+
Err(WorkflowError::NoSignalFound(signals)) => {
|
|
1268
|
+
if retries == 0 {
|
|
1269
|
+
return Err(
|
|
1270
|
+
WorkflowError::NoSignalFoundAndSleep(signals, deadline_ts).into()
|
|
1271
|
+
);
|
|
1272
|
+
}
|
|
1273
|
+
retries -= 1;
|
|
1274
|
+
}
|
|
1275
|
+
Err(err) => return Err(err.into()),
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
// Poll and wait for a wake at the same time
|
|
1279
|
+
tokio::select! {
|
|
1280
|
+
_ = bump_sub.next() => {},
|
|
1281
|
+
_ = interval.tick() => {},
|
|
1282
|
+
res = self.wait_stop() => res?,
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
};
|
|
1286
|
+
|
|
1287
|
+
// Update sleep state
|
|
1288
|
+
if signal.is_some() {
|
|
1289
|
+
self.db
|
|
1290
|
+
.update_workflow_sleep_event_state(
|
|
1291
|
+
self.workflow_id,
|
|
1292
|
+
&sleep_location,
|
|
1293
|
+
SleepState::Interrupted,
|
|
1294
|
+
)
|
|
1295
|
+
.await?;
|
|
1296
|
+
|
|
1297
|
+
// Move to next event
|
|
1298
|
+
self.cursor.update(&signal_location);
|
|
1299
|
+
} else if matches!(state, SleepState::Normal) {
|
|
1300
|
+
self.db
|
|
1301
|
+
.update_workflow_sleep_event_state(
|
|
1302
|
+
self.workflow_id,
|
|
1303
|
+
&sleep_location,
|
|
1304
|
+
SleepState::Uninterrupted,
|
|
1305
|
+
)
|
|
1306
|
+
.await?;
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
Ok(signal)
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
/// Represents a removed workflow step.
|
|
1313
|
+
#[tracing::instrument(skip_all, fields(t=std::any::type_name::<T>()))]
|
|
1314
|
+
pub async fn removed<T: Removed>(&mut self) -> Result<()> {
|
|
1315
|
+
self.check_stop()?;
|
|
1316
|
+
|
|
1317
|
+
// Existing event
|
|
1318
|
+
if self.cursor.compare_removed::<T>()? {
|
|
1319
|
+
tracing::debug!("skipping removed step",);
|
|
1320
|
+
}
|
|
1321
|
+
// New "removed" event
|
|
1322
|
+
else {
|
|
1323
|
+
tracing::debug!("inserting removed step");
|
|
1324
|
+
|
|
1325
|
+
self.db
|
|
1326
|
+
.commit_workflow_removed_event(
|
|
1327
|
+
self.workflow_id,
|
|
1328
|
+
&self.cursor.current_location(),
|
|
1329
|
+
T::event_type(),
|
|
1330
|
+
T::name(),
|
|
1331
|
+
self.loop_location(),
|
|
1332
|
+
)
|
|
1333
|
+
.await?;
|
|
1334
|
+
};
|
|
1335
|
+
|
|
1336
|
+
// Move to next event
|
|
1337
|
+
self.cursor.inc();
|
|
1338
|
+
|
|
1339
|
+
Ok(())
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
/// Returns the version of the current event in history. If no event exists, returns `current_version` and
|
|
1343
|
+
/// inserts a version check event.
|
|
1344
|
+
#[tracing::instrument(skip_all, fields(current_version))]
|
|
1345
|
+
pub async fn check_version(&mut self, current_version: usize) -> Result<usize> {
|
|
1346
|
+
self.check_stop()?;
|
|
1347
|
+
|
|
1348
|
+
if current_version == 0 {
|
|
1349
|
+
return Err(WorkflowError::InvalidVersion(
|
|
1350
|
+
"version for `check_version` must be greater than 0".into(),
|
|
1351
|
+
)
|
|
1352
|
+
.into());
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
let (is_version_check, version) =
|
|
1356
|
+
if let Some((is_version_check, step_version)) = self.cursor.compare_version_check()? {
|
|
1357
|
+
tracing::debug!("checking existing version");
|
|
1358
|
+
|
|
1359
|
+
(is_version_check, step_version)
|
|
1360
|
+
} else {
|
|
1361
|
+
tracing::debug!("inserting version check");
|
|
1362
|
+
|
|
1363
|
+
self.db
|
|
1364
|
+
.commit_workflow_version_check_event(
|
|
1365
|
+
self.workflow_id,
|
|
1366
|
+
&self.cursor.current_location(),
|
|
1367
|
+
current_version + self.version - 1,
|
|
1368
|
+
self.loop_location(),
|
|
1369
|
+
)
|
|
1370
|
+
.await?;
|
|
1371
|
+
|
|
1372
|
+
(true, current_version)
|
|
1373
|
+
};
|
|
1374
|
+
|
|
1375
|
+
if is_version_check {
|
|
1376
|
+
// Move to next event
|
|
1377
|
+
self.cursor.inc();
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
Ok(version + 1 - self.version)
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
impl WorkflowCtx {
|
|
1385
|
+
pub(crate) fn input(&self) -> &Arc<serde_json::value::RawValue> {
|
|
1386
|
+
&self.input
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
pub(crate) fn loop_location(&self) -> Option<&Location> {
|
|
1390
|
+
self.loop_location.as_ref()
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
pub(crate) fn db(&self) -> &DatabaseHandle {
|
|
1394
|
+
&self.db
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
pub(crate) fn msg_ctx(&self) -> &MessageCtx {
|
|
1398
|
+
&self.msg_ctx
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
pub(crate) fn cursor(&self) -> &Cursor {
|
|
1402
|
+
&self.cursor
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
pub(crate) fn cursor_mut(&mut self) -> &mut Cursor {
|
|
1406
|
+
&mut self.cursor
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
pub fn name(&self) -> &str {
|
|
1410
|
+
&self.name
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
pub fn workflow_id(&self) -> Id {
|
|
1414
|
+
self.workflow_id
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
pub fn ray_id(&self) -> Id {
|
|
1418
|
+
self.ray_id
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
// Not public because this only denotes the version of the context, use `check_version` instead.
|
|
1422
|
+
pub(crate) fn version(&self) -> usize {
|
|
1423
|
+
self.version
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
pub(crate) fn set_version(&mut self, version: usize) {
|
|
1427
|
+
self.version = version;
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
/// Timestamp at which the workflow was created.
|
|
1431
|
+
pub fn create_ts(&self) -> i64 {
|
|
1432
|
+
self.create_ts
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
pub fn pools(&self) -> &rivet_pools::Pools {
|
|
1436
|
+
&self.pools
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
pub fn cache(&self) -> &rivet_cache::Cache {
|
|
1440
|
+
&self.cache
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
pub fn config(&self) -> &rivet_config::Config {
|
|
1444
|
+
&self.config
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
impl Deref for WorkflowCtx {
|
|
1449
|
+
type Target = rivet_pools::Pools;
|
|
1450
|
+
|
|
1451
|
+
fn deref(&self) -> &Self::Target {
|
|
1452
|
+
&self.pools
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
pub enum Loop<T> {
|
|
1457
|
+
Continue,
|
|
1458
|
+
Break(T),
|
|
1459
|
+
}
|