This came up in a separate discussion. It would be nice to support (a subset of) the following pattern out of the box.
var prevState *jobs.RunState
// This function is called each time the function below polls the run status.
update := func(info *retries.Info[jobs.Run]) {
state := info.Info.State
if state == nil {
return
}
if prevState == nil {
// First iteration
}
if prevState == nil || prevState.LifeCycleState != state.LifeCycleState {
log.Printf("%s Run status: %s", prefix, info.Info.State.LifeCycleState)
prevState = state
}
}