settings

package
v1.4.0-beta Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2022 License: MIT Imports: 1 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 {
	// Length is responsible for body length parameters.
	// Default value is unused.
	// Maximal value is a maximal length of body
	Length BodyLength
	// BodyChunkSize is responsible for chunks in chunked transfer encoding mode.
	// Default value is unused because chunked body parser calls callback with
	// data taken from input stream.
	// Maximal value is a maximal length of chunk
	ChunkSize BodyChunkSize
}

type BodyChunkSize

type BodyChunkSize Setting[uint32]

type BodyLength

type BodyLength Setting[uint32]

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
	// KeyLength is responsible for header key length.
	// Maximal value is a maximal length of header key
	KeyLength HeadersKeyLength
	// 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
	// ValuesObjectPoolSize is responsible for a queue size in object pool of string
	// slices.
	// Maximal value is a queue size of the object pool queue size.
	ValuesObjectPoolSize HeadersValuesObjectPoolSize
}

type HeadersKeyLength

type HeadersKeyLength Setting[uint8]

type HeadersNumber

type HeadersNumber Setting[uint8]

type HeadersValuesObjectPoolSize

type HeadersValuesObjectPoolSize Setting[uint16]

type HeadersValuesSpace

type HeadersValuesSpace Setting[uint32]

type Query

type Query struct {
	// Length is responsible for a maximal length of url query may be
	// received.
	// Default value is unused
	Length QueryLength
	// Number is responsible for an initial capacity of query entries map.
	// Maximal value is unused because:
	//   Maximal number of entries equals to 65535 (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)
	Number QueryNumber
}

Query is responsible for url query settings.

type QueryLength

type QueryLength Setting[uint16]

type QueryNumber

type QueryNumber Setting[uint16]

type ResponseBuff

type ResponseBuff Setting[uint32]

ResponseBuff is responsible for a response buffer. Default value is a size of buffer allocated once a client connects.

type Setting

type Setting[T number] struct {
	Default T // soft limit
	Maximal T // hard limit
}

type Settings

type Settings struct {
	Headers      Headers
	URL          URL
	TCPServer    TCPServer
	Body         Body
	ResponseBuff ResponseBuff
}

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 TCPServer

type TCPServer struct {
	// Read is responsible for tcp server reading buffer settings.
	// Default value is a size of buffer for reading from socket, also
	// we can call this setting as a "how many bytes are read from
	// socket at most"
	Read TCPServerRead
	// IDLEConnLifetime is a timer in seconds, after expiration of which one IDLE
	// connection will be actively closed by server.
	// IDLE conn is a connection that does not send anything
	// -1 as value disables timeouts at all
	IDLEConnLifetime int
}

type TCPServerRead

type TCPServerRead Setting[uint16]

type URL

type URL struct {
	// Length is responsible for info line buffer.
	// Maximal is a size for buffer that'll be allocated once and will be kept
	// until client disconnect
	Length URLLength
	Query  Query
}

type URLLength

type URLLength Setting[uint16]

Jump to

Keyboard shortcuts

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