bodyreadhook

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package bodyreadhook lets a test fixture synchronize with a provider's HTTP connection reads. Production code never installs hooks; with none installed a socket read costs one atomic load.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AfterRead

func AfterRead(local string, n int)

AfterRead notifies installed hooks of a completed read.

func BeforeRead

func BeforeRead(conn net.Conn) (observed bool)

BeforeRead notifies installed hooks. It reports whether any hook is installed, so the caller can skip AfterRead's address lookup otherwise.

func Install

func Install(hooks *Hooks) (restore func())

Install adds hooks until the returned restore function runs. Parallel tests may install their own hooks; each sees every read and filters by address.

Types

type Hooks

type Hooks struct {
	// BeforeRead runs before the transport reads the socket.
	BeforeRead func(local string)
	// AfterRead runs after the socket read returns n bytes.
	AfterRead func(local string, n int)
}

Hooks observe socket reads on the owned provider transport, keyed by the client connection's local address.

Directories

Path Synopsis
Package readbarrier synchronizes a test fixture server with the owned provider transport's socket reads.
Package readbarrier synchronizes a test fixture server with the owned provider transport's socket reads.

Jump to

Keyboard shortcuts

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