From fe1d0a5def93f1398010c3195a244f81ceb646d6 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sun, 18 Dec 2022 13:57:27 +0800 Subject: [PATCH] 1 --- f8/dbpool.cc | 2 ++ f8/dbpool.h | 2 ++ f8/httpclientpool.cc | 28 +++++++++++++++++++++++----- f8/httpclientpool.h | 23 ++++++++++++++--------- 4 files changed, 41 insertions(+), 14 deletions(-) diff --git a/f8/dbpool.cc b/f8/dbpool.cc index 0c0a105..ba59601 100644 --- a/f8/dbpool.cc +++ b/f8/dbpool.cc @@ -21,6 +21,7 @@ #include #include +#if 0 namespace f8 { @@ -544,3 +545,4 @@ namespace f8 } } +#endif diff --git a/f8/dbpool.h b/f8/dbpool.h index 888c8c8..589f7b0 100644 --- a/f8/dbpool.h +++ b/f8/dbpool.h @@ -2,6 +2,7 @@ #include +#if 0 namespace f8 { typedef std::vector> DataSet; @@ -37,3 +38,4 @@ namespace f8 DBPoolImpl* impl_ = nullptr; }; } +#endif diff --git a/f8/httpclientpool.cc b/f8/httpclientpool.cc index 4c21a8d..bb21d8c 100644 --- a/f8/httpclientpool.cc +++ b/f8/httpclientpool.cc @@ -39,10 +39,14 @@ namespace f8 struct AsyncHttpRequest { long long context_id = 0; + #if 0 a8::XParams param; + #endif time_t add_time = 0; + #if 0 AsyncHttpOnOkFunc on_ok = nullptr; AsyncHttpOnErrorFunc on_error = nullptr; + #endif f8::Attacher timer_attacher; }; @@ -360,9 +364,11 @@ namespace f8 if (!request) { return; } + #if 0 if (request->on_ok) { request->on_ok(request->param, data); } + #endif async_http_hash.erase(seqid); delete request; } @@ -373,13 +379,16 @@ namespace f8 if (!request) { return; } + #if 0 if (request->on_error) { request->on_error(request->param, response); } + #endif async_http_hash.erase(seqid); delete request; } + #if 0 void InternalExecAsyncHttp(int method, const char* url, a8::XObject& url_params, const char* content, a8::XObject* headers, a8::XParams param, AsyncHttpOnOkFunc on_ok, AsyncHttpOnErrorFunc on_error, @@ -427,6 +436,7 @@ namespace f8 }, &p->timer_attacher); } + #endif #if F8_MUTLI_THREAD_HTTP HttpThread* GetHttpThread(long long hash_code) @@ -543,19 +553,27 @@ namespace f8 #endif } - void HttpClientPool::HttpGet(a8::XParams param, AsyncHttpOnOkFunc on_ok, AsyncHttpOnErrorFunc on_error, - const char* url, a8::XObject url_params, - long long hash_code, a8::XObject* headers) + void HttpClientPool::HttpGet(f8::HttpProxyCb cb, + const char* url, + a8::XObject url_params, + long long hash_code, + a8::XObject* headers) { + #if 0 impl_->InternalExecAsyncHttp(1, url, url_params, "", headers, param, on_ok, on_error, hash_code); + #endif } - void HttpClientPool::HttpPost(a8::XParams param, AsyncHttpOnOkFunc on_ok, AsyncHttpOnErrorFunc on_error, - const char* url, a8::XObject url_params, const std::string& content, + void HttpClientPool::HttpPost(f8::HttpProxyCb cb, + const char* url, + a8::XObject url_params, + const std::string& content, long long hash_code, a8::XObject* headers) { + #if 0 impl_->InternalExecAsyncHttp(2, url, url_params, content.c_str(), headers, param, on_ok, on_error, hash_code); + #endif } long long HttpClientPool::GetPendingNum() diff --git a/f8/httpclientpool.h b/f8/httpclientpool.h index 29dbc65..7742b7e 100644 --- a/f8/httpclientpool.h +++ b/f8/httpclientpool.h @@ -6,9 +6,6 @@ namespace f8 struct HttpContext; typedef std::function HttpProxyCb; - typedef void (*AsyncHttpOnOkFunc)(a8::XParams& param, a8::XObject& data); - typedef void (*AsyncHttpOnErrorFunc)(a8::XParams& param, const std::string& response); - class HttpClientPoolImpl; class HttpClientPool : public a8::Singleton { @@ -28,13 +25,21 @@ namespace f8 void UnInit(); //执行异步http get - void HttpGet(a8::XParams param, AsyncHttpOnOkFunc on_ok, AsyncHttpOnErrorFunc on_error, - const char* url, a8::XObject url_params, - long long hash_code, a8::XObject* headers = nullptr); + void HttpGet( + f8::HttpProxyCb cb, + const char* url, + a8::XObject url_params, + long long hash_code, + a8::XObject* headers = nullptr); //执行异步http post - void HttpPost(a8::XParams param, AsyncHttpOnOkFunc on_ok, AsyncHttpOnErrorFunc on_error, - const char* url, a8::XObject url_params, const std::string& content, - long long hash_code, a8::XObject* headers = nullptr); + void HttpPost( + f8::HttpProxyCb cb, + const char* url, + a8::XObject url_params, + const std::string& content, + long long hash_code, + a8::XObject* headers = nullptr); + //获取执行中的数量 long long GetPendingNum(); HttpClientPoolImpl* Impl();