Skip to content

Commit cc52ade

Browse files
committed
UPD | ctoken
1 parent e4645c0 commit cc52ade

37 files changed

+403
-399
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ int main () {
188188
auto msg = req.param("id").unwrap();
189189
char *end;
190190
auto res1 = co_await db->execl(manapi::ext::pq::kMaster, "INSERT INTO for_test (id, str_col) VALUES ($2, $1);",
191-
manapi::async::timeout_cancellation(2500), "no way", std::strtoll(msg.data(), &end, 10));
191+
manapi::ctokens::timeout(2500), "no way", std::strtoll(msg.data(), &end, 10));
192192
if (!res1) {
193193
if (res1.sqlcode() != manapi::ext::pq::SQL_STATE_UNIQUE_VIOLATION)
194194
res1.err().log();

handlers.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@
288288
// router.GET ("/chunked", [] (manapi::net::http::request &req, manapi::net::http::response &resp)
289289
// -> manapi::future<> {
290290
// try {
291-
// auto cancellation = manapi::async::cancellation_action::unit(req.cancellation());
291+
// auto cancellation = manapi::ctoken::unit(req.cancellation());
292292
// cancellation.timeout(5000);
293293
// cancellation.ask_cancel_callback();
294294
// auto file = manapi::filesystem::fstream::create ("/home/Timur/Downloads/VideoDownloader/ufa.mp4",
@@ -313,7 +313,7 @@
313313
// auto const res = co_await file.fread(buffs);
314314
// fin = file.eof();
315315
// co_return res;
316-
// }, manapi::async::cancellation_action::unit(cancellation))).unwrap();
316+
// }, manapi::ctoken::unit(cancellation))).unwrap();
317317
//
318318
// co_await file.close();
319319
//
@@ -395,7 +395,7 @@
395395
// auto f = co_await manapi::net::fetch2::fetch("http://127.0.0.1:8889/noise", {
396396
// {"method", "GET"}
397397
// },
398-
// manapi::async::cancellation_action::unit(req.cancellation()));
398+
// manapi::ctoken::unit(req.cancellation()));
399399
// if (!f.ok()) {
400400
// std::string s = "error: ";
401401
// s += f.message();

include/ManapiDns.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ namespace manapi::dns {
2323
* Errors:
2424
* -
2525
*/
26-
manapi::future<int> getaddrinfo (const char * node, const char* service, const addrinfo *hints, addrinfo **res, async::cancellation_action token = nullptr);
26+
manapi::future<int> getaddrinfo (const char * node, const char* service, const addrinfo *hints, addrinfo **res, ctoken token = nullptr);
2727
}

include/ManapiEventLoop.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,31 +203,31 @@ namespace manapi {
203203
* @return
204204
* @throws manapi::exception with ERR_INTERNAL code
205205
*/
206-
manapi::ev::status_or<std::shared_ptr<ev::fs>> create_watcher_fs (ev::fs_cb callback, manapi::async::cancellation_action token = nullptr) MANAPIHTTP_NOEXCEPT;
206+
manapi::ev::status_or<std::shared_ptr<ev::fs>> create_watcher_fs (ev::fs_cb callback, manapi::ctoken token = nullptr) MANAPIHTTP_NOEXCEPT;
207207

208208
/**
209209
*
210210
* @param callback Callback
211211
* @return
212212
* @throws manapi::exception with ERR_INTERNAL code
213213
*/
214-
manapi::ev::status_or<std::shared_ptr<ev::getaddrinfo>> create_watcher_getaddrinfo (const char *node, const char *service, const addrinfo *hints, ev::getaddrinfo_cb callback, manapi::async::cancellation_action token = nullptr) MANAPIHTTP_NOEXCEPT;
214+
manapi::ev::status_or<std::shared_ptr<ev::getaddrinfo>> create_watcher_getaddrinfo (const char *node, const char *service, const addrinfo *hints, ev::getaddrinfo_cb callback, manapi::ctoken token = nullptr) MANAPIHTTP_NOEXCEPT;
215215

216216
/**
217217
*
218218
* @param callback Callback
219219
* @return
220220
* @throws manapi::exception with ERR_INTERNAL code
221221
*/
222-
manapi::ev::status_or<std::shared_ptr<ev::getnameinfo>> create_watcher_getnameinfo (const struct sockaddr *addr, int flags, ev::getnameinfo_cb callback, manapi::async::cancellation_action token = nullptr) MANAPIHTTP_NOEXCEPT;
222+
manapi::ev::status_or<std::shared_ptr<ev::getnameinfo>> create_watcher_getnameinfo (const struct sockaddr *addr, int flags, ev::getnameinfo_cb callback, manapi::ctoken token = nullptr) MANAPIHTTP_NOEXCEPT;
223223

224224
/**
225225
*
226226
* @param callback Callback
227227
* @return
228228
* @throws manapi::exception with ERR_INTERNAL code
229229
*/
230-
manapi::ev::status_or<std::shared_ptr<ev::random>> create_watcher_random (char *buff, std::size_t size, ev::random_cb callback, manapi::async::cancellation_action token = nullptr) MANAPIHTTP_NOEXCEPT;
230+
manapi::ev::status_or<std::shared_ptr<ev::random>> create_watcher_random (char *buff, std::size_t size, ev::random_cb callback, manapi::ctoken token = nullptr) MANAPIHTTP_NOEXCEPT;
231231

232232
/**
233233
*

include/ManapiFetch.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,15 @@ namespace manapi::net {
128128
* @param url the site URL
129129
* @param cancellation the cancellation token
130130
*/
131-
static manapi::status_or<fetch> create (std::string url, manapi::async::cancellation_action cancellation = nullptr) MANAPIHTTP_NOEXCEPT;
131+
static manapi::status_or<fetch> create (std::string url, manapi::ctoken cancellation = nullptr) MANAPIHTTP_NOEXCEPT;
132132

133133
/**
134134
* Initialize Fetch API
135135
*
136136
* @param url the site URL
137137
* @param cancellation the cancellation token
138138
*/
139-
manapi::status init (std::string url, manapi::async::cancellation_action cancellation = nullptr) MANAPIHTTP_NOEXCEPT;
139+
manapi::status init (std::string url, manapi::ctoken cancellation = nullptr) MANAPIHTTP_NOEXCEPT;
140140

141141
/**
142142
* Set the sync callback to recv body from the request

include/ManapiFetch2.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ namespace manapi::net {
2222

2323
fetch2 &operator=(const fetch2 &n);
2424

25-
static manapi::future<manapi::status_or<fetch2>> fetch (std::string url, manapi::json params = manapi::json::object(), async::cancellation_action cancellation = nullptr);
25+
static manapi::future<manapi::status_or<fetch2>> fetch (std::string url, manapi::json params = manapi::json::object(), ctoken cancellation = nullptr);
2626

27-
static manapi::future<manapi::status_or<fetch2>> fetch (std::string url, manapi::json params, std::optional<fetch_formdata> body, async::cancellation_action cancellation = nullptr);
27+
static manapi::future<manapi::status_or<fetch2>> fetch (std::string url, manapi::json params, std::optional<fetch_formdata> body, ctoken cancellation = nullptr);
2828

29-
static manapi::future<manapi::status_or<fetch2>> fetch (std::string url, manapi::json params, std::optional<std::string> body, async::cancellation_action cancellation = nullptr);
29+
static manapi::future<manapi::status_or<fetch2>> fetch (std::string url, manapi::json params, std::optional<std::string> body, ctoken cancellation = nullptr);
3030

31-
static manapi::future<manapi::status_or<fetch2>> fetch (std::string url, manapi::json params, std::optional<std::move_only_function<ssize_t(char *, ssize_t)>> body, async::cancellation_action cancellation = nullptr);
31+
static manapi::future<manapi::status_or<fetch2>> fetch (std::string url, manapi::json params, std::optional<std::move_only_function<ssize_t(char *, ssize_t)>> body, ctoken cancellation = nullptr);
3232

33-
static manapi::future<manapi::status_or<fetch2>> fetch (std::string url, manapi::json params, std::optional<std::move_only_function<manapi::future<ssize_t>(slice_view buffs, bool &fin)>> body, async::cancellation_action cancellation = nullptr);
33+
static manapi::future<manapi::status_or<fetch2>> fetch (std::string url, manapi::json params, std::optional<std::move_only_function<manapi::future<ssize_t>(slice_view buffs, bool &fin)>> body, ctoken cancellation = nullptr);
3434

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

3737
MANAPIHTTP_NODISCARD bool ok () const MANAPIHTTP_NOEXCEPT;
3838

@@ -49,7 +49,7 @@ namespace manapi::net {
4949
manapi::future<manapi::json_error::status_or<manapi::json>> json ();
5050
private:
5151
template<typename T>
52-
static manapi::future<manapi::status_or<fetch2>> fetch_ (std::string url, manapi::json params, T body, async::cancellation_action cancellation = nullptr);
52+
static manapi::future<manapi::status_or<fetch2>> fetch_ (std::string url, manapi::json params, T body, ctoken cancellation = nullptr);
5353

5454
manapi::status setup_send_body (std::string &&data) MANAPIHTTP_NOEXCEPT;
5555

include/compress/ManapiCompress.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,33 @@
77
namespace manapi::compress {
88
#if MANAPIHTTP_ZLIB_DEPENDENCY
99

10-
future<manapi::status> deflate_compress_file(std::string src, std::string dest, int level = 0, int strategy = 0, manapi::async::cancellation_action cancellation = nullptr);
11-
future<manapi::status> deflate_decompress_file(std::string src, std::string dest, manapi::async::cancellation_action cancellation = nullptr);
10+
future<manapi::status> deflate_compress_file(std::string src, std::string dest, int level = 0, int strategy = 0, manapi::ctoken cancellation = nullptr);
11+
future<manapi::status> deflate_decompress_file(std::string src, std::string dest, manapi::ctoken cancellation = nullptr);
1212

1313
manapi::status_or<std::string> deflate_compress_string (std::string_view original, int level = 0, int strategy = 0);
1414
manapi::status_or<std::string> deflate_decompress_string (std::string_view compressed);
1515

1616
manapi::status_or<std::string> gzip_compress_string (std::string_view original, int level = 0, int strategy = 0);
1717
manapi::status_or<std::string> gzip_decompress_string (std::string_view compressed);
1818

19-
future<manapi::status> gzip_compress_file(std::string src, std::string dest, int level = 0, int strategy = 0, manapi::async::cancellation_action cancellation = nullptr);
20-
future<manapi::status> gzip_decompress_file(std::string src, std::string dest, manapi::async::cancellation_action cancellation = nullptr);
19+
future<manapi::status> gzip_compress_file(std::string src, std::string dest, int level = 0, int strategy = 0, manapi::ctoken cancellation = nullptr);
20+
future<manapi::status> gzip_decompress_file(std::string src, std::string dest, manapi::ctoken cancellation = nullptr);
2121
#endif
2222

2323
#ifdef MANAPIHTTP_BROTLI_DEPENDENCY
2424
manapi::status_or<std::string> brotli_decompress_string (std::string_view src);
2525
manapi::status_or<std::string> brotli_compress_string (std::string_view src, int quality, int window, int mode);
2626

27-
future<manapi::status> brotli_compress_file (std::string src, std::string dest, int quality, int window, int mode, manapi::async::cancellation_action cancellation = nullptr);
28-
future<manapi::status> brotli_decompress_file (std::string src, std::string dest, manapi::async::cancellation_action cancellation = nullptr);
27+
future<manapi::status> brotli_compress_file (std::string src, std::string dest, int quality, int window, int mode, manapi::ctoken cancellation = nullptr);
28+
future<manapi::status> brotli_decompress_file (std::string src, std::string dest, manapi::ctoken cancellation = nullptr);
2929
#endif
3030

3131
#ifdef MANAPIHTTP_ZSTD_DEPENDENCY
3232
manapi::status_or<std::string> zstd_decompress_string (std::string_view src);
3333
manapi::status_or<std::string> zstd_compress_string (std::string_view src, int level);
3434

35-
future<manapi::status> zstd_compress_file (std::string src, std::string dest, int level, int additional_threads = 0, manapi::async::cancellation_action cancellation = nullptr);
36-
future<manapi::status> zstd_decompress_file (std::string src, std::string dest, manapi::async::cancellation_action cancellation = nullptr);
35+
future<manapi::status> zstd_compress_file (std::string src, std::string dest, int level, int additional_threads = 0, manapi::ctoken cancellation = nullptr);
36+
future<manapi::status> zstd_decompress_file (std::string src, std::string dest, manapi::ctoken cancellation = nullptr);
3737
#endif
3838
}
3939

include/crypto/ManapiCryptoUtils.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ namespace manapi::crypto {
5353
* @param cancellation the cancellation token
5454
* @return Ok if there's no error, otherwise it returns Internal, ResourceExhausted, Cancelled
5555
*/
56-
manapi::future<manapi::status> async_random_string (char *buff, size_t len, async::cancellation_action cancellation = nullptr);
56+
manapi::future<manapi::status> async_random_string (char *buff, size_t len, ctoken cancellation = nullptr);
5757

5858
/**
5959
* Get randomly generated string

include/ext/pq/AsyncPostgreClient.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ namespace manapi::ext::pq {
3939

4040
static manapi::status_or<pq::connection> create () MANAPIHTTP_NOEXCEPT;
4141

42-
manapi::future<manapi::ev::status> connect (std::string_view uri, manapi::async::cancellation_action token = nullptr);
42+
manapi::future<manapi::ev::status> connect (std::string_view uri, manapi::ctoken token = nullptr);
4343

44-
manapi::future<manapi::status> connect (std::string host, std::string port, std::string username, std::string password, std::string database, manapi::async::cancellation_action token = nullptr);
44+
manapi::future<manapi::status> connect (std::string host, std::string port, std::string username, std::string password, std::string database, manapi::ctoken token = nullptr);
4545

46-
manapi::future<manapi::status> connect (manapi::json params, manapi::async::cancellation_action token = nullptr);
46+
manapi::future<manapi::status> connect (manapi::json params, manapi::ctoken token = nullptr);
4747

48-
manapi::future<manapi::status> connect (const char * const *keywords, const char * const *values, manapi::async::cancellation_action token = nullptr);
48+
manapi::future<manapi::status> connect (const char * const *keywords, const char * const *values, manapi::ctoken token = nullptr);
4949

50-
manapi::future<pq::status_or<pq::result>> pexec (const char *command, int nParams, const Oid *paramTypes, const char * const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat, manapi::async::cancellation_action token = nullptr);
50+
manapi::future<pq::status_or<pq::result>> pexec (const char *command, int nParams, const Oid *paramTypes, const char * const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat, manapi::ctoken token = nullptr);
5151

5252
template<typename ...Args>
5353
manapi::future<pq::status_or<pq::result>> exec (const std::string &sql, Args &&...args) {
@@ -68,7 +68,7 @@ namespace manapi::ext::pq {
6868
}
6969

7070
template<typename ...Args>
71-
manapi::future<pq::status_or<pq::result>> execl (const std::string &sql, async::cancellation_action token, Args &&...args) {
71+
manapi::future<pq::status_or<pq::result>> execl (const std::string &sql, ctoken token, Args &&...args) {
7272
std::string buffer;
7373
auto res = pq::serialize(buffer, std::make_tuple(args...));
7474
if (!res) co_return res.err();
@@ -77,7 +77,7 @@ namespace manapi::ext::pq {
7777
}
7878

7979
template<typename ...Args>
80-
manapi::future<pq::status_or<pq::result>> execl (const char *sql, async::cancellation_action token, Args &&...args) {
80+
manapi::future<pq::status_or<pq::result>> execl (const char *sql, ctoken token, Args &&...args) {
8181
std::string buffer;
8282
auto res = pq::serialize(buffer, std::make_tuple(args...));
8383
if (!res.ok()) co_return res.err();
@@ -109,17 +109,17 @@ namespace manapi::ext::pq {
109109

110110
void notify_cb (std::move_only_function<manapi::future<>(notification notify)> cb) MANAPIHTTP_NOEXCEPT;
111111
private:
112-
manapi::future<manapi::ev::status> connect_psql_ (manapi::async::cancellation_action token) MANAPIHTTP_NOEXCEPT;
112+
manapi::future<manapi::ev::status> connect_psql_ (manapi::ctoken token) MANAPIHTTP_NOEXCEPT;
113113

114114
MANAPIHTTP_NODISCARD manapi::status check_conn_ () const MANAPIHTTP_NOEXCEPT;
115115

116116
manapi::status_or<size_t> esc_to_buff (std::string_view text, char *buff) MANAPIHTTP_NOEXCEPT;
117117

118-
future<manapi::status> flush (manapi::async::cancellation_action token);
118+
future<manapi::status> flush (manapi::ctoken token);
119119

120-
future<pq::status_or<pq::result>> generic_single_result_query (manapi::async::cancellation_action token);
120+
future<pq::status_or<pq::result>> generic_single_result_query (manapi::ctoken token);
121121

122-
future<manapi::status_or<pq::result>> receive_result (manapi::async::cancellation_action token);
122+
future<manapi::status_or<pq::result>> receive_result (manapi::ctoken token);
123123

124124
static error_code result_status_to_error_code (result &result) MANAPIHTTP_NOEXCEPT;
125125

0 commit comments

Comments
 (0)