NeoGraph 0.16.0
A C++20 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
conn_pool.h
Go to the documentation of this file.
1
30#pragma once
31
33
34#include <asio/any_io_executor.hpp>
35#include <asio/awaitable.hpp>
36
37#include <chrono>
38#include <cstddef>
39#include <memory>
40#include <string>
41#include <string_view>
42#include <utility>
43#include <vector>
44
45namespace neograph::async {
46
47struct ConnPoolOptions {
51 std::size_t max_idle_per_host = 16;
52
56 std::chrono::seconds idle_ttl{30};
57
62 std::size_t max_in_flight_per_host = 0;
63};
64
65class NEOGRAPH_API ConnPool {
66public:
67 explicit ConnPool(asio::any_io_executor ex,
68 ConnPoolOptions opts = {});
69 ~ConnPool();
70
71 ConnPool(const ConnPool&) = delete;
72 ConnPool& operator=(const ConnPool&) = delete;
73
83 asio::awaitable<HttpResponse> async_post(
84 std::string_view host,
85 std::string_view port,
86 std::string_view path,
87 std::string_view body,
88 std::vector<std::pair<std::string, std::string>> headers = {},
89 bool tls = false,
90 RequestOptions opts = {});
91
93 std::size_t idle_count() const;
94
95private:
96 struct Impl;
97 std::shared_ptr<Impl> impl_;
98
99 static asio::awaitable<HttpResponse> async_post_owned(
100 std::shared_ptr<Impl> impl,
101 std::string host,
102 std::string port,
103 std::string path,
104 std::string body,
105 std::vector<std::pair<std::string, std::string>> headers,
106 bool tls,
107 RequestOptions opts);
108};
109
110} // namespace neograph::async
Minimal async HTTP/1.1 POST client on asio coroutines.
NEOGRAPH_API asio::awaitable< HttpResponse > async_post(asio::any_io_executor ex, std::string_view host, std::string_view port, std::string_view path, std::string_view body, std::vector< std::pair< std::string, std::string > > headers={}, bool tls=false, RequestOptions opts={})
Async HTTP(S) POST.