httpadmission

package
v0.1.0-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package httpadmission counts the requests an HTTP handler has admitted and not yet returned from, so a server's stop can wait for them after a forced close.

net/http stops tracking a handler once its connection is closed: after http.Server.Close, a later Shutdown returns nil at once while the handler still runs (setup-04a-03-boot-service-manager design D2, probe C3 on #353). A server that must not report itself stopped while a handler runs wraps its handler with Requests.Wrap, closes admission when its stop begins, and waits with Requests.Wait. metric.Server and the service manager's listeners use it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Requests

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

Requests counts admitted requests. Closing admission first means that once it is closed and nothing runs, which Wait observes under the same lock, no request can start. The zero value is ready to use; a Requests must not be copied after first use.

func (*Requests) CloseAdmission

func (r *Requests) CloseAdmission()

CloseAdmission refuses every later request; requests already admitted run on.

func (*Requests) Pending

func (r *Requests) Pending() int

Pending returns how many admitted requests are still running.

func (*Requests) Wait

func (r *Requests) Wait(ctx context.Context) error

Wait returns nil once no admitted request is running, or ctx's error if ctx ends first.

func (*Requests) Wrap

func (r *Requests) Wrap(next http.Handler, refusal string) http.Handler

Wrap returns a handler that admits each request through r before calling next. After CloseAdmission a request is refused with 503, the text refusal and "Connection: close", and next is not called.

Jump to

Keyboard shortcuts

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