Skip to content

Commit 36e2bc7

Browse files
committed
add getUrl method to local world and vercel world
1 parent b301b0a commit 36e2bc7

File tree

5 files changed

+18
-7
lines changed

5 files changed

+18
-7
lines changed

packages/core/src/runtime.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -585,11 +585,7 @@ export const stepEntrypoint =
585585
workflowMetadata: {
586586
workflowRunId,
587587
workflowStartedAt: new Date(+workflowStartedAt),
588-
// TODO: there should be a getUrl method on the world interface itself. This
589-
// solution only works for vercel + embedded worlds.
590-
url: process.env.VERCEL_URL
591-
? `https://${process.env.VERCEL_URL}`
592-
: `http://localhost:${process.env.PORT || 3000}`,
588+
url: world.getUrl(),
593589
},
594590
},
595591
() => stepFn(...args)

packages/world-local/src/queue.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,5 +143,9 @@ export function createQueue(port?: number): Queue {
143143
return 'dpl_embedded';
144144
};
145145

146-
return { queue, createQueueHandler, getDeploymentId };
146+
const getUrl: Queue['getUrl'] = () => {
147+
return `http://localhost:${port}`;
148+
};
149+
150+
return { queue, createQueueHandler, getDeploymentId, getUrl };
147151
}

packages/world-postgres/src/queue.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,13 @@ export function createQueue(
113113
}
114114
}
115115

116+
// TODO: Stub for now, need to implement url.
117+
const getUrl: Queue['getUrl'] = () => {
118+
return embeddedWorld.getUrl();
119+
};
120+
116121
return {
122+
getUrl,
117123
createQueueHandler,
118124
getDeploymentId,
119125
queue,

packages/world-vercel/src/queue.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,9 @@ export function createQueue(): Queue {
4646
return deploymentId;
4747
};
4848

49-
return { queue, createQueueHandler, getDeploymentId };
49+
const getUrl: Queue['getUrl'] = () => {
50+
return `https://${process.env.VERCEL_URL}`;
51+
};
52+
53+
return { queue, createQueueHandler, getDeploymentId, getUrl };
5054
}

packages/world/src/queue.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export type QueuePayload = z.infer<typeof QueuePayloadSchema>;
4545

4646
export interface Queue {
4747
getDeploymentId(): Promise<string>;
48+
getUrl(): string;
4849

4950
/**
5051
* Enqueues a message to the specified queue.

0 commit comments

Comments
 (0)