File tree Expand file tree Collapse file tree
services/apps/packages_worker/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { scheduleNpmIngest } from '../npm/schedule'
12import { svc } from '../service'
23
34setImmediate ( async ( ) => {
45 await svc . init ( )
6+ await scheduleNpmIngest ( )
57 await svc . start ( )
68} )
Original file line number Diff line number Diff line change 1+ import { ScheduleAlreadyRunning , ScheduleOverlapPolicy } from '@temporalio/client'
2+
3+ import { svc } from '../service'
4+
5+ import { npmHello } from './workflows'
6+
7+ export async function scheduleNpmIngest ( ) : Promise < void > {
8+ const { temporal } = svc
9+ if ( ! temporal ) throw new Error ( 'Temporal client not initialized' )
10+
11+ try {
12+ await temporal . schedule . create ( {
13+ scheduleId : 'npm-registry-ingest' ,
14+ spec : {
15+ cronExpressions : [ '15 3 * * *' ] ,
16+ } ,
17+ policies : {
18+ overlap : ScheduleOverlapPolicy . SKIP ,
19+ catchupWindow : '1 hour' ,
20+ } ,
21+ action : {
22+ type : 'startWorkflow' ,
23+ workflowType : npmHello ,
24+ taskQueue : 'packages-worker' ,
25+ workflowExecutionTimeout : '1 hour' ,
26+ retry : {
27+ initialInterval : '30 seconds' ,
28+ backoffCoefficient : 2 ,
29+ maximumAttempts : 3 ,
30+ } ,
31+ args : [ ] ,
32+ } ,
33+ } )
34+ } catch ( err ) {
35+ if ( err instanceof ScheduleAlreadyRunning ) {
36+ svc . log . info ( 'Schedule npm-registry-ingest already registered.' )
37+ } else {
38+ throw err
39+ }
40+ }
41+ }
You can’t perform that action at this time.
0 commit comments