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

Commit b5072fd

Browse files
committed
chore(core): add actor names to metadata endpoint (#1387)
1 parent 6b6324b commit b5072fd

File tree

5 files changed

+26
-12
lines changed

5 files changed

+26
-12
lines changed

examples/counter-serverless/src/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import { registry } from "./registry";
22

33
registry.start({
44
runnerKind: "serverless",
5-
runEngine: true,
6-
autoConfigureServerless: true,
5+
autoConfigureServerless: { url: "http://localhost:8080" },
6+
endpoint: "http://localhost:6420",
77
});

packages/rivetkit/src/common/router.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
getRequestEncoding,
66
getRequestExposeInternalError,
77
} from "@/actor/router-endpoints";
8+
import { buildActorNames, type RegistryConfig } from "@/registry/config";
89
import type { RunnerConfig } from "@/registry/run-config";
910
import { getEndpoint } from "@/remote-manager-driver/api-utils";
1011
import { HttpResponseError } from "@/schemas/client-protocol/mod";
@@ -93,6 +94,7 @@ export interface MetadataResponse {
9394
| { serverless: Record<never, never> }
9495
| { normal: Record<never, never> };
9596
};
97+
actorNames: ReturnType<typeof buildActorNames>;
9698
/**
9799
* Endpoint that the client should connect to to access this runner.
98100
*
@@ -105,7 +107,11 @@ export interface MetadataResponse {
105107
clientEndpoint?: string;
106108
}
107109

108-
export function handleMetadataRequest(c: HonoContext, runConfig: RunnerConfig) {
110+
export function handleMetadataRequest(
111+
c: HonoContext,
112+
registryConfig: RegistryConfig,
113+
runConfig: RunnerConfig,
114+
) {
109115
const response: MetadataResponse = {
110116
runtime: "rivetkit",
111117
version: VERSION,
@@ -115,6 +121,7 @@ export function handleMetadataRequest(c: HonoContext, runConfig: RunnerConfig) {
115121
? { serverless: {} }
116122
: { normal: {} },
117123
},
124+
actorNames: buildActorNames(registryConfig),
118125
// Do not return client endpoint if default server disabled
119126
clientEndpoint:
120127
runConfig.overrideServerAddress ??

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {
3333
type ManagerDriver,
3434
serializeEmptyPersistData,
3535
} from "@/driver-helpers/mod";
36-
import type { RegistryConfig } from "@/registry/config";
36+
import { buildActorNames, type RegistryConfig } from "@/registry/config";
3737
import type { RunnerConfig } from "@/registry/run-config";
3838
import { getEndpoint } from "@/remote-manager-driver/api-utils";
3939
import {
@@ -103,12 +103,7 @@ export class EngineActorDriver implements ActorDriver {
103103
metadata: {
104104
inspectorToken: this.#runConfig.inspector.token(),
105105
},
106-
prepopulateActorNames: Object.fromEntries(
107-
Object.keys(this.#registryConfig.use).map((name) => [
108-
name,
109-
{ metadata: {} },
110-
]),
111-
),
106+
prepopulateActorNames: buildActorNames(registryConfig),
112107
onConnected: () => {
113108
if (hasDisconnected) {
114109
logger().info({

packages/rivetkit/src/manager/router.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ function addServerlessRoutes(
212212

213213
router.get("/health", (c) => handleHealthRequest(c));
214214

215-
router.get("/metadata", (c) => handleMetadataRequest(c, runConfig));
215+
router.get("/metadata", (c) =>
216+
handleMetadataRequest(c, registryConfig, runConfig),
217+
);
216218
}
217219

218220
function addManagerRoutes(
@@ -643,7 +645,9 @@ function addManagerRoutes(
643645

644646
router.get("/health", (c) => handleHealthRequest(c));
645647

646-
router.get("/metadata", (c) => handleMetadataRequest(c, runConfig));
648+
router.get("/metadata", (c) =>
649+
handleMetadataRequest(c, registryConfig, runConfig),
650+
);
647651

648652
managerDriver.modifyManagerRouter?.(
649653
registryConfig,

packages/rivetkit/src/registry/config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,11 @@ export type RegistryConfigInput<A extends RegistryActors> = Omit<
3030
z.input<typeof RegistryConfigSchema>,
3131
"use"
3232
> & { use: A };
33+
34+
export function buildActorNames(
35+
registryConfig: RegistryConfig,
36+
): Record<string, { metadata: Record<string, any> }> {
37+
return Object.fromEntries(
38+
Object.keys(registryConfig.use).map((name) => [name, { metadata: {} }]),
39+
);
40+
}

0 commit comments

Comments
 (0)