prefork

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsChild

func IsChild() bool

IsChild determines if the current process is a child of Prefork

Types

type HttpServer added in v1.3.5

type HttpServer interface {
	Serve(l net.Listener) error
	ServeTLS(l net.Listener, certFile, keyFile string) error
}

type Logger

type Logger interface {
	// Printf must have the same semantics as log.Printf.
	Printf(format string, args ...interface{})
}

Logger is used for logging formatted messages.

type Prefork

type Prefork struct {
	// The network must be "tcp", "tcp4" or "tcp6".
	//
	// By default is "tcp4"
	Network      string
	Addr         string
	ServeFunc    func(ln net.Listener) error
	ServeTLSFunc func(ln net.Listener, certFile, keyFile string) error
}

Prefork implements fasthttp server prefork

Preforks master process (with all cores) between several child processes increases performance significantly, because Go doesn't have to share and manage memory between cores

WARNING: using prefork prevents the use of any global state! Things like in-memory caches won't work.

func New

func New(s HttpServer, addr string) *Prefork

New wraps the net/http server to run with preforked processes

func (*Prefork) ListenAndServe

func (p *Prefork) ListenAndServe() error

ListenAndServe serves HTTP requests from the given TCP addr

func (*Prefork) ListenAndServeTLS

func (p *Prefork) ListenAndServeTLS(certKey, certFile string) error

ListenAndServeTLS serves HTTPS requests from the given TCP addr

certFile and keyFile are paths to TLS certificate and key files.

Jump to

Keyboard shortcuts

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