settings

package
v2.3.1-beta Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Body

type Body struct {
	// MaxSize is responsible for a maximal body size in case it is being transferred
	// using ordinary Content-Length header, otherwise (e.g. chunked TE) this limit,
	// unfortunately, doesn't work
	MaxSize MaxBodySize
	// MaxChunkSize is responsible for a maximal size of a single chunk being transferred
	// via chunked TE
	MaxChunkSize MaxBodyChunkSize
}

type HTTP

type HTTP struct {
	// ResponseBuffSize is responsible for a response buffer that is being allocated when
	// client connects and is used for rendering the response into it
	ResponseBuffSize ResponseBuffSize
}

type Headers

type Headers struct {
	// Number is responsible for headers map size.
	// Default value is an initial size of allocated headers map.
	// Maximal value is maximum number of headers allowed to be presented
	Number HeadersNumber
	// MaxKeyLength is responsible for maximal header key length restriction.
	MaxKeyLength MaxHeaderKeyLength
	// MaxValueLength is responsible for maximal header value length restriction.
	MaxValueLength MaxHeaderValueLength
	// HeadersValuesSpace is responsible for a maximal space in bytes available for
	// keeping header values in memory.
	// Default value is initial space allocated when client connects.
	// Maximal value is a hard limit, reaching which one client triggers server
	// to response with 431 Header Fields Too Large
	ValueSpace HeadersValuesSpace
	// MaxValuesObjectPoolSize is responsible for a maximal size of string slices object
	// pool
	MaxValuesObjectPoolSize HeadersValuesObjectPoolSize
}

type HeadersNumber

type HeadersNumber struct {
	Default, Maximal int
}

type HeadersValuesObjectPoolSize

type HeadersValuesObjectPoolSize = int

type HeadersValuesSpace

type HeadersValuesSpace struct {
	Default, Maximal int
}

type MaxBodyChunkSize

type MaxBodyChunkSize = int

type MaxBodySize

type MaxBodySize int

type MaxHeaderKeyLength

type MaxHeaderKeyLength = int

type MaxHeaderValueLength

type MaxHeaderValueLength = int

type MaxURLLength

type MaxURLLength int

type Query

type Query struct {
	// MaxLength is responsible for a limit of the query length
	MaxLength int
	// DefaultMapSize is responsible for an initial capacity of query entries map.
	// There is no up limit because:
	//   Maximal number of entries equals to 65536 (math.MaxUint16) divided by
	//   3 (minimal length of query entry) that equals to 21,845.
	//   Worst case: sizeof(int) == 64 and sizeof(unsafe.Pointer) == 64. Then
	//   slice type takes 16 bytes
	//   In that case, we can calculate how much memory AT MOST will be used.
	//   24 bytes (slice type - cap, len and pointer 8 bytes each) + 1 byte
	//   (an array of a single char in best case) + 16 bytes (string type - len
	//   and pointer) + 1 byte (an array of single char in best case)
	//   42 bytes in total for each pair, 917490 bytes in total, that is 896 kilobytes
	//   that is 0.87 megabytes. IMHO that is not that much to care about. In case it
	//   is - somebody will open an issue, or even better, implement the limit by himself
	//   (hope he is lucky enough to find out how to handle with my hand-made DI)
	DefaultMapSize int
}

type ResponseBuffSize

type ResponseBuffSize int

type Settings

type Settings struct {
	Headers Headers
	URL     URL
	TCP     TCP
	Body    Body
	HTTP    HTTP
}

func Default

func Default() Settings

func Fill

func Fill(original Settings) (modified Settings)

Fill takes some settings and fills it with default values everywhere where it is not filled

type TCP

type TCP struct {
	// ReadBufferSize is a size of buffer in bytes which will be used to read from
	// socket
	ReadBufferSize TCPReadBuffSize
	// ReadTimeout is a duration after which client will be automatically disconnected
	ReadTimeout TCPReadTimeout
}

type TCPReadBuffSize

type TCPReadBuffSize int

type TCPReadTimeout

type TCPReadTimeout = time.Duration

type URL

type URL struct {
	// MaxLength is a size for buffer that'll be allocated once and will be kept
	// until client disconnect
	MaxLength MaxURLLength
	Query     Query
}

Jump to

Keyboard shortcuts

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