Mercurial > hg > orthanc-databases
annotate Framework/PostgreSQL/PostgreSQLParameters.h @ 370:d2b5d9c92214 pg-transactions
PG: test feature: configurable transaction isolation level
author | Alain Mazy <am@osimis.io> |
---|---|
date | Wed, 22 Feb 2023 16:52:04 +0100 |
parents | 16aac0287485 |
children | 15bfd9a76f8d |
rev | line source |
---|---|
0 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
359
16aac0287485
copyright upgraded to 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
16aac0287485
copyright upgraded to 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
0 | 7 * |
8 * This program is free software: you can redistribute it and/or | |
9 * modify it under the terms of the GNU Affero General Public License | |
10 * as published by the Free Software Foundation, either version 3 of | |
11 * the License, or (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 * Affero General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU Affero General Public License | |
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 **/ | |
21 | |
22 | |
23 #pragma once | |
24 | |
25 #if ORTHANC_ENABLE_POSTGRESQL != 1 | |
26 # error PostgreSQL support must be enabled to use this file | |
27 #endif | |
28 | |
152 | 29 #include "../../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" |
0 | 30 |
31 namespace OrthancDatabases | |
32 { | |
33 class PostgreSQLParameters | |
34 { | |
35 private: | |
36 std::string host_; | |
37 uint16_t port_; | |
38 std::string username_; | |
39 std::string password_; | |
40 std::string database_; | |
41 std::string uri_; | |
80
16df1a6ea452
Fix issue 105 (Unable to connect to PostgreSQL database using SSL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
42 bool ssl_; |
0 | 43 bool lock_; |
141
0b3e9ee53c46
Added 'MaximumConnectionRetries' & 'ConnectionRetryInterval' to configure the retries when connecting to the DB at startup
Alain Mazy <alain@mazy.be>
parents:
140
diff
changeset
|
44 unsigned int maxConnectionRetries_; |
0b3e9ee53c46
Added 'MaximumConnectionRetries' & 'ConnectionRetryInterval' to configure the retries when connecting to the DB at startup
Alain Mazy <alain@mazy.be>
parents:
140
diff
changeset
|
45 unsigned int connectionRetryInterval_; |
370
d2b5d9c92214
PG: test feature: configurable transaction isolation level
Alain Mazy <am@osimis.io>
parents:
359
diff
changeset
|
46 std::string readWriteTransactionStatement_; |
d2b5d9c92214
PG: test feature: configurable transaction isolation level
Alain Mazy <am@osimis.io>
parents:
359
diff
changeset
|
47 std::string readOnlyTransactionStatement_; |
0 | 48 |
49 void Reset(); | |
50 | |
51 public: | |
52 PostgreSQLParameters(); | |
53 | |
186 | 54 explicit PostgreSQLParameters(const OrthancPlugins::OrthancConfiguration& configuration); |
0 | 55 |
56 void SetConnectionUri(const std::string& uri); | |
57 | |
58 std::string GetConnectionUri() const; | |
59 | |
60 void SetHost(const std::string& host); | |
61 | |
62 const std::string& GetHost() const | |
63 { | |
64 return host_; | |
65 } | |
66 | |
67 void SetPortNumber(unsigned int port); | |
68 | |
69 uint16_t GetPortNumber() const | |
70 { | |
71 return port_; | |
72 } | |
73 | |
74 void SetUsername(const std::string& username); | |
75 | |
76 const std::string& GetUsername() const | |
77 { | |
78 return username_; | |
79 } | |
80 | |
81 void SetPassword(const std::string& password); | |
82 | |
83 const std::string& GetPassword() const | |
84 { | |
85 return password_; | |
86 } | |
87 | |
88 void SetDatabase(const std::string& database); | |
89 | |
90 void ResetDatabase() | |
91 { | |
92 SetDatabase(""); | |
93 } | |
94 | |
95 const std::string& GetDatabase() const | |
96 { | |
97 return database_; | |
98 } | |
99 | |
80
16df1a6ea452
Fix issue 105 (Unable to connect to PostgreSQL database using SSL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
100 void SetSsl(bool ssl) |
16df1a6ea452
Fix issue 105 (Unable to connect to PostgreSQL database using SSL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
101 { |
16df1a6ea452
Fix issue 105 (Unable to connect to PostgreSQL database using SSL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
102 ssl_ = ssl; |
16df1a6ea452
Fix issue 105 (Unable to connect to PostgreSQL database using SSL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
103 } |
16df1a6ea452
Fix issue 105 (Unable to connect to PostgreSQL database using SSL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
104 |
16df1a6ea452
Fix issue 105 (Unable to connect to PostgreSQL database using SSL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
105 bool IsSsl() const |
16df1a6ea452
Fix issue 105 (Unable to connect to PostgreSQL database using SSL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
106 { |
16df1a6ea452
Fix issue 105 (Unable to connect to PostgreSQL database using SSL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
107 return ssl_; |
16df1a6ea452
Fix issue 105 (Unable to connect to PostgreSQL database using SSL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
108 } |
16df1a6ea452
Fix issue 105 (Unable to connect to PostgreSQL database using SSL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
109 |
0 | 110 void SetLock(bool lock) |
111 { | |
112 lock_ = lock; | |
113 } | |
114 | |
115 bool HasLock() const | |
116 { | |
117 return lock_; | |
118 } | |
119 | |
141
0b3e9ee53c46
Added 'MaximumConnectionRetries' & 'ConnectionRetryInterval' to configure the retries when connecting to the DB at startup
Alain Mazy <alain@mazy.be>
parents:
140
diff
changeset
|
120 unsigned int GetMaxConnectionRetries() const |
0b3e9ee53c46
Added 'MaximumConnectionRetries' & 'ConnectionRetryInterval' to configure the retries when connecting to the DB at startup
Alain Mazy <alain@mazy.be>
parents:
140
diff
changeset
|
121 { |
0b3e9ee53c46
Added 'MaximumConnectionRetries' & 'ConnectionRetryInterval' to configure the retries when connecting to the DB at startup
Alain Mazy <alain@mazy.be>
parents:
140
diff
changeset
|
122 return maxConnectionRetries_; |
0b3e9ee53c46
Added 'MaximumConnectionRetries' & 'ConnectionRetryInterval' to configure the retries when connecting to the DB at startup
Alain Mazy <alain@mazy.be>
parents:
140
diff
changeset
|
123 } |
0b3e9ee53c46
Added 'MaximumConnectionRetries' & 'ConnectionRetryInterval' to configure the retries when connecting to the DB at startup
Alain Mazy <alain@mazy.be>
parents:
140
diff
changeset
|
124 |
0b3e9ee53c46
Added 'MaximumConnectionRetries' & 'ConnectionRetryInterval' to configure the retries when connecting to the DB at startup
Alain Mazy <alain@mazy.be>
parents:
140
diff
changeset
|
125 unsigned int GetConnectionRetryInterval() const |
0b3e9ee53c46
Added 'MaximumConnectionRetries' & 'ConnectionRetryInterval' to configure the retries when connecting to the DB at startup
Alain Mazy <alain@mazy.be>
parents:
140
diff
changeset
|
126 { |
0b3e9ee53c46
Added 'MaximumConnectionRetries' & 'ConnectionRetryInterval' to configure the retries when connecting to the DB at startup
Alain Mazy <alain@mazy.be>
parents:
140
diff
changeset
|
127 return connectionRetryInterval_; |
0b3e9ee53c46
Added 'MaximumConnectionRetries' & 'ConnectionRetryInterval' to configure the retries when connecting to the DB at startup
Alain Mazy <alain@mazy.be>
parents:
140
diff
changeset
|
128 } |
0b3e9ee53c46
Added 'MaximumConnectionRetries' & 'ConnectionRetryInterval' to configure the retries when connecting to the DB at startup
Alain Mazy <alain@mazy.be>
parents:
140
diff
changeset
|
129 |
370
d2b5d9c92214
PG: test feature: configurable transaction isolation level
Alain Mazy <am@osimis.io>
parents:
359
diff
changeset
|
130 void SetReadWriteTransactionStatement(const std::string& statement) |
d2b5d9c92214
PG: test feature: configurable transaction isolation level
Alain Mazy <am@osimis.io>
parents:
359
diff
changeset
|
131 { |
d2b5d9c92214
PG: test feature: configurable transaction isolation level
Alain Mazy <am@osimis.io>
parents:
359
diff
changeset
|
132 readWriteTransactionStatement_ = statement; |
d2b5d9c92214
PG: test feature: configurable transaction isolation level
Alain Mazy <am@osimis.io>
parents:
359
diff
changeset
|
133 } |
d2b5d9c92214
PG: test feature: configurable transaction isolation level
Alain Mazy <am@osimis.io>
parents:
359
diff
changeset
|
134 |
d2b5d9c92214
PG: test feature: configurable transaction isolation level
Alain Mazy <am@osimis.io>
parents:
359
diff
changeset
|
135 void SetReadOnlyTransactionStatement(const std::string& statement) |
d2b5d9c92214
PG: test feature: configurable transaction isolation level
Alain Mazy <am@osimis.io>
parents:
359
diff
changeset
|
136 { |
d2b5d9c92214
PG: test feature: configurable transaction isolation level
Alain Mazy <am@osimis.io>
parents:
359
diff
changeset
|
137 readOnlyTransactionStatement_ = statement; |
d2b5d9c92214
PG: test feature: configurable transaction isolation level
Alain Mazy <am@osimis.io>
parents:
359
diff
changeset
|
138 } |
d2b5d9c92214
PG: test feature: configurable transaction isolation level
Alain Mazy <am@osimis.io>
parents:
359
diff
changeset
|
139 |
d2b5d9c92214
PG: test feature: configurable transaction isolation level
Alain Mazy <am@osimis.io>
parents:
359
diff
changeset
|
140 const std::string& GetReadWriteTransactionStatement() const |
d2b5d9c92214
PG: test feature: configurable transaction isolation level
Alain Mazy <am@osimis.io>
parents:
359
diff
changeset
|
141 { |
d2b5d9c92214
PG: test feature: configurable transaction isolation level
Alain Mazy <am@osimis.io>
parents:
359
diff
changeset
|
142 return readWriteTransactionStatement_; |
d2b5d9c92214
PG: test feature: configurable transaction isolation level
Alain Mazy <am@osimis.io>
parents:
359
diff
changeset
|
143 } |
d2b5d9c92214
PG: test feature: configurable transaction isolation level
Alain Mazy <am@osimis.io>
parents:
359
diff
changeset
|
144 |
d2b5d9c92214
PG: test feature: configurable transaction isolation level
Alain Mazy <am@osimis.io>
parents:
359
diff
changeset
|
145 const std::string& GetReadOnlyTransactionStatement() const |
d2b5d9c92214
PG: test feature: configurable transaction isolation level
Alain Mazy <am@osimis.io>
parents:
359
diff
changeset
|
146 { |
d2b5d9c92214
PG: test feature: configurable transaction isolation level
Alain Mazy <am@osimis.io>
parents:
359
diff
changeset
|
147 return readOnlyTransactionStatement_; |
d2b5d9c92214
PG: test feature: configurable transaction isolation level
Alain Mazy <am@osimis.io>
parents:
359
diff
changeset
|
148 } |
d2b5d9c92214
PG: test feature: configurable transaction isolation level
Alain Mazy <am@osimis.io>
parents:
359
diff
changeset
|
149 |
0 | 150 void Format(std::string& target) const; |
151 }; | |
152 } |