|
14 | 14 | #include <functional> |
15 | 15 | #include <memory> |
16 | 16 | #include <mutex> |
| 17 | +#include <queue> |
17 | 18 | #include <string> |
18 | 19 | #include <thread> |
19 | 20 | #include <unordered_map> |
@@ -107,6 +108,17 @@ class TCPTransport { |
107 | 108 | */ |
108 | 109 | bool IsConnected() const; |
109 | 110 |
|
| 111 | + // ---- Inbound (Agent -> Provider calls) ---- |
| 112 | + // Read loop only dispatches; handlers run on a bounded worker pool |
| 113 | + // (default = hardware concurrency, queue = workers * 4, overflow |
| 114 | + // fast-fails with an empty response so Agent failover takes over). |
| 115 | + using InboundHandler = std::function<std::vector<uint8_t>(uint32_t msg_id, uint32_t req_id, const std::vector<uint8_t>& body)>; |
| 116 | + |
| 117 | + void SetInboundHandler(InboundHandler handler); |
| 118 | + void DispatchInbound(uint32_t msg_id, uint32_t req_id, std::vector<uint8_t> body); |
| 119 | + void WriteResponseSilently(uint32_t resp_msg_id, uint32_t req_id, const std::vector<uint8_t>& body); |
| 120 | + static int InboundWorkerCount(); |
| 121 | + |
110 | 122 | /** |
111 | 123 | * Send a request and wait for response. |
112 | 124 | * |
@@ -141,17 +153,6 @@ class TCPTransport { |
141 | 153 | } |
142 | 154 | }; |
143 | 155 |
|
144 | | - // ---- Inbound (Agent -> Provider calls) ---- |
145 | | - // Read loop only dispatches; handlers run on a bounded worker pool |
146 | | - // (default = hardware concurrency, queue = workers * 4, overflow |
147 | | - // fast-fails with an empty response so Agent failover takes over). |
148 | | - using InboundHandler = std::function<std::vector<uint8_t>(uint32_t msg_id, uint32_t req_id, const std::vector<uint8_t>& body)>; |
149 | | - |
150 | | - void SetInboundHandler(InboundHandler handler); |
151 | | - void DispatchInbound(uint32_t msg_id, uint32_t req_id, std::vector<uint8_t> body); |
152 | | - void WriteResponseSilently(uint32_t resp_msg_id, uint32_t req_id, const std::vector<uint8_t>& body); |
153 | | - static int InboundWorkerCount(); |
154 | | - |
155 | 156 | void ReadLoop(); |
156 | 157 | int ReadFully(void* buf, size_t count); |
157 | 158 | static void PutMsgId(uint8_t* buf, uint32_t msg_id); |
|
0 commit comments