synclatency

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package synclatency hands a test a seeded wal.SyncLatency, so a test that runs on a RAM drive still sees the fsync window of a real device (rmp #3022).

It is the ONLY place the latency is configured from the environment, and it is imported only by tests and by the test configuration of example 37; the store and WAL packages read no environment variable.

  • GOGRAPH_FSYNC_LATENCY=off disables it: ForTest returns nil and the store behaves exactly as a production one.
  • GOGRAPH_FSYNC_LATENCY_SEED=<uint64> fixes the seed, to replay a failure.

Otherwise every call draws a fresh seed, and the seed is logged when the test fails.

Index

Constants

View Source
const (
	EnvSwitch = "GOGRAPH_FSYNC_LATENCY"
	EnvSeed   = "GOGRAPH_FSYNC_LATENCY_SEED"
)

The environment variables ForTest reads.

View Source
const (
	Min = 1 * time.Millisecond
	Max = 5 * time.Millisecond
)

Min and Max bound the injected delay per fsync: uniform in [Min, Max], the range of a consumer SSD's fsync under light load.

Variables

This section is empty.

Functions

func Enabled

func Enabled() bool

Enabled reports whether GOGRAPH_FSYNC_LATENCY leaves the latency on.

func ForTest

func ForTest(tb testing.TB) *wal.SyncLatency

ForTest returns a seeded wal.SyncLatency for tb, or nil when GOGRAPH_FSYNC_LATENCY=off. When tb fails, a cleanup logs the seed and the command-line setting that replays it. It fails tb if GOGRAPH_FSYNC_LATENCY_SEED is set but not an unsigned integer.

func Seed

func Seed() (uint64, error)

Seed returns GOGRAPH_FSYNC_LATENCY_SEED when it is set, or a fresh seed from the clock otherwise.

Types

This section is empty.

Jump to

Keyboard shortcuts

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