Skip to content

Commit ee52e8c

Browse files
committed
vitest and rpc
1 parent 81bcf63 commit ee52e8c

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

apps/interaction-worker/src/index.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,6 @@ import {
1919
// Export Durable Object
2020
export { MessageDebouncer } from "./durable-objects/message-debouncer";
2121

22-
// WorkerEntrypoint for RPC calls from other workers
23-
export class InteractionService extends WorkerEntrypoint<WorkerEnv> {
24-
async handleAgentCompletion(input: AgentCompletionInput): Promise<void> {
25-
const db = createDatabaseClient(this.env);
26-
await processAgentCompletion(input, db, this.env);
27-
}
28-
}
29-
3022
const app = new Hono<App>();
3123

3224
// Middleware
@@ -158,4 +150,14 @@ app.post("/", async (c) => {
158150
app.onError(withOnError<App>());
159151
app.notFound(withNotFound<App>());
160152

161-
export default app;
153+
// Default export: WorkerEntrypoint class for both HTTP and RPC
154+
export default class extends WorkerEntrypoint<WorkerEnv> {
155+
async fetch(request: Request): Promise<Response> {
156+
return app.fetch(request, this.env, this.ctx);
157+
}
158+
159+
async handleAgentCompletion(input: AgentCompletionInput): Promise<void> {
160+
const db = createDatabaseClient(this.env);
161+
await processAgentCompletion(input, db, this.env);
162+
}
163+
}

apps/interaction-worker/vitest.config.mts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ export default defineWorkersProject({
3636
),
3737
},
3838
},
39+
serviceBindings: {
40+
EXECUTION_WORKER: {
41+
scriptPath: resolve(
42+
__dirname,
43+
"../execution-worker/src/index.ts",
44+
),
45+
},
46+
},
3947
hyperdrives: {
4048
HYPERDRIVE:
4149
process.env.DATABASE_URL ||

0 commit comments

Comments
 (0)