This repository was archived by the owner on Oct 22, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +17
-9
lines changed Expand file tree Collapse file tree 4 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ export const ClientConfigSchema = z.object({
1919 . optional ( )
2020 . transform ( ( x ) => x ?? getEnvUniversal ( "RIVET_TOKEN" ) ) ,
2121
22+ totalSlots : z . number ( ) . optional ( ) ,
23+
2224 headers : z . record ( z . string ( ) ) . optional ( ) . default ( { } ) ,
2325
2426 /** Endpoint to connect to the Rivet engine. Can be configured via RIVET_ENGINE env var. */
Original file line number Diff line number Diff line change @@ -90,10 +90,10 @@ export class EngineActorDriver implements ActorDriver {
9090 const runnerConfig : RunnerConfig = {
9191 version : this . #version,
9292 endpoint : config . endpoint ,
93- token : config . token ,
93+ token : runConfig . token ?? config . token ,
9494 pegboardEndpoint : config . pegboardEndpoint ,
9595 namespace : config . namespace ,
96- totalSlots : config . totalSlots ,
96+ totalSlots : runConfig . totalSlots ?? config . totalSlots ,
9797 runnerName : config . runnerName ,
9898 runnerKey : config . runnerKey ,
9999 metadata : {
Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ export function createManagerRouter(
105105}
106106
107107function addServerlessRoutes (
108- serverlessActorDriverBuilder : ( token : string | undefined ) => ActorDriver ,
108+ serverlessActorDriverBuilder : ( token : string | undefined , totalSlots : number | undefined ) => ActorDriver ,
109109 router : OpenAPIHono ,
110110 cors : MiddlewareHandler ,
111111) {
@@ -118,9 +118,11 @@ function addServerlessRoutes(
118118
119119 // Serverless start endpoint
120120 router . get ( "/start" , cors , async ( c ) => {
121- const actorDriver = serverlessActorDriverBuilder (
122- c . req . header ( "x-rivet-token" ) ,
123- ) ;
121+ let token = c . req . header ( "x-rivet-token" ) ;
122+ let totalSlots : number | undefined = parseInt ( c . req . header ( "x-rivetkit-total-slots" ) as any ) ;
123+ if ( isNaN ( totalSlots ) ) totalSlots = undefined ;
124+
125+ const actorDriver = serverlessActorDriverBuilder ( token , totalSlots ) ;
124126 invariant (
125127 actorDriver . serverlessHandleStart ,
126128 "missing serverlessHandleStart on ActorDriver" ,
Original file line number Diff line number Diff line change @@ -216,10 +216,14 @@ export class Registry<A extends RegistryActors> {
216216 }
217217
218218 let serverlessActorDriverBuilder :
219- | ( ( token ?: string ) => ActorDriver )
220- | undefined = ( token : string | undefined ) => {
221- // Override config token if one was set
219+ | ( ( token ?: string , totalSlots ?: number ) => ActorDriver )
220+ | undefined = (
221+ token : string | undefined ,
222+ totalSlots : number | undefined ,
223+ ) => {
224+ // Override config
222225 if ( token ) config . token = token ;
226+ if ( totalSlots ) config . totalSlots = totalSlots ;
223227
224228 return driver . actor ( this . #config, config , managerDriver , client ) ;
225229 } ;
You can’t perform that action at this time.
0 commit comments