Skip to content

[#1013] Implement the Database Adapter#1025

Open
marcocapozzoli wants to merge 20 commits intomasterfrom
masc/1013-database-adapter-cpp
Open

[#1013] Implement the Database Adapter#1025
marcocapozzoli wants to merge 20 commits intomasterfrom
masc/1013-database-adapter-cpp

Conversation

@marcocapozzoli
Copy link
Collaborator

This PR adds the initial implementation of the Database Adapter. It introduces the abstract interfaces that define the adapter contract and provides a concrete Postgres-backed adapter implementation.

Resolves #1013

* @tparam ConnT The underlying connection object type (e.g., pqxx::connection).
*/
template <typename ConnT>
class DatabaseWrapper {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eddiebrissow @marcocapozzoli
Please make this class implement commons/processor/Processor.h. Basically it means you need to implement
virtual void setup();
virtual void start();
virtual void stop();

setup() Is supposed to make proper initialization without starting any threads, connections etc. It's OK if it's empty.
start() is supposed to start any resources like threads, connections, file openings etc
stop() is supposed to gracefully stop the use of any resource. Stopping/synching threads, closing connections, closing open files etc.

The idea is that relevant resources like threads, connections etc become Processors as well. You can connect them (by calling add_subprocessor()) so when you setup/start/stop Processors they are setup/started/stopped in the proper order to avoid crashing.
We already have DedicatedThread.h and ThreadPool.h in the Processor package. The former is for when you need to spawn a single thread. The later is for when you want a thread pool of workers.
You may need to add a PostgresDBConnection (which inherits from Processor as well) in your package and probably you'll pass this class as the template argument instead of connection type.

/**
* @brief Closes the connection.
*/
virtual void disconnect() = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method will disappear when you implement Processor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement the Database Adapter in C++

2 participants