66 proxyActivities ,
77} from '@temporalio/workflow'
88
9- import { IMember } from '@crowd/types'
10-
119import * as activities from '../../activities'
1210import { IGetMembersForLFIDEnrichmentArgs } from '../../sources/lfid/types'
1311import { enrichMemberWithLFAuth0 } from '../lf-auth0/enrichMemberWithLFAuth0'
@@ -16,6 +14,15 @@ const { getLFIDEnrichableMembers } = proxyActivities<typeof activities>({
1614 startToCloseTimeout : '10 seconds' ,
1715} )
1816
17+ const { refreshToken } = proxyActivities < typeof activities > ( {
18+ startToCloseTimeout : '2 minutes' ,
19+ retry : {
20+ initialInterval : '2 seconds' ,
21+ backoffCoefficient : 2 ,
22+ maximumAttempts : 3 ,
23+ } ,
24+ } )
25+
1926export async function getMembersForLFIDEnrichment (
2027 args : IGetMembersForLFIDEnrichmentArgs ,
2128) : Promise < void > {
@@ -27,23 +34,23 @@ export async function getMembersForLFIDEnrichment(
2734 return
2835 }
2936
30- await Promise . all (
31- members . map ( ( member : IMember ) => {
32- return executeChild ( enrichMemberWithLFAuth0 , {
33- workflowId : 'member-enrichment-lfid/' + member . id ,
34- cancellationType : ChildWorkflowCancellationType . ABANDON ,
35- parentClosePolicy : ParentClosePolicy . PARENT_CLOSE_POLICY_ABANDON ,
36- workflowExecutionTimeout : '1 minute' ,
37- retry : {
38- backoffCoefficient : 2 ,
39- maximumAttempts : 10 ,
40- initialInterval : 2 * 1000 ,
41- maximumInterval : 30 * 1000 ,
42- } ,
43- args : [ member ] ,
44- } )
45- } ) ,
46- )
37+ const token = await refreshToken ( )
38+
39+ for ( const member of members ) {
40+ await executeChild ( enrichMemberWithLFAuth0 , {
41+ workflowId : 'member-enrichment-lfid/' + member . id ,
42+ cancellationType : ChildWorkflowCancellationType . ABANDON ,
43+ parentClosePolicy : ParentClosePolicy . PARENT_CLOSE_POLICY_ABANDON ,
44+ workflowExecutionTimeout : '10 minutes' ,
45+ retry : {
46+ backoffCoefficient : 2 ,
47+ maximumAttempts : 10 ,
48+ initialInterval : 2 * 1000 ,
49+ maximumInterval : 30 * 1000 ,
50+ } ,
51+ args : [ token , member ] ,
52+ } )
53+ }
4754
4855 await continueAsNew < typeof getMembersForLFIDEnrichment > ( {
4956 afterId : members [ members . length - 1 ] . id ,
0 commit comments