Globals Module

Types and nested modules

Type/Module Description

BufferPool

Dedicated byte ArrayPool isolated from System.Buffers.ArrayPool.Shared. Rationale: ArrayPool.Shared is process-wide and contended by every library running in the host (the BCL itself, ASP.NET if hosted side-by-side, JSON serialisers, gzip streams, …). Under high concurrency, even though Shared has thread-local caches, the cross-bucket fall-through paths take locks that show up in profiles. By renting Suave's per-connection buffers (line buffer, header read buffer, header-name lowercase scratch) from a pool we own, we keep our hot-path rentals out of that shared contention surface entirely. Tuning: ArrayPool.Create defaults are 1MB max length, 50 arrays per bucket. Suave's typical rentals are 8KiB and 256B; the defaults are appropriate.

DateCache

Cached HTTP date string to avoid formatting on every request. HTTP dates only change once per second, so caching provides significant benefit.

DictionaryPool

Dictionary pool for HttpContext userState

StringBuilderPool

StringBuilder pool for dynamic content generation

Logger

Functions and values

Function or value Description

ServerHeader

Full Usage: ServerHeader

Returns: string

This is the server header

Returns: string

SuaveVersion

Full Usage: SuaveVersion

Returns: string

This returns the assembly version of Suave

Returns: string

UTF8

Full Usage: UTF8

Returns: Encoding

Cached UTF8 encoding to avoid allocating new instances

Returns: Encoding

utcNow

Full Usage: utcNow

Returns: unit -> DateTimeOffset

Get the current DateTimeOffset in UTC format. If you are unit-testing you can set this, but as with all globals, you need to set it back afterwards or you will break subsequent unit tests.

Returns: unit -> DateTimeOffset

verbose

Full Usage: verbose

Returns: bool
Returns: bool