wynn/ts/src/services/temporal/index.ts

26 lines
633 B
TypeScript
Raw Normal View History

2025-06-14 23:04:46 +00:00
import { Client, Connection } from '@temporalio/client'
import { config } from '#/config'
import { c } from '#/di'
2025-02-27 03:56:30 +00:00
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,
2025-03-22 07:08:26 +00:00
dataConverter: {
2025-06-14 05:36:37 +00:00
payloadConverterPath: require.resolve('../../payload_converter'),
2025-03-22 07:08:26 +00:00
},
2025-06-14 23:04:46 +00:00
})
2025-02-27 03:56:30 +00:00
process.on('exit', () => {
2025-06-14 23:04:46 +00:00
console.log('closing temporal client')
client.connection.close()
})
2025-02-27 03:56:30 +00:00
return client
},
2025-06-14 23:04:46 +00:00
})