2025-02-27 03:56:30 +00:00
|
|
|
import { config } from "#/config";
|
2025-03-01 21:10:31 +00:00
|
|
|
import { c } from "#/di";
|
2025-02-27 03:56:30 +00:00
|
|
|
import { Client, Connection} from '@temporalio/client';
|
|
|
|
|
|
2025-03-01 21:10:31 +00:00
|
|
|
c.bind({
|
2025-02-27 03:56:30 +00:00
|
|
|
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
|
|
|
|
|
},
|
|
|
|
|
});
|