use util/retry instead of wait fork directly
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
"git.k-space.ee/k-space/logmower-shipper/pkg/lines"
|
||||
m "git.k-space.ee/k-space/logmower-shipper/pkg/mongo"
|
||||
"git.k-space.ee/k-space/logmower-shipper/pkg/sender"
|
||||
"github.com/jtagcat/util/retry"
|
||||
"github.com/jtagcat/util/std"
|
||||
"github.com/jtagcat/util/tail"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
@@ -39,17 +40,14 @@ type File struct {
|
||||
|
||||
// TODO: caller could call duplicate shipFile of same name on file replace: sends might not work properly
|
||||
func (f File) Process(ctx context.Context, db *mongo.Collection) {
|
||||
_ = wait.ManagedExponentialBackoffWithContext(ctx, backoff(), func() (done bool, _ error) {
|
||||
_ = retry.OnErrorManagedBackoff(ctx, backoff(), func() (retryable bool, _ error) {
|
||||
err := f.process(ctx, db)
|
||||
if err == nil {
|
||||
return true, nil
|
||||
if err != nil {
|
||||
promFileErr.WithLabelValues(f.MetricsName).Add(1)
|
||||
log.Printf("processing file %q: %e", f.MetricsName, err)
|
||||
}
|
||||
|
||||
promFileErr.WithLabelValues(f.MetricsName).Add(1)
|
||||
log.Printf("processing file %q: %e", f.MetricsName, err)
|
||||
|
||||
// nil: loop and keep retrying indefinitely
|
||||
return false, nil
|
||||
return true, err
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user