robustio

Imports

Imports #

"os"
"errors"
"internal/syscall/windows"
"syscall"
"errors"
"syscall"
"errors"
"math/rand"
"os"
"syscall"
"time"

Constants & Variables

arbitraryTimeout const #

const arbitraryTimeout = *ast.BinaryExpr

errFileNotFound const #

const errFileNotFound = syscall.ERROR_FILE_NOT_FOUND

errFileNotFound const #

const errFileNotFound = syscall.ENOENT

Functions

IsEphemeralError function #

IsEphemeralError reports whether err is one of the errors that the functions in this package attempt to mitigate. Errors considered ephemeral include: - syscall.ERROR_ACCESS_DENIED - syscall.ERROR_FILE_NOT_FOUND - internal/syscall/windows.ERROR_SHARING_VIOLATION This set may be expanded in the future; programs must not rely on the non-ephemerality of any given error.

func IsEphemeralError(err error) bool

ReadFile function #

ReadFile is like os.ReadFile, but on Windows retries errors that may occur if the file is concurrently replaced. (See golang.org/issue/31247 and golang.org/issue/32188.)

func ReadFile(filename string) ([]byte, error)

RemoveAll function #

RemoveAll is like os.RemoveAll, but on Windows retries errors that may occur if an executable file in the directory has recently been executed. (See golang.org/issue/19491.)

func RemoveAll(path string) error

Rename function #

Rename is like os.Rename, but on Windows retries errors that may occur if the file is concurrently read or overwritten. (See golang.org/issue/31247 and golang.org/issue/32188.)

func Rename(oldpath string, newpath string) error

isEphemeralError function #

func isEphemeralError(err error) bool

isEphemeralError function #

isEphemeralError returns true if err may be resolved by waiting.

func isEphemeralError(err error) bool

isEphemeralError function #

isEphemeralError returns true if err may be resolved by waiting.

func isEphemeralError(err error) bool

readFile function #

func readFile(filename string) ([]byte, error)

readFile function #

readFile is like os.ReadFile, but retries ephemeral errors.

func readFile(filename string) ([]byte, error)

removeAll function #

func removeAll(path string) error

removeAll function #

func removeAll(path string) error

rename function #

func rename(oldpath string, newpath string) error

rename function #

rename is like os.Rename, but retries ephemeral errors. On Windows it wraps os.Rename, which (as of 2019-06-04) uses MoveFileEx with MOVEFILE_REPLACE_EXISTING. Windows also provides a different system call, ReplaceFile, that provides similar semantics, but perhaps preserves more metadata. (The documentation on the differences between the two is very sparse.) Empirical error rates with MoveFileEx are lower under modest concurrency, so for now we're sticking with what the os package already provides.

func rename(oldpath string, newpath string) (err error)

retry function #

retry retries ephemeral errors from f up to an arbitrary timeout to work around filesystem flakiness on Windows and Darwin.

func retry(f func() (err error, mayRetry bool)) error

Generated with Arrow