Skip to content

Commit 0965b52

Browse files
committed
UPD | adds SSL support in postgresql extension, reworks the smart pointer logics in workers
1 parent 2127f4b commit 0965b52

75 files changed

Lines changed: 542 additions & 468 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ else ()
173173
# include finders
174174
# include(./cmake/FindLibev.cmake)
175175

176+
if (MANAPIHTTP_BUILD_TYPE STREQUAL "exe")
177+
find_package(PostgreSQL)
178+
endif()
179+
176180
if (MANAPIHTTP_DEPENDENCY_FETCH)
177181
pkg_check_modules(LIBUV REQUIRED IMPORTED_TARGET libuv)
178182
else ()
@@ -973,7 +977,7 @@ if (MANAPIHTTP_BUILD_METHOD STREQUAL "conan")
973977
target_link_libraries (${PROJECT_NAME} PUBLIC uv)
974978

975979
if (MANAPIHTTP_BUILD_TYPE STREQUAL "exe")
976-
target_link_libraries(${PROJECT_NAME} PUBLIC PostgreSQL::PostgreSQL)
980+
target_link_libraries(${PROJECT_NAME} PUBLIC libpq::libpq)
977981
endif ()
978982

979983
if (MANAPIHTTP_CPPTRACE_DEPENDENCY)
@@ -1036,6 +1040,12 @@ else ()
10361040
target_link_libraries (${PROJECT_NAME} PUBLIC ${LIBUV_LIBRARIES})
10371041
target_include_directories (${PROJECT_NAME} PUBLIC ${LIBUV_INCLUDE_DIRS})
10381042

1043+
if (MANAPIHTTP_BUILD_TYPE STREQUAL "exe")
1044+
message(STATUS "libpq: libs=${PostgreSQL_LIBRARIES} include=${PostgreSQL_INCLUDE_DIRS}")
1045+
target_link_libraries(${PROJECT_NAME} PUBLIC ${PostgreSQL_LIBRARIES})
1046+
target_include_directories(${PROJECT_NAME} PUBLIC ${PostgreSQL_INCLUDE_DIRS})
1047+
endif()
1048+
10391049
if (MANAPIHTTP_GMP_DEPENDENCY)
10401050
message(STATUS "gmp: libs=${GMP_LIBRARIES} include=${GMP_INCLUDE_DIRS}")
10411051
target_link_libraries(${PROJECT_NAME} PUBLIC ${GMP_LIBRARIES})

conanfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def generate(self):
140140
deps.generate()
141141

142142
def validate(self):
143-
check_min_cppstd(self, 17)
143+
pass
144144

145145
def build(self):
146146
cmake = CMake(self)

include/ManapiAsync.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,11 @@ namespace manapi {
173173
this->resume_promise(this->handle_);
174174
}
175175

