MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / SPACETIMEDB_REDUCER

Function SPACETIMEDB_REDUCER

modules/sdk-test-procedure-cpp/src/lib.cpp:226–238  ·  view source on GitHub ↗

Reducer that schedules the scheduled_proc procedure

Source from the content-addressed store, hash-verified

224
225// Reducer that schedules the scheduled_proc procedure
226SPACETIMEDB_REDUCER(schedule_proc, ReducerContext ctx) {
227 LOG_INFO("schedule_proc called at timestamp: " + std::to_string(ctx.timestamp.micros_since_epoch()));
228 // Schedule the procedure to run in 1s (1000ms = 1,000,000 microseconds)
229 ctx.db[scheduled_proc_table].insert(ScheduledProcTable{
230 0, // scheduled_id (auto-incremented)
231 ScheduleAt(TimeDuration::from_micros(1000000)), // 1 second from now
232 ctx.timestamp, // Store the timestamp at which this reducer was called
233 42, // x
234 24 // y
235 });
236
237 return Ok();
238}
239
240// Procedure that should be called 1s after schedule_proc
241SPACETIMEDB_PROCEDURE(Unit, scheduled_proc, ProcedureContext ctx, ScheduledProcTable data) {

Callers

nothing calls this directly

Calls 5

insertMethod · 0.65
to_stringFunction · 0.50
ScheduleAtEnum · 0.50
OkFunction · 0.50
micros_since_epochMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…