Help us shape the future of Go! Take the 2026 Go Developer Survey

serverruntime

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package serverruntime owns shared server workers and HTTP lifecycle. Local discovery, operator sockets and deployment policy remain composition concerns.

Index

Constants

View Source
const (
	ShutdownTimeout = 15 * time.Second
)

Variables

This section is empty.

Functions

func Run

func Run(parent context.Context, store Worker, log io.Writer, bindings []Binding, ready func() error) error

Run joins processing and listener loops before returning, without closing the caller's store. HTTP requests drain within ShutdownTimeout; on expiry their connections close. Handlers must honor request cancellation.

func Serve

func Serve(parent context.Context, store Readiness, bindings []Binding, ready func() error) error

Serve has Run's HTTP shutdown contract but starts no processing. Validation leaves resources untouched; once serving starts, all listeners close on exit. The composition owns storage, processing and cleanup on validation failure.

Types

type Binding

type Binding struct {
	Listener net.Listener
	Handler  http.Handler
	Health   bool
}

type Readiness

type Readiness interface{ Ready(context.Context) error }

Readiness checks initialized storage, not processing-queue emptiness.

type Worker

type Worker interface {
	Readiness
	Run(context.Context, func(error))
}

Worker.Run returns only after all child work has joined. Storage stays owned by composition; implementations must stop on cancellation without discarding accepted evidence or pending work.

Jump to

Keyboard shortcuts

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