Skip to content

Commit ecfc769

Browse files
ldanilekConvex, Inc.
authored andcommitted
[ENG-6866] schedule child functions from parent component (#27800)
scheduled jobs have a component & udf path which is for the function that is scheduled to run. separately, they were scheduled from a component which may be different. GitOrigin-RevId: 4b3de87f80bac38f6ee7f2c78cd8b5d944db9706
1 parent 7dd6cdb commit ecfc769

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

src/server/impl/actions_impl.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ function syscallArgs(
1010
functionReference: any,
1111
args?: Record<string, Value>,
1212
) {
13+
const address = getFunctionAddress(functionReference);
14+
return {
15+
...address,
16+
args: convexToJson(parseArgs(args)),
17+
version,
18+
requestId,
19+
};
20+
}
21+
22+
export function getFunctionAddress(functionReference: any) {
1323
// The `run*` syscalls expect either a UDF path at "name" or a serialized
1424
// reference at "reference". Dispatch on `functionReference` to coerce
1525
// it to one ore the other.
@@ -32,12 +42,7 @@ function syscallArgs(
3242
}
3343
functionAddress = { reference: referencePath };
3444
}
35-
return {
36-
...functionAddress,
37-
args: convexToJson(parseArgs(args)),
38-
version,
39-
requestId,
40-
};
45+
return functionAddress;
4146
}
4247

4348
export function setupActionCalls(requestId: string) {

src/server/impl/scheduler_impl.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { version } from "../../index.js";
33
import { performAsyncSyscall } from "./syscall.js";
44
import { parseArgs } from "../../common/index.js";
55
import { SchedulableFunctionReference, Scheduler } from "../scheduler.js";
6-
import { getFunctionName } from "../../server/api.js";
76
import { Id } from "../../values/value.js";
87
import { validateArg } from "./validate.js";
8+
import { getFunctionAddress } from "./actions_impl.js";
99

1010
export function setupMutationScheduler(): Scheduler {
1111
return {
@@ -84,11 +84,11 @@ function runAfterSyscallArgs(
8484
throw new Error("`delayMs` must be non-negative");
8585
}
8686
const functionArgs = parseArgs(args);
87-
const name = getFunctionName(functionReference);
87+
const address = getFunctionAddress(functionReference);
8888
// Note the syscall expects a unix timestamp, measured in seconds.
8989
const ts = (Date.now() + delayMs) / 1000.0;
9090
return {
91-
name,
91+
...address,
9292
ts,
9393
args: convexToJson(functionArgs),
9494
version,
@@ -110,10 +110,10 @@ function runAtSyscallArgs(
110110
} else {
111111
throw new Error("The invoke time must a Date or a timestamp");
112112
}
113-
const name = getFunctionName(functionReference);
113+
const address = getFunctionAddress(functionReference);
114114
const functionArgs = parseArgs(args);
115115
return {
116-
name,
116+
...address,
117117
ts,
118118
args: convexToJson(functionArgs),
119119
version,

0 commit comments

Comments
 (0)