Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3746302
D3914.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D3914.diff
View Options
diff --git a/services/tunnelbroker/src/Service/TunnelbrokerServiceImpl.cpp b/services/tunnelbroker/src/Service/TunnelbrokerServiceImpl.cpp
--- a/services/tunnelbroker/src/Service/TunnelbrokerServiceImpl.cpp
+++ b/services/tunnelbroker/src/Service/TunnelbrokerServiceImpl.cpp
@@ -217,26 +217,26 @@
DeliveryBroker::getInstance().erase(clientDeviceID);
}
tunnelbroker::GetResponse response;
+ auto respondToWriter =
+ [&writer, &response](std::string fromDeviceID, std::string payload) {
+ response.set_fromdeviceid(fromDeviceID);
+ response.set_payload(payload);
+ if (!writer->Write(response)) {
+ throw std::runtime_error(
+ "gRPC: 'Get' writer error on sending data to the client");
+ }
+ response.Clear();
+ };
for (auto &messageFromDatabase : messagesFromDatabase) {
- response.set_fromdeviceid(messageFromDatabase->getFromDeviceID());
- response.set_payload(messageFromDatabase->getPayload());
- if (!writer->Write(response)) {
- throw std::runtime_error(
- "gRPC: 'Get' writer error on sending data to the client");
- }
- response.Clear();
+ respondToWriter(
+ messageFromDatabase->getFromDeviceID(),
+ messageFromDatabase->getPayload());
database::DatabaseManager::getInstance().removeMessageItem(
messageFromDatabase->getMessageID());
}
while (1) {
messageToDeliver = DeliveryBroker::getInstance().pop(clientDeviceID);
- response.set_fromdeviceid(messageToDeliver.fromDeviceID);
- response.set_payload(messageToDeliver.payload);
- if (!writer->Write(response)) {
- throw std::runtime_error(
- "gRPC: 'Get' writer error on sending data to the client");
- }
- response.Clear();
+ respondToWriter(messageToDeliver.fromDeviceID, messageToDeliver.payload);
comm::network::AmqpManager::getInstance().ack(
messageToDeliver.deliveryTag);
database::DatabaseManager::getInstance().removeMessageItem(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 10, 6:13 PM (17 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2853155
Default Alt Text
D3914.diff (2 KB)
Attached To
Mode
D3914: [services] Tunnelbroker - Wrap gRPC Get message response into a function in Tunnelbroker
Attached
Detach File
Event Timeline
Log In to Comment