Open yossi-mycedar opened 1 year ago
Hi, @yossi-mycedar Do you have a sample?
When your activity needs to inject other services, how can it be done?
The same way you inject dependencies into your services (normal nestjs way). @shaolinjr
@adzamkomladev Sorry for the late response. Currently I'm doing it in the following way: (the following code was taken from app.module.ts)
// Configure a Temporal worker
TemporalModule.forRootAsync({
imports: [ClientsModule, ConfigModule],
inject: ['ClientsService', ConfigService],
useFactory: async (
clientsService: ClientsService,
configService: ConfigService
) => {
Runtime.install({});
const clientCert = fs.readFileSync(
`./${configService.get<string>('TEMPORAL_CERT_FILENAME')}.pem`
);
const clientKey = fs.readFileSync(
`./${configService.get<string>('TEMPORAL_CERT_FILENAME')}.key`
);
const connection = await NativeConnection.connect({
address: configService.get<string>('TEMPORAL_HOST'), // defaults port to 7233 if not specified
tls: {
clientCertPair: {
crt: clientCert,
key: clientKey,
},
},
});
const workflowBundle = await bundleWorkflowCode({
workflowsPath: require.resolve('./clients/temporal/workflows'),
});
return {
connection,
activities: clientActivities(clientsService),
taskQueue: TEMPORAL_QUEUE_NAME,
namespace: configService.get<string>('TEMPORAL_NAMESPACE'),
workflowBundle,
};
},
}),
Have a look at:
activities: clientActivities(clientsService),
But it feels to me like a workaround (cause defining my service in app.module sounds wrong to me).
Any suggestion / thoughts? Thanks a lot.
Hey. First of all thanks a lot for this module. It seems like there is an issue when trying to inject / import other services to this module in order to be able to use them in activities (Activity should be able to use a service -> which has a repository injected to it -> etc...) Any suggestion? Thanks