kbhttp

package
v0.0.0-...-c5434ca Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: BSD-3-Clause Imports: 8 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPinnedPortInUse = errors.New("unable to bind to pinned port")

Functions

This section is empty.

Types

type AutoPortListenerSource

type AutoPortListenerSource struct{}

AutoPortListenerSource means listen on a port that's picked automatically by the kernel.

func NewAutoPortListenerSource

func NewAutoPortListenerSource() *AutoPortListenerSource

NewAutoPortListenerSource creates a new AutoPortListenerSource.

func (AutoPortListenerSource) GetListener

func (r AutoPortListenerSource) GetListener() (net.Listener, string, error)

GetListener implements ListenerSource.

type ListenerSource

type ListenerSource interface {
	GetListener() (net.Listener, string, error)
}

ListenerSource represents where an HTTP server should listen.

type PortRangeListenerSource

type PortRangeListenerSource struct {
	sync.Mutex
	// contains filtered or unexported fields
}

PortRangeListenerSource means listen on the given range.

func NewFixedPortListenerSource

func NewFixedPortListenerSource(port int) *PortRangeListenerSource

NewFixedPortListenerSource creates a new PortListenerSource listening on the given port.

func NewPortRangeListenerSource

func NewPortRangeListenerSource(low, high int) *PortRangeListenerSource

NewPortRangeListenerSource creates a new PortListenerSource listening on low to high (inclusive).

func (*PortRangeListenerSource) GetListener

func (p *PortRangeListenerSource) GetListener() (listener net.Listener, address string, err error)

GetListener implements ListenerSource.

type RandomPortRangeListenerSource

type RandomPortRangeListenerSource struct {
	sync.Mutex
	// contains filtered or unexported fields
}

RandomPortRangeListenerSource listens on a port randomly chosen within a given range.

func NewRandomPortRangeListenerSource

func NewRandomPortRangeListenerSource(low, high int) *RandomPortRangeListenerSource

NewRandomPortRangeListenerSource creates a new RadomPortListenerSource listening on low to high (exclusive).

func (*RandomPortRangeListenerSource) GetListener

func (p *RandomPortRangeListenerSource) GetListener() (listener net.Listener, address string, err error)

GetListener implements ListenerSource.

type Srv

type Srv struct {
	sync.Mutex
	*http.ServeMux
	// contains filtered or unexported fields
}

Srv starts a simple HTTP server with a parameter for a module to provide a listener source

func NewSrv

func NewSrv(log logger.Logger, listenerSource ListenerSource) *Srv

NewSrv creates a new HTTP server with the given listener source.

func (*Srv) Active

func (h *Srv) Active() bool

Active returns true if the server is active.

func (*Srv) Addr

func (h *Srv) Addr() (string, error)

Addr returns the server's address, if it's running.

func (*Srv) Start

func (h *Srv) Start() (err error)

Start starts listening on the server's listener source.

func (*Srv) Stop

func (h *Srv) Stop() <-chan struct{}

Stop stops listening on the server's listener source.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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