settings

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 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 int64
	// MaxChunkSize is responsible for a maximal size of a single chunk being transferred
	// via chunked TE
	MaxChunkSize int64
}

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 int64
}

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 int
	// MaxValueLength is responsible for maximal header value length restriction.
	MaxValueLength int
	// 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 int
}

type HeadersNumber

type HeadersNumber struct {
	Default, Maximal int
}

type HeadersValuesSpace

type HeadersValuesSpace struct {
	Default, Maximal 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 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 int
	// ReadTimeout is a duration after which client will be automatically disconnected
	ReadTimeout 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
	BufferSize URLBufferSize
	Query      Query
	Params     URLParams
}

type URLBufferSize added in v0.8.1

type URLBufferSize struct {
	Default, Maximal int
}

type URLParams added in v0.5.0

type URLParams struct {
	// This option allows user to disable the automatic path params map clearing.
	// May be useful in cases where params keys are being accessed directly only,
	// and nothing tries to get all the map values
	DisableMapClear bool
}

Jump to

Keyboard shortcuts

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