Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.

Commit c0e2e94

Browse files
authored
feat(core): configure actor region (#1384)
1 parent 433d74c commit c0e2e94

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

packages/rivetkit/src/drivers/engine/actor-driver.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type {
2+
ActorConfig as EngineActorConfig,
23
RunnerConfig as EngineRunnerConfig,
3-
ActorConfig as RunnerActorConfig,
44
} from "@rivetkit/engine-runner";
55
import { Runner } from "@rivetkit/engine-runner";
66
import * as cbor from "cbor-x";
@@ -220,20 +220,20 @@ export class EngineActorDriver implements ActorDriver {
220220
async #runnerOnActorStart(
221221
actorId: string,
222222
generation: number,
223-
runConfig: RunnerActorConfig,
223+
actorConfig: EngineActorConfig,
224224
): Promise<void> {
225225
logger().debug({
226226
msg: "runner actor starting",
227227
actorId,
228-
name: runConfig.name,
229-
key: runConfig.key,
228+
name: actorConfig.name,
229+
key: actorConfig.key,
230230
generation,
231231
});
232232

233233
// Deserialize input
234234
let input: any;
235-
if (runConfig.input) {
236-
input = cbor.decode(runConfig.input);
235+
if (actorConfig.input) {
236+
input = cbor.decode(actorConfig.input);
237237
}
238238

239239
// Get or create handler
@@ -259,12 +259,12 @@ export class EngineActorDriver implements ActorDriver {
259259
: serializeEmptyPersistData(input);
260260
}
261261

262-
const name = runConfig.name as string;
263-
invariant(runConfig.key, "actor should have a key");
264-
const key = deserializeActorKey(runConfig.key);
262+
const name = actorConfig.name as string;
263+
invariant(actorConfig.key, "actor should have a key");
264+
const key = deserializeActorKey(actorConfig.key);
265265

266266
// Create actor instance
267-
const definition = lookupInRegistry(this.#registryConfig, runConfig.name);
267+
const definition = lookupInRegistry(this.#registryConfig, actorConfig.name);
268268
handler.actor = definition.instantiate();
269269

270270
// Start actor

packages/rivetkit/src/manager-api/actors.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export type ActorsListResponse = z.infer<typeof ActorsListResponseSchema>;
2323

2424
// MARK: POST /actors
2525
export const ActorsCreateRequestSchema = z.object({
26+
datacenter: z.string().optional(),
2627
name: z.string(),
2728
runner_name_selector: z.string(),
2829
crash_policy: z.string(),
@@ -38,6 +39,7 @@ export type ActorsCreateResponse = z.infer<typeof ActorsCreateResponseSchema>;
3839

3940
// MARK: PUT /actors
4041
export const ActorsGetOrCreateRequestSchema = z.object({
42+
datacenter: z.string().optional(),
4143
name: z.string(),
4244
key: z.string(),
4345
runner_name_selector: z.string(),

packages/rivetkit/src/remote-manager-driver/mod.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ export class RemoteManagerDriver implements ManagerDriver {
218218
});
219219

220220
const { actor, created } = await getOrCreateActor(this.#config, {
221+
datacenter: region,
221222
name,
222223
key: serializeActorKey(key),
223224
runner_name_selector: this.#config.runnerName,
@@ -249,6 +250,7 @@ export class RemoteManagerDriver implements ManagerDriver {
249250
name,
250251
key,
251252
input,
253+
region,
252254
}: CreateInput): Promise<ActorOutput> {
253255
// Wait for metadata check to complete if in progress
254256
if (this.#metadataPromise) {
@@ -259,6 +261,7 @@ export class RemoteManagerDriver implements ManagerDriver {
259261

260262
// Create actor via engine API
261263
const result = await createActor(this.#config, {
264+
datacenter: region,
262265
name,
263266
runner_name_selector: this.#config.runnerName,
264267
key: serializeActorKey(key),

0 commit comments

Comments
 (0)