@@ -28,13 +28,16 @@ export const exampleWorkflow = workflow.define({
2828 windSpeed : number ;
2929 windGust : number ;
3030 } > => {
31+ console . time ( "overall" ) ;
32+ console . time ( "geocoding" ) ;
3133 // Run in parallel!
3234 const [ { latitude, longitude, name } , weather2 ] = await Promise . all ( [
3335 step . runAction ( internal . example . getGeocoding , args , { runAfter : 100 } ) ,
3436 step . runAction ( internal . example . getGeocoding , args , { retry : true } ) ,
3537 ] ) ;
3638 console . log ( "Is geocoding is consistent?" , latitude === weather2 . latitude ) ;
37-
39+ console . timeLog ( "geocoding" , name ) ;
40+ console . time ( "weather" ) ;
3841 const weather = await step . runAction ( internal . example . getWeather , {
3942 latitude,
4043 longitude,
@@ -45,6 +48,12 @@ export const exampleWorkflow = workflow.define({
4548 console . log (
4649 `Weather in ${ name } : ${ farenheit . toFixed ( 1 ) } °F (${ temperature } °C), ${ windSpeed } km/h, ${ windGust } km/h` ,
4750 ) ;
51+ console . timeLog ( "weather" , temperature ) ;
52+ await step . runMutation ( internal . example . updateFlow , {
53+ workflowId : step . workflowId ,
54+ out : { name, celsius, farenheit, windSpeed, windGust } ,
55+ } ) ;
56+ console . timeEnd ( "overall" ) ;
4857 return { name, celsius, farenheit, windSpeed, windGust } ;
4958 } ,
5059 workpoolOptions : {
@@ -109,7 +118,8 @@ export const flowCompleted = internalMutation({
109118 await ctx . db . patch ( flow . _id , {
110119 out : args . result ,
111120 } ) ;
112- await workflow . cleanup ( ctx , args . workflowId ) ;
121+ // To delete the workflow data after it completes:
122+ // await workflow.cleanup(ctx, args.workflowId);
113123 } ,
114124} ) ;
115125
0 commit comments