ORE Studio 0.0.4
Loading...
Searching...
No Matches
Public Member Functions | List of all members
pending_request_map Class Referencefinal

Thread-safe map for tracking pending requests by correlation ID. More...

#include <pending_request_map.hpp>

Collaboration diagram for pending_request_map:
Collaboration graph

Public Member Functions

 pending_request_map (boost::asio::any_io_executor executor)
 
std::shared_ptr< response_channelregister_request (std::uint32_t correlation_id)
 Register a new pending request.
 
bool complete (std::uint32_t correlation_id, messaging::frame response)
 Complete a pending request with a response.
 
bool fail (std::uint32_t correlation_id, messaging::error_code ec)
 Fail a specific pending request with an error.
 
void fail_all (messaging::error_code ec)
 Fail all pending requests with an error.
 
void remove (std::uint32_t correlation_id)
 Remove a completed/cancelled request from the map.
 
std::size_t size () const
 Get the number of pending requests.
 
bool empty () const
 Check if there are any pending requests.
 

Detailed Description

Thread-safe map for tracking pending requests by correlation ID.

Used by the client to match incoming responses to their originating requests. When a request is sent, a response_channel is registered with its correlation ID. When a response arrives, the message loop looks up the channel by correlation ID and delivers the response.

Member Function Documentation

◆ register_request()

std::shared_ptr< response_channel > register_request ( std::uint32_t  correlation_id)

Register a new pending request.

Creates a response_channel for the given correlation ID. The caller should co_await the returned channel's get() method.

Parameters
correlation_idThe correlation ID for this request
Returns
Shared pointer to the response channel

◆ complete()

bool complete ( std::uint32_t  correlation_id,
messaging::frame  response 
)

Complete a pending request with a response.

Called by the message loop when a response frame arrives. Delivers the response to the waiting coroutine.

Parameters
correlation_idThe correlation ID from the response
responseThe response frame
Returns
true if a pending request was found and completed

◆ fail()

bool fail ( std::uint32_t  correlation_id,
messaging::error_code  ec 
)

Fail a specific pending request with an error.

Called on timeout for a specific request.

Parameters
correlation_idThe correlation ID to fail
ecThe error code
Returns
true if a pending request was found and failed

◆ fail_all()

void fail_all ( messaging::error_code  ec)

Fail all pending requests with an error.

Called when connection is lost - fails all waiting requests.

Parameters
ecThe error code to deliver to all pending requests

◆ remove()

void remove ( std::uint32_t  correlation_id)

Remove a completed/cancelled request from the map.

Should be called after get() returns to clean up.

Parameters
correlation_idThe correlation ID to remove