From b6f845781057f702469d7b22bee0f2fc870ff3fd Mon Sep 17 00:00:00 2001 From: Nathan Flurry Date: Thu, 19 Jun 2025 18:32:55 +0000 Subject: [PATCH] chore: disable inspector --- packages/core/package.json | 32 +- packages/core/src/inspector/common.ts | 374 +++++++++--------- packages/core/src/inspector/config.ts | 32 +- packages/core/src/inspector/manager.ts | 228 +++++------ packages/core/src/inspector/mod.ts | 4 +- .../src/inspector/protocol/manager/mod.ts | 4 +- .../inspector/protocol/manager/to-client.ts | 54 +-- .../inspector/protocol/manager/to-server.ts | 26 +- .../core/src/inspector/protocol/worker/mod.ts | 4 +- .../inspector/protocol/worker/to-client.ts | 70 ++-- .../inspector/protocol/worker/to-server.ts | 26 +- packages/core/src/inspector/worker.ts | 236 +++++------ packages/core/src/manager/driver.ts | 3 +- packages/core/src/manager/router.ts | 26 +- packages/core/src/registry/config.ts | 4 +- packages/core/src/test/driver/manager.ts | 14 +- .../src/topologies/coordinate/topology.ts | 6 +- .../core/src/topologies/partition/topology.ts | 104 +++-- .../src/topologies/partition/worker-router.ts | 26 +- .../src/topologies/standalone/topology.ts | 49 ++- packages/core/src/worker/instance.ts | 15 +- packages/drivers/file-system/src/manager.ts | 14 +- packages/drivers/memory/src/manager.ts | 14 +- packages/drivers/redis/src/manager.ts | 48 ++- 24 files changed, 674 insertions(+), 739 deletions(-) diff --git a/packages/core/package.json b/packages/core/package.json index 6466b540b..03e4c941b 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -120,36 +120,6 @@ "types": "./dist/test/mod.d.cts", "default": "./dist/test/mod.cjs" } - }, - "./inspector": { - "import": { - "types": "./dist/inspector/mod.d.ts", - "default": "./dist/inspector/mod.js" - }, - "require": { - "types": "./dist/inspector/mod.d.cts", - "default": "./dist/inspector/mod.cjs" - } - }, - "./inspector/protocol/worker": { - "import": { - "types": "./dist/inspector/protocol/worker/mod.d.ts", - "default": "./dist/inspector/protocol/worker/mod.js" - }, - "require": { - "types": "./dist/inspector/protocol/worker/mod.d.cts", - "default": "./dist/inspector/protocol/worker/mod.cjs" - } - }, - "./inspector/protocol/manager": { - "import": { - "types": "./dist/inspector/protocol/manager/mod.d.ts", - "default": "./dist/inspector/protocol/manager/mod.js" - }, - "require": { - "types": "./dist/inspector/protocol/manager/mod.d.cts", - "default": "./dist/inspector/protocol/manager/mod.cjs" - } } }, "engines": { @@ -158,7 +128,7 @@ "sideEffects": false, "scripts": { "dev": "yarn build --watch", - "build": "tsup src/mod.ts src/client/mod.ts src/common/log.ts src/common/websocket.ts src/worker/errors.ts src/topologies/coordinate/mod.ts src/topologies/partition/mod.ts src/utils.ts src/driver-helpers/mod.ts src/driver-test-suite/mod.ts src/worker/protocol/inspector/mod.ts src/test/mod.ts src/inspector/protocol/worker/mod.ts src/inspector/protocol/manager/mod.ts src/inspector/mod.ts", + "build": "tsup src/mod.ts src/client/mod.ts src/common/log.ts src/common/websocket.ts src/worker/errors.ts src/topologies/coordinate/mod.ts src/topologies/partition/mod.ts src/utils.ts src/driver-helpers/mod.ts src/driver-test-suite/mod.ts src/test/mod.ts", "check-types": "tsc --noEmit", "boop": "tsc --outDir dist/test -d", "test": "vitest run", diff --git a/packages/core/src/inspector/common.ts b/packages/core/src/inspector/common.ts index ab8e0bc67..c3390f6d8 100644 --- a/packages/core/src/inspector/common.ts +++ b/packages/core/src/inspector/common.ts @@ -1,187 +1,187 @@ -import type { ConnId } from "@/worker/connection"; -import { deconstructError, safeStringify } from "@/common/utils"; -import { Hono, type HonoRequest } from "hono"; -import type { UpgradeWebSocket, WSContext } from "hono/ws"; -import type { InspectorConfig } from "./config"; -import type { Logger } from "@/common/log"; -import * as errors from "@/worker/errors"; -import type { ZodSchema } from "zod"; - -interface ConnectInspectorOpts { - req: HonoRequest; -} - -export interface ConnectInspectorOutput { - onOpen: (ws: WSContext) => Promise; - onMessage: (message: MsgSchema) => Promise; - onClose: () => Promise; -} - -export type InspectorConnHandler = ( - opts: ConnectInspectorOpts, -) => Promise>; - -/** - * Represents a connection to a worker. - * @internal - */ -export class InspectorConnection { - constructor( - public readonly id: string, - private readonly ws: WSContext, - ) {} - - send(message: MsgSchema) { - try { - const serialized = safeStringify(message, 128 * 1024 * 1024); - return this.ws.send(serialized); - } catch { - return this.ws.send( - JSON.stringify({ - type: "error", - message: "Failed to serialize message due to size constraints.", - }), - ); - } - } -} - -/** - * Provides a unified interface for inspecting worker and managers. - */ -export class Inspector { - /** - * Map of all connections to the inspector. - * @internal - */ - readonly #connections = new Map< - ConnId, - InspectorConnection - >(); - - /** - * Connection counter. - */ - #conId = 0; - - /** - * Broadcast a message to all inspector connections. - * @internal - */ - broadcast(msg: ToClientSchema) { - for (const conn of this.#connections.values()) { - conn.send(msg); - } - } - - /** - * Process a message from a connection. - * @internal - */ - processMessage( - connection: InspectorConnection, - message: ToServerSchema, - ) {} - - /** - * Create a new connection to the inspector. - * Connection will be notified of all state changes. - * @internal - */ - createConnection(ws: WSContext): InspectorConnection { - const id = `${this.#conId++}`; - const con = new InspectorConnection(id, ws); - this.#connections.set(id, con); - return con; - } - - /** - * Remove a connection from the inspector. - * @internal - */ - removeConnection(con: InspectorConnection): void { - this.#connections.delete(con.id); - } -} - -export function createInspectorRoute< - ConnectionHandler extends - InspectorConnHandler, ->({ - upgradeWebSocket, - onConnect, - config, - logger, - serverMessageSchema, -}: { - upgradeWebSocket: UpgradeWebSocket | undefined; - onConnect: ConnectionHandler | undefined; - config: InspectorConfig; - logger: Logger; - serverMessageSchema: ZodSchema; -}) { - const router = new Hono(); - - if (!upgradeWebSocket || !onConnect || !config.enabled) { - return router.get("/", async (c) => { - return c.json({ - error: "Inspector disabled. Only available on WebSocket connections.", - }); - }); - } - - return router.get( - "/", - async (c, next) => { - const result = - (await config.onRequest?.({ req: c.req })) ?? config.enabled; - if (!result) return c.json({ error: "Inspector disabled." }, 403); - return next(); - }, - upgradeWebSocket(async (c) => { - try { - const handler = await onConnect({ req: c.req }); - return { - onOpen: async (_, ws) => { - try { - await handler.onOpen(ws); - } catch (error) { - const { code } = deconstructError(error, logger, { - wsEvent: "open", - }); - ws.close(1011, code); - } - }, - onClose: async () => { - try { - await handler.onClose(); - } catch (error) { - deconstructError(error, logger, { - wsEvent: "close", - }); - } - }, - onMessage: async (event, ws) => { - try { - const { success, data, error } = serverMessageSchema.safeParse( - JSON.parse(event.data.valueOf() as string), - ); - if (!success) throw new errors.MalformedMessage(error); - - await handler.onMessage(data); - } catch (error) { - const { code } = deconstructError(error, logger, { - wsEvent: "message", - }); - ws.close(1011, code); - } - }, - }; - } catch (error) { - deconstructError(error, logger, {}); - return {}; - } - }), - ); -} +// import type { ConnId } from "@/worker/connection"; +// import { deconstructError, safeStringify } from "@/common/utils"; +// import { Hono, type HonoRequest } from "hono"; +// import type { UpgradeWebSocket, WSContext } from "hono/ws"; +// import type { InspectorConfig } from "./config"; +// import type { Logger } from "@/common/log"; +// import * as errors from "@/worker/errors"; +// import type { ZodSchema } from "zod"; +// +// interface ConnectInspectorOpts { +// req: HonoRequest; +// } +// +// export interface ConnectInspectorOutput { +// onOpen: (ws: WSContext) => Promise; +// onMessage: (message: MsgSchema) => Promise; +// onClose: () => Promise; +// } +// +// export type InspectorConnHandler = ( +// opts: ConnectInspectorOpts, +// ) => Promise>; +// +// /** +// * Represents a connection to a worker. +// * @internal +// */ +// export class InspectorConnection { +// constructor( +// public readonly id: string, +// private readonly ws: WSContext, +// ) {} +// +// send(message: MsgSchema) { +// try { +// const serialized = safeStringify(message, 128 * 1024 * 1024); +// return this.ws.send(serialized); +// } catch { +// return this.ws.send( +// JSON.stringify({ +// type: "error", +// message: "Failed to serialize message due to size constraints.", +// }), +// ); +// } +// } +// } +// +// /** +// * Provides a unified interface for inspecting worker and managers. +// */ +// export class Inspector { +// /** +// * Map of all connections to the inspector. +// * @internal +// */ +// readonly #connections = new Map< +// ConnId, +// InspectorConnection +// >(); +// +// /** +// * Connection counter. +// */ +// #conId = 0; +// +// /** +// * Broadcast a message to all inspector connections. +// * @internal +// */ +// broadcast(msg: ToClientSchema) { +// for (const conn of this.#connections.values()) { +// conn.send(msg); +// } +// } +// +// /** +// * Process a message from a connection. +// * @internal +// */ +// processMessage( +// connection: InspectorConnection, +// message: ToServerSchema, +// ) {} +// +// /** +// * Create a new connection to the inspector. +// * Connection will be notified of all state changes. +// * @internal +// */ +// createConnection(ws: WSContext): InspectorConnection { +// const id = `${this.#conId++}`; +// const con = new InspectorConnection(id, ws); +// this.#connections.set(id, con); +// return con; +// } +// +// /** +// * Remove a connection from the inspector. +// * @internal +// */ +// removeConnection(con: InspectorConnection): void { +// this.#connections.delete(con.id); +// } +// } +// +// export function createInspectorRoute< +// ConnectionHandler extends +// InspectorConnHandler, +// >({ +// upgradeWebSocket, +// onConnect, +// config, +// logger, +// serverMessageSchema, +// }: { +// upgradeWebSocket: UpgradeWebSocket | undefined; +// onConnect: ConnectionHandler | undefined; +// config: InspectorConfig; +// logger: Logger; +// serverMessageSchema: ZodSchema; +// }) { +// const router = new Hono(); +// +// if (!upgradeWebSocket || !onConnect || !config.enabled) { +// return router.get("/", async (c) => { +// return c.json({ +// error: "Inspector disabled. Only available on WebSocket connections.", +// }); +// }); +// } +// +// return router.get( +// "/", +// async (c, next) => { +// const result = +// (await config.onRequest?.({ req: c.req })) ?? config.enabled; +// if (!result) return c.json({ error: "Inspector disabled." }, 403); +// return next(); +// }, +// upgradeWebSocket(async (c) => { +// try { +// const handler = await onConnect({ req: c.req }); +// return { +// onOpen: async (_, ws) => { +// try { +// await handler.onOpen(ws); +// } catch (error) { +// const { code } = deconstructError(error, logger, { +// wsEvent: "open", +// }); +// ws.close(1011, code); +// } +// }, +// onClose: async () => { +// try { +// await handler.onClose(); +// } catch (error) { +// deconstructError(error, logger, { +// wsEvent: "close", +// }); +// } +// }, +// onMessage: async (event, ws) => { +// try { +// const { success, data, error } = serverMessageSchema.safeParse( +// JSON.parse(event.data.valueOf() as string), +// ); +// if (!success) throw new errors.MalformedMessage(error); +// +// await handler.onMessage(data); +// } catch (error) { +// const { code } = deconstructError(error, logger, { +// wsEvent: "message", +// }); +// ws.close(1011, code); +// } +// }, +// }; +// } catch (error) { +// deconstructError(error, logger, {}); +// return {}; +// } +// }), +// ); +// } diff --git a/packages/core/src/inspector/config.ts b/packages/core/src/inspector/config.ts index badb62068..ca41d8163 100644 --- a/packages/core/src/inspector/config.ts +++ b/packages/core/src/inspector/config.ts @@ -1,16 +1,16 @@ -import type { HonoRequest } from "hono"; -import { z } from "zod"; - -export const InspectorConfigSchema = z.object({ - enabled: z.boolean().optional().default(false), - /** - * Handler for incoming requests. - * A best place to add authentication. - */ - onRequest: z - .function() - .args(z.object({ req: z.custom() })) - .returns(z.promise(z.boolean()).or(z.boolean())) - .optional(), -}); -export type InspectorConfig = z.infer; +// import type { HonoRequest } from "hono"; +// import { z } from "zod"; +// +// export const InspectorConfigSchema = z.object({ +// enabled: z.boolean().optional().default(false), +// /** +// * Handler for incoming requests. +// * A best place to add authentication. +// */ +// onRequest: z +// .function() +// .args(z.object({ req: z.custom() })) +// .returns(z.promise(z.boolean()).or(z.boolean())) +// .optional(), +// }); +// export type InspectorConfig = z.infer; diff --git a/packages/core/src/inspector/manager.ts b/packages/core/src/inspector/manager.ts index 4e759669a..6307a518c 100644 --- a/packages/core/src/inspector/manager.ts +++ b/packages/core/src/inspector/manager.ts @@ -1,114 +1,114 @@ -import type { UpgradeWebSocket } from "hono/ws"; -import { - type ToClient, - type ToServer, - ToServerSchema, -} from "@/inspector/protocol/manager/mod"; -import { logger } from "@/manager/log"; -import * as errors from "@/worker/errors"; -import { - createInspectorRoute, - Inspector, - type InspectorConnection, - type InspectorConnHandler, -} from "./common"; -import type { InspectorConfig } from "./config"; -import type { ManagerDriver } from "@/manager/driver"; -import { throttle } from "@/worker/utils"; - -export type ManagerInspectorConnHandler = InspectorConnHandler; - -interface Worker { - id: string; - name: string; - key: string[]; - region?: string; - createdAt?: string; - destroyedAt?: string; -} - -/** - * Create a router for the Manager Inspector. - * @internal - */ -export function createManagerInspectorRouter( - upgradeWebSocket: UpgradeWebSocket | undefined, - onConnect: ManagerInspectorConnHandler | undefined, - config: InspectorConfig, -) { - return createInspectorRoute({ - upgradeWebSocket, - onConnect, - config, - logger: logger(), - serverMessageSchema: ToServerSchema, - }); -} - -/** - * Represents a connection to a worker. - * @internal - */ -export type ManagerInspectorConnection = InspectorConnection; - -/** - * Provides a unified interface for inspecting worker external and internal state. - */ -export class ManagerInspector extends Inspector { - /** - * Inspected worker instance. - * @internal - */ - readonly driver: ManagerDriver; - - /** - * Notify all inspector listeners of a worker's state change. - * @param state - The new state. - */ - public onWorkersChange = throttle((workers: Worker[]) => { - this.broadcast({ type: "workers", workers }); - }, 500); - - constructor( - driver: ManagerDriver, - private readonly hooks: { - getAllWorkers: () => Worker[]; - getAllTypesOfWorkers: () => string[]; - }, - ) { - super(); - this.driver = driver; - } - - /** - * Process a message from a connection. - * @internal - */ - processMessage(connection: ManagerInspectorConnection, incoming: unknown) { - const result = ToServerSchema.safeParse(incoming); - - if (!result.success) { - logger().warn("Invalid message", result.error); - return connection.send({ - type: "error", - message: "Invalid message", - }); - } - const message = result.data; - - if (message.type === "info") { - return connection.send({ - type: "info", - workers: this.hooks.getAllWorkers(), - types: this.hooks.getAllTypesOfWorkers(), - }); - } - - if (message.type === "destroy") { - // TODO - return; - } - - throw new errors.Unreachable(message); - } -} +// import type { UpgradeWebSocket } from "hono/ws"; +// import { +// type ToClient, +// type ToServer, +// ToServerSchema, +// } from "@/inspector/protocol/manager/mod"; +// import { logger } from "@/manager/log"; +// import * as errors from "@/worker/errors"; +// import { +// createInspectorRoute, +// Inspector, +// type InspectorConnection, +// type InspectorConnHandler, +// } from "./common"; +// import type { InspectorConfig } from "./config"; +// import type { ManagerDriver } from "@/manager/driver"; +// import { throttle } from "@/worker/utils"; +// +// export type ManagerInspectorConnHandler = InspectorConnHandler; +// +// interface Worker { +// id: string; +// name: string; +// key: string[]; +// region?: string; +// createdAt?: string; +// destroyedAt?: string; +// } +// +// /** +// * Create a router for the Manager Inspector. +// * @internal +// */ +// export function createManagerInspectorRouter( +// upgradeWebSocket: UpgradeWebSocket | undefined, +// onConnect: ManagerInspectorConnHandler | undefined, +// config: InspectorConfig, +// ) { +// return createInspectorRoute({ +// upgradeWebSocket, +// onConnect, +// config, +// logger: logger(), +// serverMessageSchema: ToServerSchema, +// }); +// } +// +// /** +// * Represents a connection to a worker. +// * @internal +// */ +// export type ManagerInspectorConnection = InspectorConnection; +// +// /** +// * Provides a unified interface for inspecting worker external and internal state. +// */ +// export class ManagerInspector extends Inspector { +// /** +// * Inspected worker instance. +// * @internal +// */ +// readonly driver: ManagerDriver; +// +// /** +// * Notify all inspector listeners of a worker's state change. +// * @param state - The new state. +// */ +// public onWorkersChange = throttle((workers: Worker[]) => { +// this.broadcast({ type: "workers", workers }); +// }, 500); +// +// constructor( +// driver: ManagerDriver, +// private readonly hooks: { +// getAllWorkers: () => Worker[]; +// getAllTypesOfWorkers: () => string[]; +// }, +// ) { +// super(); +// this.driver = driver; +// } +// +// /** +// * Process a message from a connection. +// * @internal +// */ +// processMessage(connection: ManagerInspectorConnection, incoming: unknown) { +// const result = ToServerSchema.safeParse(incoming); +// +// if (!result.success) { +// logger().warn("Invalid message", result.error); +// return connection.send({ +// type: "error", +// message: "Invalid message", +// }); +// } +// const message = result.data; +// +// if (message.type === "info") { +// return connection.send({ +// type: "info", +// workers: this.hooks.getAllWorkers(), +// types: this.hooks.getAllTypesOfWorkers(), +// }); +// } +// +// if (message.type === "destroy") { +// // TODO +// return; +// } +// +// throw new errors.Unreachable(message); +// } +// } diff --git a/packages/core/src/inspector/mod.ts b/packages/core/src/inspector/mod.ts index 088ff8cce..dd9909013 100644 --- a/packages/core/src/inspector/mod.ts +++ b/packages/core/src/inspector/mod.ts @@ -1,2 +1,2 @@ -export { ManagerInspector } from "./manager"; -export { WorkerInspector } from "./worker"; +// export { ManagerInspector } from "./manager"; +// export { WorkerInspector } from "./worker"; diff --git a/packages/core/src/inspector/protocol/manager/mod.ts b/packages/core/src/inspector/protocol/manager/mod.ts index 0bf544b94..5d95a831e 100644 --- a/packages/core/src/inspector/protocol/manager/mod.ts +++ b/packages/core/src/inspector/protocol/manager/mod.ts @@ -1,2 +1,2 @@ -export * from "./to-client"; -export * from "./to-server"; +// export * from "./to-client"; +// export * from "./to-server"; diff --git a/packages/core/src/inspector/protocol/manager/to-client.ts b/packages/core/src/inspector/protocol/manager/to-client.ts index a19b4fcd1..3fbb9d1e8 100644 --- a/packages/core/src/inspector/protocol/manager/to-client.ts +++ b/packages/core/src/inspector/protocol/manager/to-client.ts @@ -1,27 +1,27 @@ -import { z } from "zod"; - -const WorkerSchema = z.object({ - id: z.string(), - name: z.string(), - key: z.array(z.string()), -}); - -export type Worker = z.infer; - -export const ToClientSchema = z.discriminatedUnion("type", [ - z.object({ - type: z.literal("info"), - workers: z.array(WorkerSchema), - types: z.array(z.string()), - }), - z.object({ - type: z.literal("workers"), - workers: z.array(WorkerSchema), - }), - z.object({ - type: z.literal("error"), - message: z.string(), - }), -]); - -export type ToClient = z.infer; +// import { z } from "zod"; +// +// const WorkerSchema = z.object({ +// id: z.string(), +// name: z.string(), +// key: z.array(z.string()), +// }); +// +// export type Worker = z.infer; +// +// export const ToClientSchema = z.discriminatedUnion("type", [ +// z.object({ +// type: z.literal("info"), +// workers: z.array(WorkerSchema), +// types: z.array(z.string()), +// }), +// z.object({ +// type: z.literal("workers"), +// workers: z.array(WorkerSchema), +// }), +// z.object({ +// type: z.literal("error"), +// message: z.string(), +// }), +// ]); +// +// export type ToClient = z.infer; diff --git a/packages/core/src/inspector/protocol/manager/to-server.ts b/packages/core/src/inspector/protocol/manager/to-server.ts index 2fd65cc60..783d3b662 100644 --- a/packages/core/src/inspector/protocol/manager/to-server.ts +++ b/packages/core/src/inspector/protocol/manager/to-server.ts @@ -1,13 +1,13 @@ -import { z } from "zod"; - -export const ToServerSchema = z.discriminatedUnion("type", [ - z.object({ - type: z.literal("info"), - }), - z.object({ - type: z.literal("destroy"), - workerId: z.string(), - }), -]); - -export type ToServer = z.infer; +// import { z } from "zod"; +// +// export const ToServerSchema = z.discriminatedUnion("type", [ +// z.object({ +// type: z.literal("info"), +// }), +// z.object({ +// type: z.literal("destroy"), +// workerId: z.string(), +// }), +// ]); +// +// export type ToServer = z.infer; diff --git a/packages/core/src/inspector/protocol/worker/mod.ts b/packages/core/src/inspector/protocol/worker/mod.ts index 0bf544b94..5d95a831e 100644 --- a/packages/core/src/inspector/protocol/worker/mod.ts +++ b/packages/core/src/inspector/protocol/worker/mod.ts @@ -1,2 +1,2 @@ -export * from "./to-client"; -export * from "./to-server"; +// export * from "./to-client"; +// export * from "./to-server"; diff --git a/packages/core/src/inspector/protocol/worker/to-client.ts b/packages/core/src/inspector/protocol/worker/to-client.ts index e94d76ac9..b1692473b 100644 --- a/packages/core/src/inspector/protocol/worker/to-client.ts +++ b/packages/core/src/inspector/protocol/worker/to-client.ts @@ -1,35 +1,35 @@ -import { z } from "zod"; - -const ConnSchema = z.object({ - id: z.string(), - parameters: z.any(), - state: z.object({ - enabled: z.boolean(), - value: z.any().optional(), - }), -}); - -export const InspectDataSchema = z.object({ - connections: z.array(ConnSchema), - actions: z.array(z.string()), - state: z.object({ - enabled: z.boolean(), - value: z.any().optional(), - }), -}); - -export type InspectData = z.infer; - -export const ToClientSchema = z.discriminatedUnion("type", [ - z - .object({ - type: z.literal("info"), - }) - .merge(InspectDataSchema), - z.object({ - type: z.literal("error"), - message: z.string(), - }), -]); - -export type ToClient = z.infer; +// import { z } from "zod"; +// +// const ConnSchema = z.object({ +// id: z.string(), +// parameters: z.any(), +// state: z.object({ +// enabled: z.boolean(), +// value: z.any().optional(), +// }), +// }); +// +// export const InspectDataSchema = z.object({ +// connections: z.array(ConnSchema), +// actions: z.array(z.string()), +// state: z.object({ +// enabled: z.boolean(), +// value: z.any().optional(), +// }), +// }); +// +// export type InspectData = z.infer; +// +// export const ToClientSchema = z.discriminatedUnion("type", [ +// z +// .object({ +// type: z.literal("info"), +// }) +// .merge(InspectDataSchema), +// z.object({ +// type: z.literal("error"), +// message: z.string(), +// }), +// ]); +// +// export type ToClient = z.infer; diff --git a/packages/core/src/inspector/protocol/worker/to-server.ts b/packages/core/src/inspector/protocol/worker/to-server.ts index 7e27f6c4a..728322728 100644 --- a/packages/core/src/inspector/protocol/worker/to-server.ts +++ b/packages/core/src/inspector/protocol/worker/to-server.ts @@ -1,13 +1,13 @@ -import { z } from "zod"; - -export const ToServerSchema = z.discriminatedUnion("type", [ - z.object({ - type: z.literal("info"), - }), - z.object({ - type: z.literal("setState"), - state: z.any(), - }), -]); - -export type ToServer = z.infer; +// import { z } from "zod"; +// +// export const ToServerSchema = z.discriminatedUnion("type", [ +// z.object({ +// type: z.literal("info"), +// }), +// z.object({ +// type: z.literal("setState"), +// state: z.any(), +// }), +// ]); +// +// export type ToServer = z.infer; diff --git a/packages/core/src/inspector/worker.ts b/packages/core/src/inspector/worker.ts index ab917ceaf..087002c90 100644 --- a/packages/core/src/inspector/worker.ts +++ b/packages/core/src/inspector/worker.ts @@ -1,118 +1,118 @@ -import type { AnyWorkerInstance } from "@/worker/instance"; -import type { AnyConn, ConnId } from "@/worker/connection"; -import { throttle } from "@/worker/utils"; -import type { UpgradeWebSocket } from "hono/ws"; -import * as errors from "@/worker/errors"; -import { - type ToClient, - type ToServer, - ToServerSchema, -} from "@/inspector/protocol/worker/mod"; -import { logger } from "@/worker/log"; -import { - createInspectorRoute, - Inspector, - type InspectorConnection, - type InspectorConnHandler, -} from "./common"; -import type { InspectorConfig } from "./config"; - -export type WorkerInspectorConnHandler = InspectorConnHandler; - -/** - * Create a router for the worker inspector. - * @internal - */ -export function createWorkerInspectorRouter( - upgradeWebSocket: UpgradeWebSocket | undefined, - onConnect: WorkerInspectorConnHandler | undefined, - config: InspectorConfig, -) { - return createInspectorRoute({ - upgradeWebSocket, - onConnect, - config, - logger: logger(), - serverMessageSchema: ToServerSchema, - }); -} - -/** - * Represents a connection to a worker. - * @internal - */ -export type WorkerInspectorConnection = InspectorConnection; - -/** - * Provides a unified interface for inspecting worker external and internal state. - */ -export class WorkerInspector extends Inspector { - /** - * Inspected worker instance. - * @internal - */ - readonly worker: AnyWorkerInstance; - - /** - * Notify all inspector listeners of a worker's state change. - * @param state - The new state. - * @internal - */ - onStateChange = throttle((state: unknown) => { - this.broadcast(this.#createInfoMessage()); - }, 500); - - /** - * - * Notify all inspector listeners of a worker's connections change. - * @param connections - The new connections. - * @internal - */ - onConnChange = throttle((connections: Map) => { - this.broadcast(this.#createInfoMessage()); - }, 500); - - constructor(worker: AnyWorkerInstance) { - super(); - this.worker = worker; - } - - /** - * Process a message from a connection. - * @internal - */ - processMessage(connection: WorkerInspectorConnection, message: ToServer) { - super.processMessage(connection, message); - if (message.type === "info") { - return connection.send(this.#createInfoMessage()); - } - if (message.type === "setState") { - this.worker.state = message.state; - return; - } - - throw new errors.Unreachable(message); - } - - /** - * Create an info message for the inspector. - */ - #createInfoMessage(): ToClient { - return { - type: "info", - connections: Array.from(this.worker.conns).map(([id, connection]) => ({ - id, - parameters: connection.params, - state: { - value: connection._stateEnabled ? connection.state : undefined, - enabled: connection._stateEnabled, - }, - })), - actions: this.worker.actions, - state: { - value: this.worker.stateEnabled ? this.worker.state : undefined, - enabled: this.worker.stateEnabled, - }, - }; - } -} +// import type { AnyWorkerInstance } from "@/worker/instance"; +// import type { AnyConn, ConnId } from "@/worker/connection"; +// import { throttle } from "@/worker/utils"; +// import type { UpgradeWebSocket } from "hono/ws"; +// import * as errors from "@/worker/errors"; +// import { +// type ToClient, +// type ToServer, +// ToServerSchema, +// } from "@/inspector/protocol/worker/mod"; +// import { logger } from "@/worker/log"; +// import { +// createInspectorRoute, +// Inspector, +// type InspectorConnection, +// type InspectorConnHandler, +// } from "./common"; +// import type { InspectorConfig } from "./config"; +// +// export type WorkerInspectorConnHandler = InspectorConnHandler; +// +// /** +// * Create a router for the worker inspector. +// * @internal +// */ +// export function createWorkerInspectorRouter( +// upgradeWebSocket: UpgradeWebSocket | undefined, +// onConnect: WorkerInspectorConnHandler | undefined, +// config: InspectorConfig, +// ) { +// return createInspectorRoute({ +// upgradeWebSocket, +// onConnect, +// config, +// logger: logger(), +// serverMessageSchema: ToServerSchema, +// }); +// } +// +// /** +// * Represents a connection to a worker. +// * @internal +// */ +// export type WorkerInspectorConnection = InspectorConnection; +// +// /** +// * Provides a unified interface for inspecting worker external and internal state. +// */ +// export class WorkerInspector extends Inspector { +// /** +// * Inspected worker instance. +// * @internal +// */ +// readonly worker: AnyWorkerInstance; +// +// /** +// * Notify all inspector listeners of a worker's state change. +// * @param state - The new state. +// * @internal +// */ +// onStateChange = throttle((state: unknown) => { +// this.broadcast(this.#createInfoMessage()); +// }, 500); +// +// /** +// * +// * Notify all inspector listeners of a worker's connections change. +// * @param connections - The new connections. +// * @internal +// */ +// onConnChange = throttle((connections: Map) => { +// this.broadcast(this.#createInfoMessage()); +// }, 500); +// +// constructor(worker: AnyWorkerInstance) { +// super(); +// this.worker = worker; +// } +// +// /** +// * Process a message from a connection. +// * @internal +// */ +// processMessage(connection: WorkerInspectorConnection, message: ToServer) { +// super.processMessage(connection, message); +// if (message.type === "info") { +// return connection.send(this.#createInfoMessage()); +// } +// if (message.type === "setState") { +// this.worker.state = message.state; +// return; +// } +// +// throw new errors.Unreachable(message); +// } +// +// /** +// * Create an info message for the inspector. +// */ +// #createInfoMessage(): ToClient { +// return { +// type: "info", +// connections: Array.from(this.worker.conns).map(([id, connection]) => ({ +// id, +// parameters: connection.params, +// state: { +// value: connection._stateEnabled ? connection.state : undefined, +// enabled: connection._stateEnabled, +// }, +// })), +// actions: this.worker.actions, +// state: { +// value: this.worker.stateEnabled ? this.worker.state : undefined, +// enabled: this.worker.stateEnabled, +// }, +// }; +// } +// } diff --git a/packages/core/src/manager/driver.ts b/packages/core/src/manager/driver.ts index 7e329f08d..02c8b2b7a 100644 --- a/packages/core/src/manager/driver.ts +++ b/packages/core/src/manager/driver.ts @@ -1,6 +1,5 @@ import { ClientDriver } from "@/client/client"; import type { WorkerKey } from "@/common/utils"; -import type { ManagerInspector } from "@/inspector/manager"; import type { Env, Context as HonoContext, HonoRequest } from "hono"; export interface ManagerDriver { @@ -9,7 +8,7 @@ export interface ManagerDriver { getOrCreateWithKey(input: GetOrCreateWithKeyInput): Promise; createWorker(input: CreateInput): Promise; - inspector?: ManagerInspector; + // inspector?: ManagerInspector; } export interface GetForIdInput { c?: HonoContext | undefined; diff --git a/packages/core/src/manager/router.ts b/packages/core/src/manager/router.ts index 0b068f0be..c414bd574 100644 --- a/packages/core/src/manager/router.ts +++ b/packages/core/src/manager/router.ts @@ -37,10 +37,6 @@ import { stringifyError, } from "@/common/utils"; import type { DriverConfig } from "@/driver-helpers/config"; -import { - type ManagerInspectorConnHandler, - createManagerInspectorRouter, -} from "@/inspector/manager"; import { Hono, type Context as HonoContext, type Next } from "hono"; import { OpenAPIHono } from "@hono/zod-openapi"; import { z } from "@hono/zod-openapi"; @@ -66,7 +62,7 @@ import { authenticateEndpoint } from "./auth"; import type { WebSocket, MessageEvent, CloseEvent } from "ws"; type ManagerRouterHandler = { - onConnectInspector?: ManagerInspectorConnHandler; + // onConnectInspector?: ManagerInspectorConnHandler; routingHandler: ConnRoutingHandler; }; @@ -357,16 +353,16 @@ export function createManagerRouter( ); } - if (registryConfig.inspector.enabled) { - router.route( - "/inspect", - createManagerInspectorRouter( - upgradeWebSocket, - handler.onConnectInspector, - registryConfig.inspector, - ), - ); - } + // if (registryConfig.inspector.enabled) { + // router.route( + // "/inspect", + // createManagerInspectorRouter( + // upgradeWebSocket, + // handler.onConnectInspector, + // registryConfig.inspector, + // ), + // ); + // } if (registryConfig.test.enabled) { // Add HTTP endpoint to test the inline client diff --git a/packages/core/src/registry/config.ts b/packages/core/src/registry/config.ts index a8b569a53..8c0446823 100644 --- a/packages/core/src/registry/config.ts +++ b/packages/core/src/registry/config.ts @@ -3,7 +3,6 @@ import { z } from "zod"; import type { cors } from "hono/cors"; import { WorkerDefinition, AnyWorkerDefinition } from "@/worker/definition"; -import { InspectorConfigSchema } from "@/inspector/config"; // Define CORS options schema type CorsOptions = NonNullable[0]>; @@ -71,8 +70,7 @@ export const RegistryConfigSchema = z.object({ /** Peer configuration for coordinated topology. */ workerPeer: WorkerPeerConfigSchema.optional().default({}), - /** Inspector configuration. */ - inspector: InspectorConfigSchema.optional().default({ enabled: false }), + // inspector: InspectorConfigSchema.optional().default({ enabled: false }), // TODO: Find a better way of passing around the test config /** diff --git a/packages/core/src/test/driver/manager.ts b/packages/core/src/test/driver/manager.ts index 21df8fafd..a3fe5720c 100644 --- a/packages/core/src/test/driver/manager.ts +++ b/packages/core/src/test/driver/manager.ts @@ -8,20 +8,16 @@ import type { import { WorkerAlreadyExists } from "@/worker/errors"; import type { TestGlobalState } from "./global-state"; import * as crypto from "node:crypto"; -import { ManagerInspector } from "@/inspector/manager"; import type { Registry } from "@/registry/mod"; import { WorkerOutput } from "@/manager/driver"; export class TestManagerDriver implements ManagerDriver { #state: TestGlobalState; - /** - * @internal - */ - inspector: ManagerInspector = new ManagerInspector(this, { - getAllWorkers: () => this.#state.getAllWorkers(), - getAllTypesOfWorkers: () => Object.keys(this.registry.config.workers), - }); + // inspector: ManagerInspector = new ManagerInspector(this, { + // getAllWorkers: () => this.#state.getAllWorkers(), + // getAllTypesOfWorkers: () => Object.keys(this.registry.config.workers), + // }); constructor( private readonly registry: Registry, @@ -134,7 +130,7 @@ export class TestManagerDriver implements ManagerDriver { const workerId = crypto.randomUUID(); this.#state.createWorker(workerId, name, key, input); - this.inspector.onWorkersChange(this.#state.getAllWorkers()); + // this.inspector.onWorkersChange(this.#state.getAllWorkers()); return { workerId, diff --git a/packages/core/src/topologies/coordinate/topology.ts b/packages/core/src/topologies/coordinate/topology.ts index 8bd3e93b8..18d695e70 100644 --- a/packages/core/src/topologies/coordinate/topology.ts +++ b/packages/core/src/topologies/coordinate/topology.ts @@ -135,9 +135,9 @@ export class CoordinateTopology { this.clientDriver, { routingHandler, - onConnectInspector: () => { - throw new errors.Unsupported("inspect"); - }, + // onConnectInspector: () => { + // throw new errors.Unsupported("inspect"); + // }, }, ); diff --git a/packages/core/src/topologies/partition/topology.ts b/packages/core/src/topologies/partition/topology.ts index 1a6f8cd36..cf7530bb4 100644 --- a/packages/core/src/topologies/partition/topology.ts +++ b/packages/core/src/topologies/partition/topology.ts @@ -23,9 +23,7 @@ import type { ConnDriver } from "@/worker/driver"; import type { WorkerKey } from "@/common/utils"; import type { DriverConfig } from "@/driver-helpers/config"; import type { RegistryConfig } from "@/registry/config"; -import type { WorkerInspectorConnection } from "@/inspector/worker"; import { createManagerRouter } from "@/manager/router"; -import type { ManagerInspectorConnection } from "@/inspector/manager"; import type { ConnectWebSocketOpts, ConnectSseOpts, @@ -81,30 +79,30 @@ export class PartitionTopologyManager { this.clientDriver, { routingHandler, - onConnectInspector: async () => { - const inspector = driverConfig.drivers?.manager?.inspector; - if (!inspector) throw new errors.Unsupported("inspector"); - - let conn: ManagerInspectorConnection | undefined; - return { - onOpen: async (ws) => { - conn = inspector.createConnection(ws); - }, - onMessage: async (message) => { - if (!conn) { - logger().warn("`conn` does not exist"); - return; - } - - inspector.processMessage(conn, message); - }, - onClose: async () => { - if (conn) { - inspector.removeConnection(conn); - } - }, - }; - }, + // onConnectInspector: async () => { + // const inspector = driverConfig.drivers?.manager?.inspector; + // if (!inspector) throw new errors.Unsupported("inspector"); + // + // let conn: ManagerInspectorConnection | undefined; + // return { + // onOpen: async (ws) => { + // conn = inspector.createConnection(ws); + // }, + // onMessage: async (message) => { + // if (!conn) { + // logger().warn("`conn` does not exist"); + // return; + // } + // + // inspector.processMessage(conn, message); + // }, + // onClose: async () => { + // if (conn) { + // inspector.removeConnection(conn); + // } + // }, + // }; + // }, }, ); } @@ -303,33 +301,33 @@ export class PartitionTopologyWorker { await worker.processMessage(opts.message, conn); }, }, - onConnectInspector: async () => { - if (this.#workerStartedPromise) - await this.#workerStartedPromise.promise; - - const worker = this.#worker; - if (!worker) throw new Error("Worker should be defined"); - - let conn: WorkerInspectorConnection | undefined; - return { - onOpen: async (ws) => { - conn = worker.inspector.createConnection(ws); - }, - onMessage: async (message) => { - if (!conn) { - logger().warn("`conn` does not exist"); - return; - } - - worker.inspector.processMessage(conn, message); - }, - onClose: async () => { - if (conn) { - worker.inspector.removeConnection(conn); - } - }, - }; - }, + // onConnectInspector: async () => { + // if (this.#workerStartedPromise) + // await this.#workerStartedPromise.promise; + // + // const worker = this.#worker; + // if (!worker) throw new Error("Worker should be defined"); + // + // let conn: WorkerInspectorConnection | undefined; + // return { + // onOpen: async (ws) => { + // conn = worker.inspector.createConnection(ws); + // }, + // onMessage: async (message) => { + // if (!conn) { + // logger().warn("`conn` does not exist"); + // return; + // } + // + // worker.inspector.processMessage(conn, message); + // }, + // onClose: async () => { + // if (conn) { + // worker.inspector.removeConnection(conn); + // } + // }, + // }; + // }, }); } diff --git a/packages/core/src/topologies/partition/worker-router.ts b/packages/core/src/topologies/partition/worker-router.ts index 0443f669b..7cfe0b4df 100644 --- a/packages/core/src/topologies/partition/worker-router.ts +++ b/packages/core/src/topologies/partition/worker-router.ts @@ -8,10 +8,6 @@ import { } from "@/common/router"; import type { DriverConfig } from "@/driver-helpers/config"; import type { RegistryConfig } from "@/registry/config"; -import { - type WorkerInspectorConnHandler, - createWorkerInspectorRouter, -} from "@/inspector/worker"; import { type ConnectWebSocketOpts, type ConnectWebSocketOutput, @@ -51,7 +47,7 @@ export interface WorkerRouterHandler { // Connection handlers as a required subobject connectionHandlers: ConnectionHandlers; - onConnectInspector?: WorkerInspectorConnHandler; + // onConnectInspector?: WorkerInspectorConnHandler; } /** @@ -206,16 +202,16 @@ export function createWorkerRouter( ); }); - if (registryConfig.inspector.enabled) { - router.route( - "/inspect", - createWorkerInspectorRouter( - upgradeWebSocket, - handler.onConnectInspector, - registryConfig.inspector, - ), - ); - } + // if (registryConfig.inspector.enabled) { + // router.route( + // "/inspect", + // createWorkerInspectorRouter( + // upgradeWebSocket, + // handler.onConnectInspector, + // registryConfig.inspector, + // ), + // ); + // } router.notFound(handleRouteNotFound); router.onError( diff --git a/packages/core/src/topologies/standalone/topology.ts b/packages/core/src/topologies/standalone/topology.ts index af4b4c7c7..c60f1ec7d 100644 --- a/packages/core/src/topologies/standalone/topology.ts +++ b/packages/core/src/topologies/standalone/topology.ts @@ -21,7 +21,6 @@ import { ActionContext } from "@/worker/action"; import type { DriverConfig } from "@/driver-helpers/config"; import type { RegistryConfig } from "@/registry/config"; import { createManagerRouter } from "@/manager/router"; -import type { ManagerInspectorConnection } from "@/inspector/manager"; import type { ConnectWebSocketOpts, ConnectWebSocketOutput, @@ -276,30 +275,30 @@ export class StandaloneTopology { // Build manager router const managerRouter = createManagerRouter(registryConfig, driverConfig, this.clientDriver, { routingHandler, - onConnectInspector: async () => { - const inspector = driverConfig.drivers?.manager?.inspector; - if (!inspector) throw new errors.Unsupported("inspector"); - - let conn: ManagerInspectorConnection | undefined; - return { - onOpen: async (ws) => { - conn = inspector.createConnection(ws); - }, - onMessage: async (message) => { - if (!conn) { - logger().warn("`conn` does not exist"); - return; - } - - inspector.processMessage(conn, message); - }, - onClose: async () => { - if (conn) { - inspector.removeConnection(conn); - } - }, - }; - }, + // onConnectInspector: async () => { + // const inspector = driverConfig.drivers?.manager?.inspector; + // if (!inspector) throw new errors.Unsupported("inspector"); + // + // let conn: ManagerInspectorConnection | undefined; + // return { + // onOpen: async (ws) => { + // conn = inspector.createConnection(ws); + // }, + // onMessage: async (message) => { + // if (!conn) { + // logger().warn("`conn` does not exist"); + // return; + // } + // + // inspector.processMessage(conn, message); + // }, + // onClose: async () => { + // if (conn) { + // inspector.removeConnection(conn); + // } + // }, + // }; + // }, }); router.route("/", managerRouter); diff --git a/packages/core/src/worker/instance.ts b/packages/core/src/worker/instance.ts index bc3c64ef8..200356c29 100644 --- a/packages/core/src/worker/instance.ts +++ b/packages/core/src/worker/instance.ts @@ -18,7 +18,6 @@ import { Schedule } from "./schedule"; import * as wsToClient from "@/worker/protocol/message/to-client"; import type * as wsToServer from "@/worker/protocol/message/to-server"; import { CachedSerializer } from "./protocol/serde"; -import { WorkerInspector } from "@/inspector/worker"; import { WorkerContext } from "./context"; import invariant from "invariant"; import type { @@ -131,11 +130,7 @@ export class WorkerInstance { #schedule!: Schedule; - /** - * Inspector for the worker. - * @internal - */ - inspector!: WorkerInspector; + // inspector!: WorkerInspector; get id() { return this.#workerId; @@ -168,7 +163,7 @@ export class WorkerInstance { this.#key = key; this.#region = region; this.#schedule = new Schedule(this); - this.inspector = new WorkerInspector(this); + // this.inspector = new WorkerInspector(this); // Initialize server // @@ -459,7 +454,7 @@ export class WorkerInstance { this.#persistChanged = true; // Call inspect handler - this.inspector.onStateChange(this.#persistRaw.s); + // this.inspector.onStateChange(this.#persistRaw.s); // Call onStateChange if it exists if (this.#config.onStateChange && this.#ready) { @@ -594,7 +589,7 @@ export class WorkerInstance { this.#removeSubscription(eventName, conn, true); } - this.inspector.onConnChange(this.#connections); + // this.inspector.onConnChange(this.#connections); if (this.#config.onDisconnect) { try { const result = this.#config.onDisconnect(this.workerContext, conn); @@ -714,7 +709,7 @@ export class WorkerInstance { this.#persist.c.push(persist); this.saveState({ immediate: true }); - this.inspector.onConnChange(this.#connections); + // this.inspector.onConnChange(this.#connections); // Handle connection if (this.#config.onConnect) { diff --git a/packages/drivers/file-system/src/manager.ts b/packages/drivers/file-system/src/manager.ts index 2692d0e8f..564fbe2ef 100644 --- a/packages/drivers/file-system/src/manager.ts +++ b/packages/drivers/file-system/src/manager.ts @@ -12,18 +12,14 @@ import { logger } from "./log"; import type { FileSystemGlobalState } from "./global-state"; import { WorkerState } from "./global-state"; import type { Registry } from "rivetkit"; -import { ManagerInspector } from "rivetkit/inspector"; export class FileSystemManagerDriver implements ManagerDriver { #state: FileSystemGlobalState; - /** - * @internal - */ - inspector: ManagerInspector = new ManagerInspector(this, { - getAllWorkers: () => this.#state.getAllWorkers(), - getAllTypesOfWorkers: () => Object.keys(this.registry.config.workers), - }); + // inspector: ManagerInspector = new ManagerInspector(this, { + // getAllWorkers: () => this.#state.getAllWorkers(), + // getAllTypesOfWorkers: () => Object.keys(this.registry.config.workers), + // }); constructor( private readonly registry: Registry, @@ -94,7 +90,7 @@ export class FileSystemManagerDriver implements ManagerDriver { await this.#state.createWorker(workerId, name, key, input); // Notify inspector about worker changes - this.inspector.onWorkersChange(this.#state.getAllWorkers()); + // this.inspector.onWorkersChange(this.#state.getAllWorkers()); return { workerId, diff --git a/packages/drivers/memory/src/manager.ts b/packages/drivers/memory/src/manager.ts index 2403de999..8e97b2528 100644 --- a/packages/drivers/memory/src/manager.ts +++ b/packages/drivers/memory/src/manager.ts @@ -9,19 +9,15 @@ import type { import { WorkerAlreadyExists } from "rivetkit/errors"; import type { MemoryGlobalState } from "./global-state"; import * as crypto from "node:crypto"; -import { ManagerInspector } from "rivetkit/inspector"; import type { Registry } from "rivetkit"; export class MemoryManagerDriver implements ManagerDriver { #state: MemoryGlobalState; - /** - * @internal - */ - inspector: ManagerInspector = new ManagerInspector(this, { - getAllWorkers: () => this.#state.getAllWorkers(), - getAllTypesOfWorkers: () => Object.keys(this.registry.config.workers), - }); + // inspector: ManagerInspector = new ManagerInspector(this, { + // getAllWorkers: () => this.#state.getAllWorkers(), + // getAllTypesOfWorkers: () => Object.keys(this.registry.config.workers), + // }); constructor( private readonly registry: Registry, @@ -103,7 +99,7 @@ export class MemoryManagerDriver implements ManagerDriver { const workerId = crypto.randomUUID(); this.#state.createWorker(workerId, name, key, input); - this.inspector.onWorkersChange(this.#state.getAllWorkers()); + // this.inspector.onWorkersChange(this.#state.getAllWorkers()); return { workerId, name, key }; } diff --git a/packages/drivers/redis/src/manager.ts b/packages/drivers/redis/src/manager.ts index 61d539205..2d91e17c2 100644 --- a/packages/drivers/redis/src/manager.ts +++ b/packages/drivers/redis/src/manager.ts @@ -10,7 +10,6 @@ import { WorkerAlreadyExists } from "rivetkit/errors"; import type Redis from "ioredis"; import * as crypto from "node:crypto"; import { KEYS } from "./keys"; -import { ManagerInspector } from "rivetkit/inspector"; import type { Registry } from "rivetkit"; interface Worker { @@ -26,24 +25,21 @@ export class RedisManagerDriver implements ManagerDriver { #redis: Redis; #registry?: Registry; - /** - * @internal - */ - inspector: ManagerInspector = new ManagerInspector(this, { - getAllWorkers: () => { - // Create a function that returns an array of workers directly - // Not returning a Promise since the ManagerInspector expects a synchronous function - const workers: Worker[] = []; - - // Return empty array since we can't do async operations here - // The actual data will be fetched when needed by calling getAllWorkers() manually - return workers; - }, - getAllTypesOfWorkers: () => { - if (!this.#registry) return []; - return Object.keys(this.#registry.config.workers); - }, - }); + // inspector: ManagerInspector = new ManagerInspector(this, { + // getAllWorkers: () => { + // // Create a function that returns an array of workers directly + // // Not returning a Promise since the ManagerInspector expects a synchronous function + // const workers: Worker[] = []; + // + // // Return empty array since we can't do async operations here + // // The actual data will be fetched when needed by calling getAllWorkers() manually + // return workers; + // }, + // getAllTypesOfWorkers: () => { + // if (!this.#registry) return []; + // return Object.keys(this.#registry.config.workers); + // }, + // }); constructor(redis: Redis, registry?: Registry) { this.#redis = redis; @@ -121,13 +117,13 @@ export class RedisManagerDriver implements ManagerDriver { await pipeline.exec(); // Notify inspector of worker creation - this.inspector.onWorkersChange([ - { - id: workerId, - name, - key, - }, - ]); + // this.inspector.onWorkersChange([ + // { + // id: workerId, + // name, + // key, + // }, + // ]); return { workerId,