server

package
v0.229.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package server hosts the HTTP and (later) HTTPS listeners. Multiple servers share one http.Handler and run concurrently under an Orchestrator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Orchestrator

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

Orchestrator runs multiple Server instances concurrently and shuts them down together on context cancellation or first non-expected error.

func NewOrchestrator

func NewOrchestrator(servers ...Server) *Orchestrator

NewOrchestrator constructs an Orchestrator over non-nil servers.

func (*Orchestrator) Start

func (o *Orchestrator) Start(ctx context.Context) (err error)

Start blocks until ctx is cancelled or any server fails.

func (*Orchestrator) WithShutdownTimeout

func (o *Orchestrator) WithShutdownTimeout(d time.Duration) *Orchestrator

WithShutdownTimeout overrides the default shutdown grace period.

type Server

type Server interface {
	ListenAndServe() error
	Shutdown(ctx context.Context) error
	IsExpectedStopErr(err error) bool
}

Server is the minimum surface the Orchestrator needs.

func NewHTTP

func NewHTTP(addr string, handler http.Handler, t Timeouts) Server

NewHTTP returns a plain HTTP Server bound to addr.

func NewHTTPS

func NewHTTPS(addr string, handler http.Handler, tlsCfg *tls.Config, t Timeouts) Server

NewHTTPS returns an HTTPS Server bound to addr using tlsCfg.

type Timeouts

type Timeouts struct {
	ReadHeader time.Duration
	Write      time.Duration
	Idle       time.Duration
}

Timeouts is the parameter object for the four http.Server timeouts the mock exposes. Zero means "use the http stdlib default" (which for WriteTimeout and IdleTimeout is effectively unbounded — set them explicitly).

Jump to

Keyboard shortcuts

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