NeoGraph 0.10.0
A C++17 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
conn_pool.h File Reference

Keep-alive HTTP(S) connection pool for async_post. More...

#include <neograph/async/http_client.h>
#include <asio/any_io_executor.hpp>
#include <asio/awaitable.hpp>
#include <chrono>
#include <cstddef>
#include <memory>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
Include dependency graph for conn_pool.h:

Go to the source code of this file.

Detailed Description

Keep-alive HTTP(S) connection pool for async_post.

Stage 3 / Semester 1.2 — follows 1.1 (TLS) with the other half of what makes real LLM/MCP endpoints usable at scale: amortizing the TCP connect + TLS handshake over many requests to the same host.

Semantics:

  • ConnPool::async_post mirrors the free async_post signature in http_client.h. The body, headers, path, and status/body return value behave identically.
  • Under the hood, the pool keys idle connections by (host, port, tls). A request with a matching key picks up an idle connection; otherwise it opens a fresh one.
  • If reusing an idle connection fails mid-exchange (server-side idle timeout race), the pool transparently retries once with a fresh connection so the caller never sees a spurious error.
  • After a successful exchange, the connection returns to the pool unless the server sent Connection: close, in which case it's dropped.

Thread-safety: the pool may be shared across worker threads of one or more io_contexts. Check-out/check-in are serialized by an internal mutex; actual network I/O happens outside the lock.

Definition in file conn_pool.h.