http

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component interface {
	Stop()
}

Component defines long-running services within the http service that require graceful shutdown when service shuts down.

type Service

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

func NewService

func NewService(opt ...ServiceOpt) *Service

func (*Service) Component

func (s *Service) Component(comp Component)

Component registers a Component that will run within the service that requires stopping when service shuts down.

func (*Service) Register

func (s *Service) Register(path, method string, routeHandler http.Handler, preHandler ...negroni.Handler)

Register registers a route-handler (http.Handler) for a given path and http.Method. Pre-handler(s) can optionally be supplied, they will run before route-handler in the order supplied.

func (*Service) Start

func (s *Service) Start() error

Start starts the service Routes should be registered before calling start

func (*Service) Stop

func (s *Service) Stop() error

Stop gracefully shuts down the service without interrupting any active connections. Stop works by first calling all long-running registered components, and then calling underlying http-server Shutdown.

type ServiceOpt

type ServiceOpt func(*serviceOpts)

func App

func App(app ...func(*Service) error) ServiceOpt

func ServiceName

func ServiceName(name string) ServiceOpt

func ServicePort

func ServicePort(port int) ServiceOpt

func ServiceShutdownGracetime

func ServiceShutdownGracetime(t time.Duration) ServiceOpt

Jump to

Keyboard shortcuts

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