Documentation
¶
Index ¶
- Variables
- func Close()
- func CurrentDialer() *fastdialer.Dialer
- func GlobalGuardBytesBufferAlloc() error
- func GlobalRestoreBytesBufferAlloc()
- func GuardThreadsOrDefault(current int) int
- func Init(options *types.Options) error
- func IsLowOnMemory() bool
- func NewDialer(options *types.Options) (*fastdialer.Dialer, error)
- func StartActiveMemGuardian(ctx context.Context)
- func StopActiveMemGuardian()
Constants ¶
This section is empty.
Variables ¶
var ( MaxThreadsOnLowMemory = env.GetEnvOrDefault("MEMGUARDIAN_THREADS", 30) MaxBytesBufferAllocOnLowMemory = env.GetEnvOrDefault("MEMGUARDIAN_ALLOC", 200) )
var Dialer *fastdialer.Dialer
Dialer is a shared fastdialer instance for host DNS resolution. Prefer CurrentDialer() for reads; the variable is exported for backward compatibility but is mutated under mu.
Functions ¶
func Close ¶
func Close()
Close releases one reference to the global shared fastdialer. The dialer is closed and reset to nil only when the final reference is released, allowing a later Init() to re-create it. Extra Close() calls (more than Init()) are ignored rather than tearing down a dialer still in use.
func CurrentDialer ¶
func CurrentDialer() *fastdialer.Dialer
CurrentDialer returns the shared dialer (nil if not initialized), read under the lock so it doesn't race with Init/Close.
func GlobalGuardBytesBufferAlloc ¶
func GlobalGuardBytesBufferAlloc() error
GlobalGuardBytesBufferAlloc reduces buffer pool size when memory is low
func GlobalRestoreBytesBufferAlloc ¶
func GlobalRestoreBytesBufferAlloc()
GlobalRestoreBytesBufferAlloc restores buffer pool size when memory is normal
func GuardThreadsOrDefault ¶
GuardThreadsOrDefault returns reduced thread count when memory is low
func Init ¶
Init creates the global Dialer instance based on user configuration, or reuses the existing one, and registers one reference. Every successful Init must be paired with exactly one Close.
func IsLowOnMemory ¶
func IsLowOnMemory() bool
func NewDialer ¶
func NewDialer(options *types.Options) (*fastdialer.Dialer, error)
NewDialer creates a new fastdialer instance based on user configuration.
func StartActiveMemGuardian ¶
func StopActiveMemGuardian ¶
func StopActiveMemGuardian()
Types ¶
This section is empty.