23 lines
550 B
TypeScript
23 lines
550 B
TypeScript
import { config } from "#/config";
|
|
import { container } from "#/di";
|
|
import { Client, Connection} from '@temporalio/client';
|
|
|
|
container.bind({
|
|
provide: Client,
|
|
async: true,
|
|
useFactory: async () => {
|
|
const connection = await Connection.connect({
|
|
address: config.TEMPORAL_HOSTPORT,
|
|
})
|
|
const client = new Client({
|
|
connection,
|
|
namespace: config.TEMPORAL_NAMESPACE,
|
|
});
|
|
process.on('exit', () => {
|
|
console.log('closing temporal client');
|
|
client.connection.close();
|
|
});
|
|
return client
|
|
},
|
|
});
|