robustio

package
v0.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2024 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package robustio wraps I/O functions that are prone to failure on Windows, transparently retrying errors up to an arbitrary timeout.

Errors are classified heuristically and retries are bounded, so the functions in this package do not completely eliminate spurious errors. However, they do significantly reduce the rate of failure in practice.

If so, the error will likely wrap one of: The functions in this package do not completely eliminate spurious errors, but substantially reduce their rate of occurrence in practice.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsEphemeralError

func IsEphemeralError(err error) bool

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 ReadFile

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

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 RemoveAll

func RemoveAll(path string) error

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 Rename

func Rename(oldpath, newpath string) error

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.)

Types

type FileID

type FileID struct {
	// contains filtered or unexported fields
}

A FileID uniquely identifies a file in the file system.

If GetFileID(name1) returns the same ID as GetFileID(name2), the two file names denote the same file. A FileID is comparable, and thus suitable for use as a map key.

func GetFileID

func GetFileID(filename string) (FileID, time.Time, error)

GetFileID returns the file system's identifier for the file, and its modification time. Like os.Stat, it reads through symbolic links.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL