Skip to content

Commit b2166bc

Browse files
committed
make supervisor heartbeat interval configurable
1 parent 4b0af15 commit b2166bc

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

apps/supervisor/src/env.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { AdditionalEnvVars, BoolEnv } from "./envUtil.js";
66
const Env = z.object({
77
// This will come from `spec.nodeName` in k8s
88
TRIGGER_WORKER_INSTANCE_NAME: z.string().default(randomUUID()),
9+
TRIGGER_WORKER_HEARTBEAT_INTERVAL_SECONDS: z.coerce.number().default(30),
910

1011
// Required settings
1112
TRIGGER_API_URL: z.string().url(),

apps/supervisor/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ class ManagedSupervisor {
121121
maxRunCount: env.TRIGGER_DEQUEUE_MAX_RUN_COUNT,
122122
maxConsumerCount: env.TRIGGER_DEQUEUE_MAX_CONSUMER_COUNT,
123123
runNotificationsEnabled: env.TRIGGER_WORKLOAD_API_ENABLED,
124+
heartbeatIntervalSeconds: env.TRIGGER_WORKER_HEARTBEAT_INTERVAL_SECONDS,
124125
preDequeue: async () => {
125126
if (this.isKubernetes) {
126127
// Not used in k8s for now

packages/core/src/v3/runEngineWorker/supervisor/session.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { IntervalService } from "../../utils/interval.js";
1313
type SupervisorSessionOptions = SupervisorClientCommonOptions & {
1414
queueConsumerEnabled?: boolean;
1515
runNotificationsEnabled?: boolean;
16-
heartbeatIntervalSeconds?: number;
16+
heartbeatIntervalSeconds: number;
1717
dequeueIntervalMs: number;
1818
dequeueIdleIntervalMs: number;
1919
preDequeue?: PreDequeueFn;
@@ -32,7 +32,6 @@ export class SupervisorSession extends EventEmitter<WorkerEvents> {
3232
private readonly queueConsumers: RunQueueConsumer[];
3333

3434
private readonly heartbeat: IntervalService;
35-
private readonly heartbeatIntervalSeconds: number;
3635

3736
constructor(private opts: SupervisorSessionOptions) {
3837
super();
@@ -53,7 +52,6 @@ export class SupervisorSession extends EventEmitter<WorkerEvents> {
5352
});
5453
});
5554

56-
this.heartbeatIntervalSeconds = opts.heartbeatIntervalSeconds || 30;
5755
this.heartbeat = new IntervalService({
5856
onInterval: async () => {
5957
console.debug("[SupervisorSession] Sending heartbeat");
@@ -65,7 +63,7 @@ export class SupervisorSession extends EventEmitter<WorkerEvents> {
6563
console.error("[SupervisorSession] Heartbeat failed", { error: response.error });
6664
}
6765
},
68-
intervalMs: this.heartbeatIntervalSeconds * 1000,
66+
intervalMs: opts.heartbeatIntervalSeconds * 1000,
6967
leadingEdge: false,
7068
onError: async (error) => {
7169
console.error("[SupervisorSession] Failed to send heartbeat", { error });

0 commit comments

Comments
 (0)