Documentation
¶
Index ¶
- Constants
- func New(opts ...Option) *fasthttp.Server
- type Option
- func WithConcurrency(concurrency int) Option
- func WithDisableKeepalive(disableKeepalive bool) Option
- func WithIdleTimeout(idleTimeout time.Duration) Option
- func WithLogAllErrors(logAllErrors bool) Option
- func WithMaxConnsPerIP(maxConnsPerIP int) Option
- func WithMaxRequestBodySize(maxRequestBodySize int) Option
- func WithMaxRequestsPerConn(maxRequestsPerConn int) Option
- func WithName(name string) Option
- func WithReadBufferSize(readBufferSize int) Option
- func WithReadTimeout(readTimeout time.Duration) Option
- func WithTCPKeepalive(tcpKeepalive bool) Option
- func WithWriteBufferSize(writeBufferSize int) Option
- func WithWriteTimeout(writeTimeout time.Duration) Option
Constants ¶
const ( DefaultServerName = "microcore" DefaultServerConcurrency = 256 * 1024 DefaultServerReadBufferSize = 4096 // 4 KB DefaultServerWriteBufferSize = 4096 // 4 KB DefaultServerReadTimeout = 10 * time.Second DefaultServerWriteTimeout = 10 * time.Second DefaultServerIdleTimeout = 10 * time.Second DefaultServerMaxConnsPerIP = 0 // unlimited DefaultServerMaxRequestsPerConn = 0 // unlimited DefaultServerMaxRequestBodySize = 4 * 1024 * 1024 // 4 MB DefaultServerDisableKeepalive = false DefaultServerTCPKeepalive = false DefaultServerLogAllErrors = true )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
func WithConcurrency ¶
The maximum number of concurrent connections the server may serve.
func WithDisableKeepalive ¶
Whether to disable keep-alive connections.
The server will close all the incoming connections after sending the first response to client if this option is set to true.
func WithIdleTimeout ¶
IdleTimeout is the maximum amount of time to wait for the next request when keep-alive is enabled. If IdleTimeout is zero, the value of ReadTimeout is used.
func WithLogAllErrors ¶
Logs all errors, including the most frequent 'connection reset by peer', 'broken pipe' and 'connection timeout' errors. Such errors are common in production serving real-world clients.
func WithMaxConnsPerIP ¶
Maximum number of concurrent client connections allowed per IP.
func WithMaxRequestBodySize ¶
Whether to disable keep-alive connections.
The server will close all the incoming connections after sending the first response to client if this option is set to true.
func WithMaxRequestsPerConn ¶
Maximum number of requests served per connection.
The server closes connection after the last request. 'Connection: close' header is added to the last response.
func WithReadBufferSize ¶
Per-connection buffer size for requests' reading. This also limits the maximum header size.
Increase this buffer if your clients send multi-KB RequestURIs and/or multi-KB headers (for example, BIG cookies).
func WithReadTimeout ¶
ReadTimeout is the amount of time allowed to read the full request including body. The connection's read deadline is reset when the connection opens, or for keep-alive connections after the first byte has been read.
func WithTCPKeepalive ¶
Whether to enable tcp keep-alive connections.
Whether the operating system should send tcp keep-alive messages on the tcp connection.
func WithWriteBufferSize ¶
Per-connection buffer size for responses writing.
func WithWriteTimeout ¶
WriteTimeout is the maximum duration before timing out writes of the response. It is reset after the request handler has returned.