in pcap-fsnotify/internal/gcs/client_library_exporter.go [261:302]
func (x *libraryExporter) newObject(
srcPcapFile *string,
tgtPcapFile *string,
) *storage.ObjectHandle {
attempts := uint8(0)
return x.handle.
Object(*tgtPcapFile).
Retryer(
storage.WithBackoff(gax.Backoff{
Initial: 2 * time.Second,
Max: time.Duration(x.maxRetries) * x.retriesDelay * time.Second,
}),
storage.WithMaxAttempts(int(x.maxRetries)),
storage.WithErrorFunc(func(err error) bool {
// see: https://pkg.go.dev/cloud.google.com/go/storage#WithErrorFunc
// GCS client always calls this function, even when `err` is `nil`
if err == nil {
// if `err` is `nil`, then prevent retyring by returning `false`:
// - which we assume is the logical thing to do if there is no error...
return false
}
attempts += 1
x.logger.LogEvent(
zapcore.WarnLevel,
sf.Format("failed to EXPORT file at attempt {0}: {1}", attempts, *srcPcapFile),
PCAP_EXPORT,
map[string]any{
"source": *srcPcapFile,
"target": tgtPcapFile,
"attempt": attempts,
},
err,
)
return true
}),
storage.WithPolicy(storage.RetryAlways),
)
}