Skip to content

Commit 75f8d74

Browse files
authored
Merge pull request #135 from Countly/rq_size
Rq size
2 parents 4165868 + 9326a3b commit 75f8d74

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## XX.XX.XX
2+
- Added "checkRQSize" function to return the current number of requests in the queue.
3+
14
## 23.2.0
25
- Request queue processing now is limited to 100 requests at a time
36
- Added 'setEventsToRQThreshold' method that sets the number of events after which all events will be sent to the RQ. Default value is set to 100.

include/countly.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ class Countly : public cly::CountlyDelegates {
105105
*/
106106
int checkEQSize();
107107

108+
/*
109+
* Checks and returns the size of the request queue in memory or persistent storage.
110+
*/
111+
int checkRQSize();
112+
108113
/**
109114
* Checks and returns the size of the event queue in persistent storage.
110115
*/

include/countly/request_module.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ class RequestModule {
3535
*/
3636
void clearRequestQueue();
3737

38+
long long RQSize();
39+
3840
private:
3941
class RequestModuleImpl;
4042
std::unique_ptr<RequestModuleImpl> impl;

src/countly.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ void Countly::checkAndSendEventToRQ() {
520520

521521
void Countly::setMaxEvents(size_t value) {
522522
log(LogLevel::WARNING, "[Countly][setMaxEvents/SetMaxEventsPerMessage] These calls are deprecated. Use 'setEventsToRQThreshold' instead.");
523-
setEventsToRQThreshold(value);
523+
setEventsToRQThreshold(static_cast<int>(value));
524524
}
525525

526526
void Countly::setEventsToRQThreshold(int value) {
@@ -824,12 +824,24 @@ int Countly::checkEQSize() {
824824
return event_count;
825825
}
826826

827+
int Countly::checkRQSize() {
828+
log(LogLevel::DEBUG, "[Countly][checkRQSize]");
829+
int request_count = -1;
830+
if (!is_sdk_initialized) {
831+
log(LogLevel::DEBUG, "[Countly][checkRQSize] SDK is not initialized.");
832+
return request_count;
833+
}
834+
835+
request_count = static_cast<int>(requestModule->RQSize());
836+
return request_count;
837+
}
838+
827839
#ifndef COUNTLY_USE_SQLITE
828840
int Countly::checkMemoryEQSize() {
829841
log(LogLevel::DEBUG, "[Countly][checkMemoryEQSize] Checking event queue size in memory");
830842
int result = 0;
831843
mutex->lock();
832-
result = event_queue.size();
844+
result = static_cast<int>(event_queue.size());
833845
mutex->unlock();
834846
return result;
835847
}
@@ -1205,4 +1217,4 @@ void Countly::updateRemoteConfigExcept(std::string *keys, size_t key_count) {
12051217
std::thread _thread(&Countly::_updateRemoteConfigWithSpecificValues, this, data);
12061218
_thread.detach();
12071219
}
1208-
} // namespace cly
1220+
} // namespace cly

src/request_module.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,4 +341,5 @@ HTTPResponse RequestModule::sendHTTP(std::string path, std::string data) {
341341
return response;
342342
#endif
343343
}
344+
long long RequestModule::RQSize() { return impl->_storageModule->RQCount(); }
344345
} // namespace cly

0 commit comments

Comments
 (0)