Skip to content

Commit

Permalink
Fix tests and add good defaults for localhost
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos Candeia <[email protected]>
  • Loading branch information
mcandeia committed Sep 24, 2024
1 parent 4e548c8 commit 882093a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 7 additions & 2 deletions src/actors/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,22 @@ type Promisify<Actor> = {
: Actor[key];
};

const ACTORS_SERVER_URL: string | undefined = Deno.env.get(
const DENO_ACTORS_SERVER_URL: string | undefined = Deno.env.get(
"DENO_ACTORS_SERVER_URL",
);
const DEPLOYMENT: string | undefined = Deno.env.get("DENO_DEPLOYMENT_ID");
const ACTORS_SERVER_URL = DENO_ACTORS_SERVER_URL ??
(typeof DEPLOYMENT === "string"
? undefined
: `http://localhost:${Deno.env.get("PORT") ?? 8000}`);

/**
* utilities to create and manage actors.
*/
export const actors = {
proxy: <TInstance extends Actor>(
actor: ActorConstructor<TInstance> | string,
server = ACTORS_SERVER_URL,
server: string | undefined = ACTORS_SERVER_URL,
): { id: (id: string) => Promisify<TInstance> } => {
return {
id: (id: string): Promisify<TInstance> => {
Expand Down
5 changes: 1 addition & 4 deletions src/actors/runtime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ Deno.test("counter increment and getCount", async () => {
const rt = new ActorRuntime([Counter]);
await using _server = runServer(rt);
const actorId = "1234";
const counterProxy = actors.proxy({
actor: Counter,
server: "http://localhost:8000",
});
const counterProxy = actors.proxy(Counter);

const actor = counterProxy.id(actorId);
// Test increment
Expand Down

0 comments on commit 882093a

Please sign in to comment.