Handles multiple asynchronous HTTP requests using libcurl's multi interface.
More...
#include <HttpBatchRequestHandler.hpp>
|
| | HttpBatchRequestHandler (std::vector< std::unique_ptr< HttpRequestContext > > &context_list) |
| | Constructs a handler for managing multiple HTTP requests asynchronously.
|
| | ~HttpBatchRequestHandler () |
| | Cleans up the multi handle and removes all request handles.
|
| bool | process () |
| | Processes the requests within the handler.
|
| std::list< std::unique_ptr< HttpRequestContext > > | extract_failed_requests () |
| | Extracts the list of failed requests.
|
| bool | has_group_id (uint64_t group_id) const |
| | Checks whether this batch contains a request from the specified group.
|
| std::size_t | group_request_count (uint64_t group_id) const |
| | Counts active requests from the specified group.
|
| void | cancel_request_by_id (const std::unordered_map< uint64_t, std::list< std::function< void()> > > &to_cancel) |
| | Cancels HTTP requests based on their unique IDs.
|
| void | cancel_requests (const std::unordered_map< uint64_t, std::list< std::function< void()> > > &requests_to_cancel, const std::unordered_map< uint64_t, std::list< std::function< void()> > > &groups_to_cancel) |
| | Cancels HTTP requests based on their request or group IDs.
|
Handles multiple asynchronous HTTP requests using libcurl's multi interface.
Definition at line 12 of file HttpBatchRequestHandler.hpp.
◆ HttpBatchRequestHandler()
| kurlyk::HttpBatchRequestHandler::HttpBatchRequestHandler |
( |
std::vector< std::unique_ptr< HttpRequestContext > > & | context_list | ) |
|
|
inlineexplicit |
◆ ~HttpBatchRequestHandler()
| kurlyk::HttpBatchRequestHandler::~HttpBatchRequestHandler |
( |
| ) |
|
|
inline |
◆ cancel_request_by_id()
| void kurlyk::HttpBatchRequestHandler::cancel_request_by_id |
( |
const std::unordered_map< uint64_t, std::list< std::function< void()> > > & | to_cancel | ) |
|
|
inline |
Cancels HTTP requests based on their unique IDs.
- Parameters
-
| to_cancel | A map of request IDs to their corresponding cancellation callbacks. |
Definition at line 153 of file HttpBatchRequestHandler.hpp.
◆ cancel_requests()
| void kurlyk::HttpBatchRequestHandler::cancel_requests |
( |
const std::unordered_map< uint64_t, std::list< std::function< void()> > > & | requests_to_cancel, |
|
|
const std::unordered_map< uint64_t, std::list< std::function< void()> > > & | groups_to_cancel ) |
|
inline |
Cancels HTTP requests based on their request or group IDs.
- Parameters
-
| requests_to_cancel | A map of request IDs to their corresponding cancellation callbacks. |
| groups_to_cancel | A map of group IDs to their corresponding cancellation callbacks. |
Definition at line 160 of file HttpBatchRequestHandler.hpp.
◆ extract_failed_requests()
| std::list< std::unique_ptr< HttpRequestContext > > kurlyk::HttpBatchRequestHandler::extract_failed_requests |
( |
| ) |
|
|
inline |
◆ group_request_count()
| std::size_t kurlyk::HttpBatchRequestHandler::group_request_count |
( |
uint64_t | group_id | ) |
const |
|
inline |
Counts active requests from the specified group.
- Parameters
-
| group_id | Group ID to inspect. |
- Returns
- Number of active requests belonging to this group.
Definition at line 139 of file HttpBatchRequestHandler.hpp.
◆ handle_completed_request()
| void kurlyk::HttpBatchRequestHandler::handle_completed_request |
( |
CURLMsg * | message | ) |
|
|
inlineprivate |
Handles the completion of a single request.
- Parameters
-
| message | CURLMsg structure containing the result of the completed request. |
Definition at line 187 of file HttpBatchRequestHandler.hpp.
◆ has_group_id()
| bool kurlyk::HttpBatchRequestHandler::has_group_id |
( |
uint64_t | group_id | ) |
const |
|
inline |
Checks whether this batch contains a request from the specified group.
- Parameters
-
| group_id | Group ID to inspect. |
- Returns
- True if at least one active request belongs to this group.
Definition at line 132 of file HttpBatchRequestHandler.hpp.
◆ process()
| bool kurlyk::HttpBatchRequestHandler::process |
( |
| ) |
|
|
inline |
Processes the requests within the handler.
- Returns
- True if all requests are completed, false otherwise.
Definition at line 86 of file HttpBatchRequestHandler.hpp.
◆ m_failed_requests
| std::list<std::unique_ptr<HttpRequestContext> > kurlyk::HttpBatchRequestHandler::m_failed_requests |
|
private |
◆ m_handlers
| std::vector<std::unique_ptr<HttpRequestHandler> > kurlyk::HttpBatchRequestHandler::m_handlers |
|
private |
◆ m_multi_handle
| CURLM* kurlyk::HttpBatchRequestHandler::m_multi_handle = nullptr |
|
private |
The documentation for this class was generated from the following file: