]> WPIA git - cassiopeia.git/blob - src/db/mysql.h
5559244bd3f5f6892be597c76a87af2356d2e5a1
[cassiopeia.git] / src / db / mysql.h
1 #pragma once
2
3 #include <string>
4 #include <memory>
5 #include <tuple>
6
7 #include <mysql/mysql.h>
8
9 #include "database.h"
10
11 class MySQLJobProvider : public JobProvider {
12 private:
13     static std::shared_ptr<int> lib_ref;
14
15     std::shared_ptr<MYSQL> conn;
16
17 private:
18     std::shared_ptr<MYSQL> _connect( const std::string& server, const std::string& user, const std::string& password, const std::string& database );
19
20 public:
21     MySQLJobProvider( const std::string& server, const std::string& user, const std::string& password, const std::string& database );
22
23 public:
24     bool connect( const std::string& server, const std::string& user, const std::string& password, const std::string& database );
25     bool disconnect();
26
27     std::string escape_string( const std::string& target );
28
29     std::pair< int, std::shared_ptr<MYSQL_RES> > query( const std::string& query );
30
31 public:
32     std::shared_ptr<Job> fetchJob();
33     void finishJob( std::shared_ptr<Job> job );
34     void failJob( std::shared_ptr<Job> job );
35     std::shared_ptr<TBSCertificate> fetchTBSCert( std::shared_ptr<Job> job );
36     void writeBack( std::shared_ptr<Job> job, std::shared_ptr<SignedCertificate> res );
37     std::pair<std::string, std::string> getRevocationInfo( std::shared_ptr<Job> job );
38     void writeBackRevocation( std::shared_ptr<Job> job, std::string date );
39 };