Documentation
¶
Index ¶
- func Buggify(probability float64) bool
- func BuggifyEnabled() bool
- func DisableBuggify()
- func EnableBuggify(seed int64)
- func SuspendBuggify() (resume func())
- type Clock
- type CryptoRand
- type Env
- type MemStorage
- func (m *MemStorage) Chtimes(path string, atime, mtime time.Time) error
- func (m *MemStorage) MkdirAll(path string, perm os.FileMode) error
- func (m *MemStorage) ReadDir(path string) ([]fs.DirEntry, error)
- func (m *MemStorage) ReadFile(path string) ([]byte, error)
- func (m *MemStorage) Remove(path string) error
- func (m *MemStorage) Stat(path string) (os.FileInfo, error)
- func (m *MemStorage) WriteFile(path string, data []byte, perm os.FileMode) error
- type OSStorage
- func (OSStorage) CheckWritable(path string) error
- func (OSStorage) Chmod(path string, mode os.FileMode) error
- func (OSStorage) Chtimes(path string, atime, mtime time.Time) error
- func (OSStorage) Lstat(path string) (os.FileInfo, error)
- func (OSStorage) MkdirAll(path string, perm os.FileMode) error
- func (OSStorage) ReadDir(path string) ([]fs.DirEntry, error)
- func (OSStorage) ReadFile(path string) ([]byte, error)
- func (OSStorage) Readlink(path string) (string, error)
- func (OSStorage) Remove(path string) error
- func (OSStorage) Stat(path string) (os.FileInfo, error)
- func (OSStorage) Symlink(oldname, newname string) error
- func (OSStorage) WriteFile(path string, data []byte, perm os.FileMode) error
- type Rand
- type RealClock
- type SeededRand
- type SimClock
- type Storage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Buggify ¶
Buggify returns true with the given probability, but ONLY when simulation mode is active. In production (not enabled), it always returns false with near-zero overhead (single boolean check).
func BuggifyEnabled ¶
func BuggifyEnabled() bool
BuggifyEnabled returns whether simulation fault injection is active.
func DisableBuggify ¶
func DisableBuggify()
DisableBuggify deactivates all fault injection. Call this at the end of a simulation run.
func EnableBuggify ¶
func EnableBuggify(seed int64)
EnableBuggify activates fault injection with the given seed. Call this at the start of a simulation run.
func SuspendBuggify ¶ added in v0.14.0
func SuspendBuggify() (resume func())
SuspendBuggify switches fault injection off until the returned resume is called, which restores the previous state with its random stream intact. An invariant check uses it so it observes what is persisted, not faults injected into its own reads, without perturbing the run's later choices. Suspensions nest.
Types ¶
type Clock ¶
type Clock interface {
Now() time.Time
After(d time.Duration) <-chan time.Time
Sleep(d time.Duration)
}
Clock abstracts time operations for deterministic simulation.
type Env ¶
Env bundles all I/O abstractions needed for deterministic simulation. Pass *Env through call chains instead of threading individual interfaces.
type MemStorage ¶
type MemStorage struct {
// contains filtered or unexported fields
}
MemStorage is an in-memory Storage implementation for tests and browser fallback.
func NewMemStorage ¶
func NewMemStorage() *MemStorage
NewMemStorage creates a new in-memory storage.
func (*MemStorage) Chtimes ¶
func (m *MemStorage) Chtimes(path string, atime, mtime time.Time) error
Chtimes sets the access and modification times of the named file.
func (*MemStorage) MkdirAll ¶
func (m *MemStorage) MkdirAll(path string, perm os.FileMode) error
MkdirAll creates the directory and all parent directories.
func (*MemStorage) ReadDir ¶
func (m *MemStorage) ReadDir(path string) ([]fs.DirEntry, error)
ReadDir returns directory entries for the given path.
func (*MemStorage) ReadFile ¶
func (m *MemStorage) ReadFile(path string) ([]byte, error)
ReadFile reads the file at the given path. Returns a copy of the data.
func (*MemStorage) Remove ¶
func (m *MemStorage) Remove(path string) error
Remove deletes the file or empty directory at the given path.
type OSStorage ¶
type OSStorage struct{}
OSStorage delegates to the os package. Used in production and WASI.
func (OSStorage) CheckWritable ¶ added in v0.13.0
CheckWritable reports, with access(2), whether this process may write path: a file's content, or a directory's entries. It is not part of Storage, since not every storage has permissions; callers that need it check for it.
func (OSStorage) Chmod ¶ added in v0.11.0
Chmod changes a file's mode. It is not part of Storage, since not every storage has file modes; callers that need it check for it.
func (OSStorage) Lstat ¶ added in v0.14.0
Lstat is Stat without following a final symbolic link. It is not part of Storage, since not every storage has symbolic links or file modes; callers that need it check for it.
func (OSStorage) Readlink ¶ added in v0.14.0
Readlink returns the target a symbolic link names. Like Lstat, it is not part of Storage.
type SeededRand ¶
type SeededRand struct {
// contains filtered or unexported fields
}
SeededRand uses a seeded math/rand source for deterministic output.
func NewSeededRand ¶
func NewSeededRand(seed int64) *SeededRand
type SimClock ¶
type SimClock struct {
// contains filtered or unexported fields
}
SimClock is a virtual clock for deterministic simulation. Time only advances when Advance or AdvanceTo is called explicitly.
func NewSimClock ¶
func NewSimClock() *SimClock
NewSimClock creates a SimClock starting at Unix epoch zero.
func NewSimClockAt ¶
NewSimClockAt creates a SimClock starting at the given time.
func (*SimClock) AdvanceTo ¶
AdvanceTo sets the clock to t (must be >= current time) and fires any waiters whose deadline has been reached.
func (*SimClock) After ¶
After returns a channel that receives the current time once the clock has been advanced past the deadline. The channel is never selected until Advance/AdvanceTo is called.
func (*SimClock) PendingCount ¶
PendingCount returns the number of waiters that haven't fired yet. Useful for the simulator to know if any node is sleeping.
type Storage ¶
type Storage interface {
Stat(path string) (os.FileInfo, error)
Remove(path string) error
MkdirAll(path string, perm os.FileMode) error
ReadFile(path string) ([]byte, error)
WriteFile(path string, data []byte, perm os.FileMode) error
ReadDir(path string) ([]fs.DirEntry, error)
Chtimes(path string, atime, mtime time.Time) error
}
Storage abstracts filesystem operations for WASM portability.