github.com/filecoin-project/bacalhau@v0.3.23-0.20230228154132-45c989550ace/pkg/requester/jobtransform/default_timeout.go (about)

     1  package jobtransform
     2  
     3  import (
     4  	"context"
     5  	"time"
     6  
     7  	"github.com/filecoin-project/bacalhau/pkg/model"
     8  )
     9  
    10  // Sets a default timeout value if one is not passed or below an acceptable value
    11  func NewTimeoutApplier(minTimeout, defaultTimeout time.Duration) Transformer {
    12  	return func(ctx context.Context, job *model.Job) (modified bool, err error) {
    13  		if job.Spec.GetTimeout() <= minTimeout {
    14  			job.Spec.Timeout = defaultTimeout.Seconds()
    15  			return true, nil
    16  		}
    17  		return
    18  	}
    19  }