Skip to content

Commit

Permalink
🔙
Browse files Browse the repository at this point in the history
  • Loading branch information
flvndvd committed Jan 22, 2024
1 parent 65f6f46 commit 75a5f73
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion front/lib/temporal.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ConnectionOptions } from "@temporalio/client";
import { Client, Connection } from "@temporalio/client";
import { NativeConnection } from "@temporalio/worker";
import fs from "fs-extra";

type TemporalNamespaces = "connectors" | "front";
Expand Down Expand Up @@ -33,7 +34,7 @@ export async function getTemporalClientForNamespace(
}

async function getConnectionOptions(
envVarForTemporalNamespace: string
envVarForTemporalNamespace: string = temporalWorkspaceToEnvVar["front"]
): Promise<
| {
address: string;
Expand Down Expand Up @@ -71,6 +72,15 @@ async function getConnectionOptions(
};
}

export async function getTemporalWorkerConnection(): Promise<{
connection: NativeConnection;
namespace: string | undefined;
}> {
const connectionOptions = await getConnectionOptions();
const connection = await NativeConnection.connect(connectionOptions);
return { connection, namespace: process.env.TEMPORAL_NAMESPACE };
}

export async function getTemporalClient() {
return getTemporalClientForNamespace("front");
}
Expand Down

0 comments on commit 75a5f73

Please sign in to comment.