-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementing SQLite based request queue
* the husk * setPath fix * Co-authored-by: ArtursKadikis <[email protected]> * Reworking storage module API and creating implementation for the memory variant (#111) * - polymorphous behavior added - sqlite storge class added - code is building * storage modules integration stable state * - log added * storage unit tests added * unit tests updated * - virtual destructor - sqlite storage tests * files and class names updated * - storage unit tests improved - PR Changes - Code formatting * Log print updated while adding event. * cmakelist file updated * - Abstract methods signatures updated - Stable state * - new methods added - Unit test improved - stable state * - Unit tests add/updated - methods signatures improved - Fixed potential bugs * - logic updated * - Fixed issue with storage moduel - Unit tests * - request remove front code refactored * - Moved to new structure * -Unit tests fixed -Updated logic * memory deallocated * - Pointer to smart pointer * - RQpeekFront would return DataENtry with id = -1 and data = "" - Incremental Id Unit tests added * - make_shard used - peekAll and clearAll * removed logs * storage module unit tests updated * - unit test changes, * - Only unit tests added Note: Code isn't compiling * - unit test comments added - compile errors fixed - All unit tests are doing fine. * Code refactor * PR Changes, * test changes, * - missed requested chagnes * - RQ removed on the basis of id, not ref * Storage module methods documentation added. * request processing is functional * Method comments updated * - fixed unit tests * - fix bug - views test running. * - fixe a potential bug, --------- Co-authored-by: Zahid Zafar <> * View changes added (#113) * views * comments * extracted things (#114) * bits * Co-authored-by: ArtursKadikis <[email protected]> * Adding request queue db variant (#112) * - Request sql calls added * - code compile checks - storage unit tests logic updated * storage tests reworked * - sqlite storage unit tests fixed * - clearSDK - debugEQState - Views tests * - finishing test * - PR Requested changes - raw pointer to smart pointer * Requested changes * - crash tests fixed - sessions tests fixed * - set request queue size - safe check on configuration values - new configuration tests * Request module request threshold unit tests added. * - safety check for storage modules * - unit tests added in the storage module - PR changes - fixed event schema creation * Changelog added SDK Version updated * PR Changes * Update views.cpp * comments and name changes * Co-authored-by: ArtursKadikis <[email protected]> * new vacuum * its a me function --------- Co-authored-by: Zahid Zafar <> Co-authored-by: ArtursK <[email protected]> Co-authored-by: turtledreams <[email protected]> * Update CHANGELOG.md * Update CHANGELOG.md * database --------- Co-authored-by: Zahid Zafar <[email protected]> Co-authored-by: ArtursK <[email protected]>
- Loading branch information
1 parent
e978b57
commit 0d34011
Showing
27 changed files
with
1,908 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
## Build Scripts | ||
|
||
Scripts provided here offers a convenient way to build sample app and the tests at different platforms. | ||
Still SQLite setup must be done separately at the "/vendor/sqlite" directory if SQLite is needed. | ||
Current cmake options set in the script that differs from the default are: | ||
|
||
- COUNTLY_BUILD_SAMPLE = ON | ||
- COUNTLY_BUILD_TESTS = ON | ||
|
||
To change any other options you can manually modify the scripts. | ||
|
||
### Run | ||
|
||
You can run the scripts simply by executing them from the root directory. | ||
|
||
### Flow | ||
|
||
When run the script would: | ||
|
||
- Check if a build folder is present at the root and erase it if it exists | ||
- Run Cmake with mentioned options | ||
- Build countly-sample app | ||
- Build countly-test | ||
|
||
After this point you can just go to the "/build" directory and execute those build files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
if [ "${PWD##*/}" = "build" ] | ||
then | ||
echo "In build folder. Changing directory..." | ||
cd .. | ||
echo "Current directory: $PWD" | ||
else | ||
echo "Not in build folder. Current directory: $PWD" | ||
fi | ||
|
||
echo "Deleting folder and its subfolders..." | ||
rm -rf build | ||
echo "Folder and subfolders deleted." | ||
|
||
cmake -DCOUNTLY_BUILD_SAMPLE=1 -DCOUNTLY_BUILD_TESTS=1 -DCOUNTLY_USE_CUSTOM_SHA256=OFF -DCOUNTLY_USE_SQLITE=OFF -B build . | ||
|
||
cd build | ||
make ./countly-sample | ||
make ./countly-tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@echo off | ||
if /i "%CD:~-5%"=="build" ( | ||
echo In build folder. Changing directory... | ||
cd .. | ||
echo Current directory: %CD% | ||
) else ( | ||
echo Not in build folder. Current directory: %CD% | ||
) | ||
echo Deleting folder and its subfolders... | ||
rmdir /s /q build | ||
echo Folder and subfolders deleted. | ||
cmake -DCOUNTLY_BUILD_SAMPLE=1 -DCOUNTLY_BUILD_TESTS=1 -DCOUNTLY_USE_CUSTOM_SHA256=OFF -DCOUNTLY_USE_SQLITE=OFF -B build . -G "Unix Makefiles" | ||
cd build | ||
make ./countly-sample | ||
make ./countly-tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#ifndef STORAGE_MODULE_BASE_HPP_ | ||
#define STORAGE_MODULE_BASE_HPP_ | ||
#include "countly/countly_configuration.hpp" | ||
#include "countly/logger_module.hpp" | ||
#include <string> | ||
#include <vector> | ||
|
||
namespace cly { | ||
|
||
class DataEntry { | ||
private: | ||
long long _id; | ||
std::string _data; | ||
|
||
public: | ||
DataEntry(const long long id, const std::string &data) { | ||
this->_id = id; | ||
this->_data = data; | ||
} | ||
|
||
~DataEntry() {} | ||
|
||
/** | ||
* @return id of data entry | ||
*/ | ||
long long getId() const { return _id; } | ||
|
||
/** | ||
* @return content of data entry | ||
*/ | ||
const std::string &getData() const { return _data; } | ||
}; | ||
|
||
class StorageModuleBase { | ||
protected: | ||
bool _is_initialized = false; | ||
std::shared_ptr<CountlyConfiguration> _configuration; | ||
std::shared_ptr<LoggerModule> _logger; | ||
|
||
public: | ||
StorageModuleBase(std::shared_ptr<CountlyConfiguration> config, std::shared_ptr<LoggerModule> logger) { | ||
this->_configuration = config; | ||
this->_logger = logger; | ||
} | ||
|
||
bool isInitialized() { return _is_initialized; } | ||
|
||
virtual ~StorageModuleBase() { | ||
_logger.reset(); | ||
_configuration.reset(); | ||
} | ||
|
||
/** | ||
* Initialize the storage module. | ||
*/ | ||
virtual void init() = 0; | ||
|
||
/** | ||
* Returns the count of stored requests. | ||
* @return count of stored requests | ||
*/ | ||
virtual long long RQCount() = 0; | ||
|
||
/** | ||
* Delete all stored requests. | ||
*/ | ||
virtual void RQClearAll() = 0; | ||
|
||
/** | ||
* Remove front request from the request queue. | ||
*/ | ||
virtual void RQRemoveFront() = 0; | ||
|
||
/** | ||
* Retrieve the element at the front of the queue. It does not deletes the element in the queue. | ||
* @return front request of the queue. | ||
*/ | ||
const virtual std::shared_ptr<DataEntry> RQPeekFront() = 0; | ||
|
||
/** | ||
* Retrieve all requests in the request queue without removing them. | ||
* @return a vector of requests. | ||
*/ | ||
virtual std::vector<std::shared_ptr<DataEntry>> RQPeekAll() = 0; | ||
|
||
/** | ||
* Remove the front request from the request queue if provided request's id and front request's id do match. | ||
* @param request: a shared pointer to front request | ||
*/ | ||
virtual void RQRemoveFront(std::shared_ptr<DataEntry> request) = 0; | ||
|
||
/** | ||
* Insert element into the request queue at the end. | ||
* @param request: content of the request | ||
*/ | ||
virtual void RQInsertAtEnd(const std::string &request) = 0; | ||
}; | ||
|
||
} // namespace cly | ||
|
||
#endif |
Oops, something went wrong.