File tree Expand file tree Collapse file tree 6 files changed +14
-1
lines changed
packages/core/src/v3/runEngineWorker/supervisor Expand file tree Collapse file tree 6 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ const Env = z.object({
31
31
// Dequeue settings (provider mode)
32
32
TRIGGER_DEQUEUE_ENABLED : BoolEnv . default ( "true" ) ,
33
33
TRIGGER_DEQUEUE_INTERVAL_MS : z . coerce . number ( ) . int ( ) . default ( 1000 ) ,
34
+ TRIGGER_DEQUEUE_MAX_RUN_COUNT : z . coerce . number ( ) . int ( ) . default ( 10 ) ,
34
35
35
36
// Optional services
36
37
TRIGGER_WARM_START_URL : z . string ( ) . optional ( ) ,
Original file line number Diff line number Diff line change @@ -113,6 +113,7 @@ class ManagedSupervisor {
113
113
managedWorkerSecret : env . MANAGED_WORKER_SECRET ,
114
114
dequeueIntervalMs : env . TRIGGER_DEQUEUE_INTERVAL_MS ,
115
115
queueConsumerEnabled : env . TRIGGER_DEQUEUE_ENABLED ,
116
+ maxRunCount : env . TRIGGER_DEQUEUE_MAX_RUN_COUNT ,
116
117
runNotificationsEnabled : env . TRIGGER_WORKLOAD_API_ENABLED ,
117
118
preDequeue : async ( ) => {
118
119
if ( this . isKubernetes ) {
Original file line number Diff line number Diff line change 1
1
import { json , TypedResponse } from "@remix-run/server-runtime" ;
2
- import { WorkerApiDequeueRequestBody , WorkerApiDequeueResponseBody } from "@trigger.dev/core/v3/workers" ;
2
+ import {
3
+ WorkerApiDequeueRequestBody ,
4
+ WorkerApiDequeueResponseBody ,
5
+ } from "@trigger.dev/core/v3/workers" ;
3
6
import { createActionWorkerApiRoute } from "~/services/routeBuilders/apiBuilder.server" ;
4
7
5
8
export const action = createActionWorkerApiRoute (
@@ -10,6 +13,7 @@ export const action = createActionWorkerApiRoute(
10
13
return json (
11
14
await authenticatedWorker . dequeue ( {
12
15
maxResources : body . maxResources ,
16
+ maxRunCount : body . maxRunCount ,
13
17
} )
14
18
) ;
15
19
}
Original file line number Diff line number Diff line change @@ -7,13 +7,15 @@ type RunQueueConsumerOptions = {
7
7
intervalMs ?: number ;
8
8
preDequeue ?: PreDequeueFn ;
9
9
preSkip ?: PreSkipFn ;
10
+ maxRunCount ?: number ;
10
11
onDequeue : ( messages : WorkerApiDequeueResponseBody ) => Promise < void > ;
11
12
} ;
12
13
13
14
export class RunQueueConsumer {
14
15
private readonly client : SupervisorHttpClient ;
15
16
private readonly preDequeue ?: PreDequeueFn ;
16
17
private readonly preSkip ?: PreSkipFn ;
18
+ private readonly maxRunCount ?: number ;
17
19
private readonly onDequeue : ( messages : WorkerApiDequeueResponseBody ) => Promise < void > ;
18
20
19
21
private intervalMs : number ;
@@ -24,6 +26,7 @@ export class RunQueueConsumer {
24
26
this . intervalMs = opts . intervalMs ?? 5_000 ;
25
27
this . preDequeue = opts . preDequeue ;
26
28
this . preSkip = opts . preSkip ;
29
+ this . maxRunCount = opts . maxRunCount ;
27
30
this . onDequeue = opts . onDequeue ;
28
31
this . client = opts . client ;
29
32
}
@@ -87,6 +90,7 @@ export class RunQueueConsumer {
87
90
try {
88
91
const response = await this . client . dequeue ( {
89
92
maxResources : preDequeueResult ?. maxResources ,
93
+ maxRunCount : this . maxRunCount ,
90
94
} ) ;
91
95
92
96
if ( ! response . success ) {
Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ export type WorkerApiConnectResponseBody = z.infer<typeof WorkerApiConnectRespon
66
66
67
67
export const WorkerApiDequeueRequestBody = z . object ( {
68
68
maxResources : MachineResources . optional ( ) ,
69
+ maxRunCount : z . number ( ) . optional ( ) ,
69
70
} ) ;
70
71
export type WorkerApiDequeueRequestBody = z . infer < typeof WorkerApiDequeueRequestBody > ;
71
72
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ type SupervisorSessionOptions = SupervisorClientCommonOptions & {
17
17
dequeueIntervalMs ?: number ;
18
18
preDequeue ?: PreDequeueFn ;
19
19
preSkip ?: PreSkipFn ;
20
+ maxRunCount ?: number ;
20
21
} ;
21
22
22
23
export class SupervisorSession extends EventEmitter < WorkerEvents > {
@@ -44,6 +45,7 @@ export class SupervisorSession extends EventEmitter<WorkerEvents> {
44
45
preSkip : opts . preSkip ,
45
46
onDequeue : this . onDequeue . bind ( this ) ,
46
47
intervalMs : opts . dequeueIntervalMs ,
48
+ maxRunCount : opts . maxRunCount ,
47
49
} ) ;
48
50
49
51
// TODO: This should be dynamic and set by (or at least overridden by) the platform
You can’t perform that action at this time.
0 commit comments