import * as fs from 'fs/promises' ; import { createHash } from 'crypto' ; import { Context } from '@temporalio/activity' ; export function createNonStickyActivities ( uniqueWorkerTaskQueue ) { return { async getUniqueTaskQueue ( ) { return uniqueWorkerTaskQueue ; } , } ; } export function createStickyActivities ( ) { return { async downloadFileToWorkerFileSystem ( url , path ) { console . log ( `Downloading ${ url } and saving to ${ path }` ) ; const body = Buffer . from ( 'downloaded body' ) ; await Context . current ( ) . sleep ( 3000 ) ; await fs . writeFile ( path , body ) ; } , async workOnFileInWorkerFileSystem ( path ) { const content = await fs . readFile ( path ) ; const checksum = createHash ( 'md5' ) . update ( content ) . digest ( 'hex' ) ; await Context . current ( ) . sleep ( 3000 ) ; console . log ( `Did some work on ${ path }, checksum: ${ checksum }` ) ; } , async cleanupFileFromWorkerFileSystem ( path ) { await Context . current ( ) . sleep ( 3000 ) ; console . log ( `Removing ${ path }` ) ; await fs . rm ( path ) ; } , } ; }