176-
[[nodiscard]] bool operator==(const std::nullptr_t &n) const {
176+
MANAPIHTTP_NODISCARD bool operator==(const std::nullptr_t &n) const {
177177
return this->handle_ == nullptr;
178178
}
179179

180-
[[nodiscard]] bool operator!=(const std::nullptr_t &n) const {
180+
MANAPIHTTP_NODISCARD bool operator!=(const std::nullptr_t &n) const {
181181
return false == this->operator==(std::forward<decltype(n)>(n));
182182
}
183183

@@ -268,11 +268,11 @@ namespace manapi {
268268
}
269269
}
270270

271-
[[nodiscard]] bool finished () const {
271+
MANAPIHTTP_NODISCARD bool finished () const {
272272
return !this->handle_ || this->handle_.done();
273273
}
274274

275-
[[nodiscard]] const std::coroutine_handle<promise> &handle () {
275+
MANAPIHTTP_NODISCARD const std::coroutine_handle<promise> &handle () {
276276
return this->handle_;
277277
}
278278

include/ManapiBigint.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,19 @@ namespace manapi {
7171
* Stringify the bigint and return it
7272
* @return the stringified bigint
7373
*/
74-
[[nodiscard]] std::string stringify () const;
74+
MANAPIHTTP_NODISCARD std::string stringify () const;
7575

7676
/**
7777
* Integerify the bigint and return it with data loss
7878
* @return the integerified bigint
7979
*/
80-
[[nodiscard]] ssize_t integerify () const;
80+
MANAPIHTTP_NODISCARD ssize_t integerify () const;
8181

8282
/**
8383
* Decimalify the bigint and return it with data loss
8484
* @return the decimalify bigint
8585
*/
86-
[[nodiscard]] double decimalify () const;
86+
MANAPIHTTP_NODISCARD double decimalify () const;
8787

8888
/**
8989
* Get a bigint from the source string
@@ -120,7 +120,7 @@ namespace manapi {
120120
* Get the precision
121121
* @return the precision
122122
*/
123-
[[nodiscard]] size_t precision () const;
123+
MANAPIHTTP_NODISCARD size_t precision () const;
124124

125125
bigint operator/ (const bigint &oth) const;
126126

@@ -149,14 +149,14 @@ namespace manapi {
149149
* @param oth the power
150150
* @return the result
151151
*/
152-
[[nodiscard]] bigint root (ssize_t oth) const;
152+
MANAPIHTTP_NODISCARD bigint root (ssize_t oth) const;
153153

154154
/**
155155
* Do sqrt operation with bigint
156156
* @param oth the power
157157
* @return the result
158158
*/
159-
[[nodiscard]] bigint sqrt (ssize_t oth) const;
159+
MANAPIHTTP_NODISCARD bigint sqrt (ssize_t oth) const;
160160

161161
bigint operator+ (ssize_t oth) const;
162162

include/ManapiEventLoop.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ namespace manapi {
273273

274274
void stop_watcher (std::shared_ptr<ev::tcp> s) MANAPIHTTP_NOEXCEPT;
275275

276-
[[nodiscard]] const std::shared_ptr<threadpool> &taskpool () const MANAPIHTTP_NOEXCEPT;
276+
MANAPIHTTP_NODISCARD const std::shared_ptr<threadpool> &taskpool () const MANAPIHTTP_NOEXCEPT;
277277
#if MANAPIHTTP_CURL_DEPENDENCY
278278
manapi::error::status watch_curl (void *shared_curl, std::move_only_function<void(int result)> cb) MANAPIHTTP_NOEXCEPT;
279279

include/ManapiEventStructures.hpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,14 @@ namespace manapi::ev {
399399
};
400400

401401
struct chars_deleter {
402-
void operator()(char *data);
402+
void operator()(const char *data);
403+
};
404+
405+
template<typename T>
406+
struct impl_array_deleter {
407+
void operator () (const T *data) {
408+
delete[] data;
409+
}
403410
};
404411

405412
/**
@@ -1037,19 +1044,19 @@ namespace manapi::sys_error {
10371044
* Get the system code error
10381045
* @return the system code error
10391046
*/
1040-
[[nodiscard]] int syserr () const;
1047+
MANAPIHTTP_NODISCARD int syserr () const;
10411048

10421049
/**
10431050
* Get the system name error
10441051
* @return the system name error
10451052
*/
1046-
[[nodiscard]] std::string_view sysname () const;
1053+
MANAPIHTTP_NODISCARD std::string_view sysname () const;
10471054

10481055
/**
10491056
* Get the system msg error
10501057
* @return the system msg error
10511058
*/
1052-
[[nodiscard]] std::string_view sysmsg () const;
1059+
MANAPIHTTP_NODISCARD std::string_view sysmsg () const;
10531060
private:
10541061
/* the system error code */
10551062
int syserr_;
@@ -1076,23 +1083,23 @@ namespace manapi::sys_error {
10761083
* Get the system code error
10771084
* @return the system code error
10781085
*/
1079-
[[nodiscard]] int syserr () const {
1086+
MANAPIHTTP_NODISCARD int syserr () const {
10801087
return this->err_.syserr();
10811088
}
10821089

10831090
/**
10841091
* Get the system name error
10851092
* @return the system name error
10861093
*/
1087-
[[nodiscard]] std::string_view sysname () const {
1094+
MANAPIHTTP_NODISCARD std::string_view sysname () const {
10881095
return this->err_.sysname();
10891096
}
10901097

10911098
/**
10921099
* Get the system msg error
10931100
* @return the system msg error
10941101
*/
1095-
[[nodiscard]] std::string_view sysmsg () const {
1102+
MANAPIHTTP_NODISCARD std::string_view sysmsg () const {
10961103
return this->err_.sysmsg();
10971104
}
10981105
};

include/ManapiFetch.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ namespace manapi::net {
303303
* Get the current HTTP status code
304304
* @return the HTTP status code
305305
*/
306-
[[nodiscard]] uint16_t status_code () const MANAPIHTTP_NOEXCEPT;
306+
MANAPIHTTP_NODISCARD uint16_t status_code () const MANAPIHTTP_NOEXCEPT;
307307

308308
/**
309309
* Send the request to the server

include/ManapiFetch2.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ namespace manapi::net {
3434

3535
static manapi::future<manapi::error::status_or<fetch2>> fetch (std::string url, manapi::json params, std::optional<http::file_transfer_info> body, async::cancellation_action cancellation = nullptr);
3636

37-
[[nodiscard]] bool ok () const MANAPIHTTP_NOEXCEPT;
37+
MANAPIHTTP_NODISCARD bool ok () const MANAPIHTTP_NOEXCEPT;
3838

39-
[[nodiscard]] uint16_t status () const MANAPIHTTP_NOEXCEPT;
39+
MANAPIHTTP_NODISCARD uint16_t status () const MANAPIHTTP_NOEXCEPT;
4040

4141
std::map<std::string, std::string, std::less<>> headers () MANAPIHTTP_NOEXCEPT;
4242

include/ManapiHttp.hpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ namespace manapi::net::http {
2323
class server : public site {
2424
struct data2_t;
2525

26-
server(server_ctx sctx);
2726
public:
2827
using resp = manapi::net::http::response &;
2928
using req = manapi::net::http::request &;
3029
using uresp = manapi::net::http::uresponse;
3130

3231

32+
server(server_ctx sctx);
3333
/**
3434
* initialize the server with the server ctx
3535
* @param sctx the HTTP server context
@@ -42,10 +42,10 @@ namespace manapi::net::http {
4242
~server() final;
4343

4444
/* move */
45-
server(server &&n) noexcept;
45+
server(server &&n) MANAPIHTTP_NOEXCEPT;
4646

4747
/* move */
48-
server&operator=(server &&n) noexcept;
48+
server&operator=(server &&n) MANAPIHTTP_NOEXCEPT;
4949

5050
/* copy */
5151
server(const server &n);
@@ -108,15 +108,13 @@ namespace manapi::net::http {
108108
*/
109109
manapi::future<error::status> stop ();
110110
private:
111-
std::shared_ptr<data2_t> data2;
112-
113-
static manapi::future<error::status> stop_ (std::shared_ptr<site::data_t> data, std::shared_ptr<data2_t> data2, bool evloop);
111+
static manapi::future<error::status> stop_ (std::shared_ptr<data2_t> data2, bool evloop);
114112

115113
manapi::future<> init_pool_ ();
116114

117115
manapi::error::status pool_ (std::move_only_function<void()> cb) MANAPIHTTP_NOEXCEPT;
118116

119-
static void clean_up (std::shared_ptr<data2_t> data2);
117+
static void clean_up (const std::shared_ptr<data2_t>& data2);
120118

121119
static manapi::future<void> stop_pool (std::shared_ptr<data2_t> data2);
122120
};

include/ManapiMemoryPool.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ namespace manapi {
4747
return !this->operator==(nullptr);
4848
}
4949

50-
[[nodiscard]] operator bool () const noexcept {
50+
MANAPIHTTP_NODISCARD operator bool () const noexcept {
5151
return this->operator!=(nullptr);
5252
}
5353

0 commit comments

Comments
 (0)