httpserver

package
v1.0.12758-54d8f47 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 11 Imported by: 2

Documentation

Overview

Package httpserver contains helpers for creating zero-downtime REST APIs.

There are tools for: - observability (both for requests and connection info) - health checks

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Name is the name of the server in o11y
	Name string
	// Addr is the address to listen on
	Addr string
	// Handler is the  HTTP handler to delegate requests to.
	Handler http.Handler

	// Optional
	// Network must be "tcp", "tcp4", "tcp6", "unix", "unixpacket" or "" (which defaults to tcp).
	Network string

	// ShutdownGrace is the period during which the server allows requests to be fully served.
	ShutdownGrace time.Duration
}

type HTTPServer

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

func Load

func Load(ctx context.Context, cfg Config, sys *system.System) (*HTTPServer, error)

func New

func New(ctx context.Context, cfg Config) (s *HTTPServer, err error)

func (HTTPServer) Addr

func (s HTTPServer) Addr() string

func (*HTTPServer) MetricsProducer

func (s *HTTPServer) MetricsProducer() MetricProducer

func (*HTTPServer) Serve

func (s *HTTPServer) Serve(ctx context.Context) error

Serve the http server. On context cancellation the server is shutdown giving some time for the in flight requests to be handled.

type MetricProducer

type MetricProducer interface {
	// MetricName The name for this group of metrics
	//(Name might be cleaner, but is much more likely to conflict in implementations)
	MetricName() string
	// Gauges are instantaneous name value pairs
	Gauges(context.Context) map[string]float64
}

Directories

Path Synopsis
Package ginrouter provides a common base for configuring a Gin router instance, wiring in the standard o11y wrappers.
Package ginrouter provides a common base for configuring a Gin router instance, wiring in the standard o11y wrappers.
Package healthcheck contains a simple healthcheck handler.
Package healthcheck contains a simple healthcheck handler.

Jump to

Keyboard shortcuts

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