1
This commit is contained in:
parent
a075615d14
commit
fe1d0a5def
@ -21,6 +21,7 @@
|
|||||||
#include <f8/utils.h>
|
#include <f8/utils.h>
|
||||||
#include <f8/timer.h>
|
#include <f8/timer.h>
|
||||||
|
|
||||||
|
#if 0
|
||||||
namespace f8
|
namespace f8
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -544,3 +545,4 @@ namespace f8
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
|
||||||
|
#if 0
|
||||||
namespace f8
|
namespace f8
|
||||||
{
|
{
|
||||||
typedef std::vector<std::vector<std::string>> DataSet;
|
typedef std::vector<std::vector<std::string>> DataSet;
|
||||||
@ -37,3 +38,4 @@ namespace f8
|
|||||||
DBPoolImpl* impl_ = nullptr;
|
DBPoolImpl* impl_ = nullptr;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -39,10 +39,14 @@ namespace f8
|
|||||||
struct AsyncHttpRequest
|
struct AsyncHttpRequest
|
||||||
{
|
{
|
||||||
long long context_id = 0;
|
long long context_id = 0;
|
||||||
|
#if 0
|
||||||
a8::XParams param;
|
a8::XParams param;
|
||||||
|
#endif
|
||||||
time_t add_time = 0;
|
time_t add_time = 0;
|
||||||
|
#if 0
|
||||||
AsyncHttpOnOkFunc on_ok = nullptr;
|
AsyncHttpOnOkFunc on_ok = nullptr;
|
||||||
AsyncHttpOnErrorFunc on_error = nullptr;
|
AsyncHttpOnErrorFunc on_error = nullptr;
|
||||||
|
#endif
|
||||||
f8::Attacher timer_attacher;
|
f8::Attacher timer_attacher;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -360,9 +364,11 @@ namespace f8
|
|||||||
if (!request) {
|
if (!request) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
if (request->on_ok) {
|
if (request->on_ok) {
|
||||||
request->on_ok(request->param, data);
|
request->on_ok(request->param, data);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
async_http_hash.erase(seqid);
|
async_http_hash.erase(seqid);
|
||||||
delete request;
|
delete request;
|
||||||
}
|
}
|
||||||
@ -373,13 +379,16 @@ namespace f8
|
|||||||
if (!request) {
|
if (!request) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
if (request->on_error) {
|
if (request->on_error) {
|
||||||
request->on_error(request->param, response);
|
request->on_error(request->param, response);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
async_http_hash.erase(seqid);
|
async_http_hash.erase(seqid);
|
||||||
delete request;
|
delete request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
void InternalExecAsyncHttp(int method, const char* url, a8::XObject& url_params,
|
void InternalExecAsyncHttp(int method, const char* url, a8::XObject& url_params,
|
||||||
const char* content, a8::XObject* headers,
|
const char* content, a8::XObject* headers,
|
||||||
a8::XParams param, AsyncHttpOnOkFunc on_ok, AsyncHttpOnErrorFunc on_error,
|
a8::XParams param, AsyncHttpOnOkFunc on_ok, AsyncHttpOnErrorFunc on_error,
|
||||||
@ -427,6 +436,7 @@ namespace f8
|
|||||||
},
|
},
|
||||||
&p->timer_attacher);
|
&p->timer_attacher);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if F8_MUTLI_THREAD_HTTP
|
#if F8_MUTLI_THREAD_HTTP
|
||||||
HttpThread* GetHttpThread(long long hash_code)
|
HttpThread* GetHttpThread(long long hash_code)
|
||||||
@ -543,19 +553,27 @@ namespace f8
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void HttpClientPool::HttpGet(a8::XParams param, AsyncHttpOnOkFunc on_ok, AsyncHttpOnErrorFunc on_error,
|
void HttpClientPool::HttpGet(f8::HttpProxyCb cb,
|
||||||
const char* url, a8::XObject url_params,
|
const char* url,
|
||||||
long long hash_code, a8::XObject* headers)
|
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);
|
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,
|
void HttpClientPool::HttpPost(f8::HttpProxyCb cb,
|
||||||
const char* url, a8::XObject url_params, const std::string& content,
|
const char* url,
|
||||||
|
a8::XObject url_params,
|
||||||
|
const std::string& content,
|
||||||
long long hash_code, a8::XObject* headers)
|
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);
|
impl_->InternalExecAsyncHttp(2, url, url_params, content.c_str(), headers, param, on_ok, on_error, hash_code);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
long long HttpClientPool::GetPendingNum()
|
long long HttpClientPool::GetPendingNum()
|
||||||
|
@ -6,9 +6,6 @@ namespace f8
|
|||||||
struct HttpContext;
|
struct HttpContext;
|
||||||
typedef std::function<void(bool, a8::XObject*, f8::HttpContext*)> HttpProxyCb;
|
typedef std::function<void(bool, a8::XObject*, f8::HttpContext*)> HttpProxyCb;
|
||||||
|
|
||||||
typedef void (*AsyncHttpOnOkFunc)(a8::XParams& param, a8::XObject& data);
|
|
||||||
typedef void (*AsyncHttpOnErrorFunc)(a8::XParams& param, const std::string& response);
|
|
||||||
|
|
||||||
class HttpClientPoolImpl;
|
class HttpClientPoolImpl;
|
||||||
class HttpClientPool : public a8::Singleton<HttpClientPool>
|
class HttpClientPool : public a8::Singleton<HttpClientPool>
|
||||||
{
|
{
|
||||||
@ -28,13 +25,21 @@ namespace f8
|
|||||||
void UnInit();
|
void UnInit();
|
||||||
|
|
||||||
//执行异步http get
|
//执行异步http get
|
||||||
void HttpGet(a8::XParams param, AsyncHttpOnOkFunc on_ok, AsyncHttpOnErrorFunc on_error,
|
void HttpGet(
|
||||||
const char* url, a8::XObject url_params,
|
f8::HttpProxyCb cb,
|
||||||
long long hash_code, a8::XObject* headers = nullptr);
|
const char* url,
|
||||||
|
a8::XObject url_params,
|
||||||
|
long long hash_code,
|
||||||
|
a8::XObject* headers = nullptr);
|
||||||
//执行异步http post
|
//执行异步http post
|
||||||
void HttpPost(a8::XParams param, AsyncHttpOnOkFunc on_ok, AsyncHttpOnErrorFunc on_error,
|
void HttpPost(
|
||||||
const char* url, a8::XObject url_params, const std::string& content,
|
f8::HttpProxyCb cb,
|
||||||
long long hash_code, a8::XObject* headers = nullptr);
|
const char* url,
|
||||||
|
a8::XObject url_params,
|
||||||
|
const std::string& content,
|
||||||
|
long long hash_code,
|
||||||
|
a8::XObject* headers = nullptr);
|
||||||
|
|
||||||
//获取执行中的数量
|
//获取执行中的数量
|
||||||
long long GetPendingNum();
|
long long GetPendingNum();
|
||||||
HttpClientPoolImpl* Impl();
|
HttpClientPoolImpl* Impl();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user