1277
// syncVersionDataToTaskQueues is a helper that syncs the provided version data to all task queues.
1278
// This function does NOT acquire the workflow lock - the caller is responsible for that.
1279
>
func (d *VersionWorkflowRunner) syncVersionDataToTaskQueues(ctx workflow.Context, versionData *deploymentspb.DeploymentVersionData) error {
version_workflow.go
1280
>
state := d.GetVersionState()
1281
>
1282
>
// sync to task queues
1283
>
syncReq := &deploymentspb.SyncDeploymentVersionUserDataRequest{
1284
>
Version: state.GetVersion(),
1285
>
}
1286
>
1287
>
// send in the task-queue families in batches of syncBatchSize
1288
>
batches := make([][]*deploymentspb.SyncDeploymentVersionUserDataRequest_SyncUserData, 0)
1289
>
for _, tqName := range workflow.DeterministicKeys(state.TaskQueueFamilies) {
1290
>
byType := state.TaskQueueFamilies[tqName]
1291
>
var types []enumspb.TaskQueueType
1292
>
for _, tqType := range workflow.DeterministicKeys(byType.TaskQueues) {
1293
>
types = append(types, enumspb.TaskQueueType(tqType))
1294
>
}
1295
1296
>
syncReq.Sync = append(syncReq.Sync, &deploymentspb.SyncDeploymentVersionUserDataRequest_SyncUserData{
version_workflow.go
1297
>
Name: tqName,
1298
>
Types: types,
1299
>
Data: versionData,
1300
>
})
1301
>
1302
>
if len(syncReq.Sync) == int(d.VersionState.SyncBatchSize) {
1303
batches = append(batches, syncReq.Sync)
1304
syncReq.Sync = make([]*deploymentspb.SyncDeploymentVersionUserDataRequest_SyncUserData, 0) // reset the syncReq.Sync slice for the next batch
1305
}
1306
}
1308
>
batches = append(batches, syncReq.Sync)
1309
>
}
1310
1311
// calling SyncDeploymentVersionUserData for each batch
1313
>
activityCtx := workflow.WithActivityOptions(ctx, defaultActivityOptions)
1314
>
var syncRes deploymentspb.SyncDeploymentVersionUserDataResponse
1315
>
1316
>
err := workflow.ExecuteActivity(activityCtx, d.a.SyncDeploymentVersionUserData, &deploymentspb.SyncDeploymentVersionUserDataRequest{
1317
>
Version: state.GetVersion(),
1318
>
Sync: batch,
1319
>
}).Get(ctx, &syncRes)
1320
>
if err != nil {
1321
return err
1322
}
1324
>
// wait for propagation
1325
>
err = workflow.ExecuteActivity(
1326
>
activityCtx,
1327
>
d.a.CheckWorkerDeploymentUserDataPropagation,
1328
>
&deploymentspb.CheckWorkerDeploymentUserDataPropagationRequest{
1329
>
TaskQueueMaxVersions: syncRes.TaskQueueMaxVersions,
1330
>
}).Get(ctx, nil)
1331
>
if err != nil {
1332
return err
1333
}