Additive schedule registration for TypeScript for file-splitting#5435
Additive schedule registration for TypeScript for file-splitting#5435JasonAtClockwork wants to merge 9 commits into
Conversation
|
For context, the solution that @coolreader18 and I discussed was to allow you to specify on the reducer, the table you wanted to schedule to. The one detail is that we would need to enforce (at least for now), that at most (and perhaps exactly) one reducer was subscribed to a schedule table. The reason being is that the calling order would not be well defined, and we didn't want people to rely on whatever order we end up calling them in. So that would look like this: const scheduledMessages = table({public: true}, {
scheduledId: t.u64().primaryKey().autoInc(),
scheduledAt: t.scheduleAt(),
text: t.string(),
});
const spacetimedb = schema({ scheduledMessages });
spacetime.reducer({ on_schedule = spacetimedb.scheduledMessages });
// or something similarThe idea was that it would align with the future reactive reducers envisioned in: https://github.com/clockworklabs/SpacetimeDBPrivate/pull/2862 This change would also be an additive change. Also please add any new syntax we go with to the |
I've completely refactored the PR to move in this direction as I did go with |
|
|
| scheduled: (): any => repeatingTest, | ||
| }, | ||
| repeatingTestArg | ||
| ), |
There was a problem hiding this comment.
Can we please keep both the old and new syntax since the old syntax is still supported?
There was a problem hiding this comment.
What I've done is have one of the scheduled tests left as the legacy and one with the new structure. repeatingTest is set up with the new, and nonrepeatingTest is set up with the original:
// nonrepeating_test_arg table with legacy scheduled(nonrepeating_test)
nonrepeatingTestArg: table(
{
name: 'nonrepeating_test_arg',
scheduled: (): any => nonrepeatingTest,
},
nonrepeatingTestArg
),With how module-test is set up for ensure_schema between Rust and TypeScript it's less churn to not add a new test everywhere.
cloutiertyler
left a comment
There was a problem hiding this comment.
This now LGTM but with an important comment about module-test-ts that I'd like to address.
Closes: #4571 - The secondary issue specifically
Description of Changes
onScheduleoptional parameter forreducersandproceduresas suggested by @cloutiertyler to move towards reactive reducersreducer/procedureper schedule tabletable({ scheduled })path workingScheduleAtcolumn tracking onto table metadataschedule.scheduleAtColfor compatibilityOther Options Considered
.schedule()scheduled: 'reducerName'string/name intable(...)API and ABI breaking changes
.reducer()and.procedure()foronScheduletable({ scheduled })behaviorExpected complexity level and risk
3 - Preserving legacy scheduled table behavior while changing how schedule metadata is assembled
Testing