1082
}
1083
1084
>
func (d *VersionWorkflowRunner) refreshDrainageInfo(ctx workflow.Context) {
version_workflow.go
1085
>
if d.VersionState.GetDrainageInfo().GetStatus() != enumspb.VERSION_DRAINAGE_STATUS_DRAINING {
1086
return // only refresh when status is draining
1087
}
1089
>
// regardless of results mark state as dirty so we CaN in the first opportunity now that some
1090
>
// history events are made.
1091
>
d.setStateChanged()
1092
>
}()
1093
1095
>
var interval time.Duration
1096
>
var err error
1097
>
if drainage.LastCheckedTime.AsTime().Equal(drainage.LastChangedTime.AsTime()) {
1098
>
// this is the first update, so we wait according to the grace period config
1099
>
interval, err = getSafeDurationConfig(ctx, "getVisibilityGracePeriod", d.unsafeVisibilityGracePeriodGetter, defaultVisibilityGrace)
1100
>
} else {
1101
// this is a subsequent check, we wait according to the refresh interval
1102
interval, err = getSafeDurationConfig(ctx, "getDrainageRefreshInterval", d.unsafeRefreshIntervalGetter, defaultVisibilityRefresh)
1103
}
1105
d.logger.Error("could not calculate drainage refresh interval", tag.Error(err))
1106
return
1107
}
1108
>
timeSinceLastRefresh := workflow.Now(ctx).Sub(drainage.LastCheckedTime.AsTime())
version_workflow.go
1109
>
if interval > timeSinceLastRefresh {
1110
>
if err = workflow.Sleep(ctx, interval-timeSinceLastRefresh); err != nil {
1111
d.logger.Error("error while trying to sleep", tag.Error(err))
1112
return