Skip to content

HostManager

The HostManager class provides centralized management for HostVariant objects associated with HTTP requests and connections.

Remarks:

The HostManager class acts as a central registry for managing HostVariant objects, each associated with a unique HostKey. It facilitates the creation, retrieval, and management of HostVariant instances based on HTTP requests and connections.

A HostVariant represents a specific host and port combination (e.g., "http://example.com:80" or "https://example.com:443") and manages the connections and request queues for that host. The class ensures that a single HostVariant instance is used for each unique host, helping optimize resource usage and connection pooling.

Key features of the HostManager class include:

  • Creation and Retrieval: The class allows you to create and retrieve HostVariant instances based on HTTP requests, connections, or HostKey. It ensures that a single HostVariant is used for each unique host.
  • Queue Management: The HostManager manages the queue of pending requests for each HostVariant, ensuring efficient request processing.
  • Connection Management: The class handles the management of connections associated with HostVariant objects, including recycling idle connections, removing idle connections, and shutting down connections when needed.

Usage of the HostManager class is typically transparent to developers and is handled internally by the Best HTTP library. However, it provides a convenient and efficient way to manage connections and requests when needed.

Methods:

HostVariant HostManager.GetHostVariant(HTTPRequest)

Gets the HostVariant associated with an HTTP request.

HostVariant HostManager.GetHostVariant(HostKey)

Gets the HostVariant associated with a HostKey.

Void HostManager.RemoveAllIdleConnections()

Removes all idle connections for all hosts.

Void HostManager.TryToSendQueuedRequests()

Tries to send queued requests for all hosts.

Void HostManager.Shutdown()

Shuts down all connections for all hosts.

Void HostManager.Clear()

Clears all hosts and their associated variants.

Comments