291
}, nil
292
})
294
d.logger.Info("SetQueryHandler failed for WorkerDeployment create request-id query with error: " + err.Error())
295
return err
296
}
297
298
>
if err := workflow.SetUpdateHandlerWithOptions(
workflow.go
299
>
ctx,
300
>
CreateWorkerDeployment,
301
>
d.handleCreateWorkerDeployment,
302
>
workflow.UpdateHandlerOptions{
303
>
Validator: d.validateCreateWorkerDeployment,
304
>
},
305
>
); err != nil {
306
return err
307
}
308
309
>
if err := workflow.SetUpdateHandlerWithOptions(
workflow.go
310
>
ctx,
311
>
CreateWorkerDeploymentVersion,
312
>
d.handleCreateWorkerDeploymentVersion,
313
>
workflow.UpdateHandlerOptions{
314
>
Validator: d.validateCreateWorkerDeploymentVersion,
315
>
},
316
>
); err != nil {
317
return err
318
}
319
321
>
ctx,
322
>
RegisterWorkerInWorkerDeployment,
323
>
d.handleRegisterWorker,
324
>
); err != nil {
325
return err
326
}
327
328
>
if err := workflow.SetUpdateHandlerWithOptions(
workflow.go
329
>
ctx,
330
>
SetCurrentVersion,
331
>
d.handleSetCurrent,
332
>
workflow.UpdateHandlerOptions{
333
>
Validator: d.validateSetCurrent,
334
>
},
335
>
); err != nil {
336
return err
337
}
338
339
>
if err := workflow.SetUpdateHandlerWithOptions(
workflow.go
340
>
ctx,
341
>
SetRampingVersion,
342
>
d.handleSetRampingVersion,
343
>
workflow.UpdateHandlerOptions{
344
>
Validator: d.validateSetRampingVersion,
345
>
},
346
>
); err != nil {
347
return err
348
}
349
350
>
if err := workflow.SetUpdateHandlerWithOptions(
workflow.go
351
>
ctx,
352
>
SetManagerIdentity,
353
>
d.handleSetManager,
354
>
workflow.UpdateHandlerOptions{
355
>
Validator: d.validateSetManager,
356
>
},
357
>
); err != nil {
358
return err
359
}
360
361
>
if err := workflow.SetUpdateHandlerWithOptions(
workflow.go
362
>
ctx,
363
>
DeleteVersion,
364
>
d.handleDeleteVersion,
365
>
workflow.UpdateHandlerOptions{
366
>
Validator: d.validateDeleteVersion,
367
>
},
368
>
); err != nil {
369
return err
370
}
371
372
>
if err := workflow.SetUpdateHandlerWithOptions(
workflow.go
373
>
ctx,
374
>
DeleteDeployment,
375
>
d.handleDeleteDeployment,
376
>
workflow.UpdateHandlerOptions{
377
>
Validator: d.validateDeleteDeployment,
378
>
},
379
>
); err != nil {
380
return err
381
}
382
383
// Listen to signals in a different goroutine to make business logic clearer
385
>
386
>
// Wait until we can continue as new or are cancelled. The workflow will continue-as-new iff
387
>
// there are no pending updates/signals and the state has changed.
388
>
err = workflow.Await(ctx, func() bool {
389
>
canContinue := d.deleteDeployment || // deployment is deleted -> it's ok to drop all signals and updates.
390
>
// There is no pending signal or update, but the state is dirty or forceCaN is requested:
391
>
(!d.signalHandler.signalSelector.HasPending() && d.signalHandler.processingSignals == 0 && workflow.AllHandlersFinished(ctx) &&
392
>
(d.forceCAN || d.stateChanged || workflow.GetInfo(ctx).GetContinueAsNewSuggested()))
393
>
394
>
// TODO(carlydf): remove verbose logging
395
>
if canContinue {
396
d.logger.Info("Workflow can continue as new",
397
"workflow_id", workflow.GetInfo(ctx).WorkflowExecution.ID,