mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-07-25 19:41:58 -04:00
7acce2ce4b
Closes: https://github.com/clockworklabs/SpacetimeDB/issues/4571 - The secondary issue specifically # Description of Changes - Added new `onSchedule` optional parameter for `reducers` and `procedures` as suggested by @cloutiertyler to move towards reactive reducers - Enforced at most one scheduled `reducer`/`procedure` per schedule table - Kept the existing `table({ scheduled })` path working - Moved `ScheduleAt` column tracking onto table metadata - Lets the new schedule API resolve schedule-at columns without relying on legacy table options - Kept `schedule.scheduleAtCol` for compatibility # Other Options Considered - Add new additive API `.schedule()` - Was the first implementation of this branch but was the wrong direction for the future - Rust-inspired schedule token/name handle - Closest conceptual match to Rust: table stores a schedule descriptor/name and the reducer binds the implementation separately - Avoids importing reducers from table definitions and could preserve type checking if the token carries the row type - Adds more API surface and abstraction, and needs careful design to avoid users managing fragile names manually - `scheduled: 'reducerName'` string/name in `table(...)` - Very simple and closest to the raw module-def storage model - Fully breaks the runtime import cycle - Loses compile-time signature checking unless paired with another checker/registration API, and typos become runtime/module validation errors - This basically is what we had before 2.0 # API and ABI breaking changes - Adds new TypeScript options to `.reducer()` and `.procedure()` for `onSchedule` - No intended breaking changes to existing `table({ scheduled })` behavior # Expected complexity level and risk 3 - Preserving legacy scheduled table behavior while changing how schedule metadata is assembled # Testing - [x] Added new tests to cover the legacy schedule and new registration - [x] Updated module-test-ts coverage to show both legacy and new reducer scheduling - [x] Ran a local throwaway test project to test before and after for both legacy + new api