in azkustoingest/result.go [102:143]
func (r *Result) poll(ctx context.Context) {
const pollInterval = 10 * time.Second
attempts := 3
delay := [3]int{120, 60, 10} // attempts are counted backwards
// create a table client
if r.tableClient != nil {
// Create a ticker to poll the table in 10 second intervals.
timer := time.NewTimer(pollInterval)
defer timer.Stop()
for {
select {
case <-ctx.Done():
r.record.Status = StatusRetrievalCanceled
r.record.FailureStatus = Transient
return
case <-timer.C:
smap, err := r.tableClient.Read(ctx, r.record.IngestionSourceID.String())
if err != nil {
if attempts == 0 {
r.record.Status = StatusRetrievalFailed
r.record.FailureStatus = Transient
r.record.Details = "Failed reading from Status Table: " + err.Error()
return
}
attempts = attempts - 1
time.Sleep(time.Duration(delay[attempts]+rand.Intn(5)) * time.Second)
} else {
r.record.FromMap(smap)
if r.record.Status.IsFinal() {
return
}
}
timer.Reset(pollInterval)
}
}
}
}