failer

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FS

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

func NewFS

func NewFS(fs fs.FS, os fs.OS, failer Failer) *FS

func (*FS) Open

func (f *FS) Open(name string) (iofs.File, error)

Open implements fs.FS.

type Failer

type Failer interface {
	// Checks if the called operation should fail
	// os - the [fs.OS] object
	// Arguments helping to make a decision:
	// op`     - called operation
	// self   - object which method is called (e.g. Fd). Can be nil (e.g. for methods of `Fs`)
	// args   - the arguments of the operation
	ShouldFail(os fs.OS, op fs.Op, self any, args ...any) error
}

Failure-injection interface

type File

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

func NewFile

func NewFile(file fs.File, os fs.OS, failer Failer) *File

func (*File) Close

func (f *File) Close() error

Close implements fs.File.

func (*File) Name

func (f *File) Name() string

Name implements fs.File.

func (*File) Read

func (f *File) Read(p []byte) (int, error)

Read implements fs.File.

func (*File) ReadAt

func (f *File) ReadAt(p []byte, off int64) (n int, err error)

ReadAt implements fs.File.

func (*File) ReadDir

func (f *File) ReadDir(n int) ([]fs.DirEntry, error)

ReadDir implements fs.File.

func (*File) Seek

func (f *File) Seek(offset int64, whence int) (int64, error)

Seek implements fs.File.

func (*File) Stat

func (f *File) Stat() (fs.FileInfo, error)

Stat implements fs.File.

func (*File) Write

func (f *File) Write(p []byte) (n int, err error)

Write implements fs.File.

func (*File) WriteAt

func (f *File) WriteAt(p []byte, off int64) (n int, err error)

WriteAt implements fs.File.

type OS

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

func NewOS

func NewOS(os fs.OS, failer Failer) *OS

func (*OS) Chdir

func (o *OS) Chdir(dir string) error

Chdir implements fs.OS.

func (*OS) Chmod

func (o *OS) Chmod(name string, mode fs.FileMode) error

Chmod implements fs.OS.

func (*OS) Chown

func (o *OS) Chown(name string, uid int, gid int) error

Chown implements fs.OS.

func (*OS) Create

func (o *OS) Create(name string) (fs.File, error)

Create implements fs.OS.

func (*OS) DirFS

func (o *OS) DirFS(dir string) fs.FS

DirFS implements fs.OS.

func (*OS) Getwd

func (o *OS) Getwd() (dir string, err error)

Getwd implements fs.OS.

func (*OS) Lstat

func (o *OS) Lstat(name string) (fs.FileInfo, error)

Lstat implements fs.OS.

func (*OS) Mkdir

func (o *OS) Mkdir(name string, perm fs.FileMode) error

Mkdir implements fs.OS.

func (*OS) MkdirAll

func (o *OS) MkdirAll(path string, perm fs.FileMode) error

MkdirAll implements fs.OS.

func (*OS) Open

func (o *OS) Open(name string) (fs.File, error)

Open implements fs.OS.

func (*OS) OpenFile

func (o *OS) OpenFile(name string, flag int, perm fs.FileMode) (fs.File, error)

OpenFile implements fs.OS.

func (*OS) ReadDir

func (o *OS) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir implements fs.OS.

func (o *OS) ReadLink(name string) (string, error)

ReadLink implements fs.OS.

func (*OS) Stat

func (o *OS) Stat(name string) (fs.FileInfo, error)

Stat implements fs.OS.

func (o *OS) Symlink(oldName string, newName string) error

Symlink implements fs.OS.

type ProbabilityFailer

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

Generates random failures with the given probability

func NewProbabilityFailer

func NewProbabilityFailer(seed int64, prob float64) *ProbabilityFailer

Creates a new ProbabilityFailer with the given probability

func (*ProbabilityFailer) ShouldFail

func (pf *ProbabilityFailer) ShouldFail(_ fs.OS, op fs.Op, _ any, _ ...any) error

Jump to

Keyboard shortcuts

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