(cobra client and bots) add batch_size subscription option for retrieving multiple messages at once

This commit is contained in:
Benjamin Sergeant
2020-06-17 17:13:45 -07:00
parent bf0f11fd65
commit 565a08b229
9 changed files with 18 additions and 2 deletions

View File

@ -29,6 +29,7 @@ namespace ix
auto runtime = botConfig.runtime;
auto maxEventsPerMinute = botConfig.maxEventsPerMinute;
auto limitReceivedEvents = botConfig.limitReceivedEvents;
auto batchSize = botConfig.batchSize;
ix::CobraConnection conn;
conn.configure(config);
@ -148,6 +149,7 @@ namespace ix
&receivedCountPerMinutes,
maxEventsPerMinute,
limitReceivedEvents,
batchSize,
&fatalCobraError,
&sentCount](const CobraEventPtr& event) {
if (event->type == ix::CobraEventType::Open)
@ -169,7 +171,7 @@ namespace ix
CoreLogger::info("Subscribing to " + channel);
CoreLogger::info("Subscribing at position " + subscriptionPosition);
CoreLogger::info("Subscribing with filter " + filter);
conn.subscribe(channel, filter, subscriptionPosition,
conn.subscribe(channel, filter, subscriptionPosition, batchSize,
[&sentCount, &receivedCountPerMinutes,
maxEventsPerMinute, limitReceivedEvents,
&throttled, &receivedCount,

View File

@ -27,5 +27,6 @@ namespace ix
int runtime = -1;
int maxEventsPerMinute = std::numeric_limits<int>::max();
bool limitReceivedEvents = false;
int batchSize = 1;
};
} // namespace ix