mirror of
https://github.com/sogou/workflow.git
synced 2026-02-08 01:33:17 +08:00
Merge branch 'master' of https://github.com/sogou/workflow into nossl
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <functional>
|
||||
#include <openssl/ssl.h>
|
||||
#include "json_parser.h"
|
||||
#include "StringUtil.h"
|
||||
#include "URIParser.h"
|
||||
@@ -46,6 +47,7 @@ WFConsulTask::WFConsulTask(const std::string& proxy_url,
|
||||
this->retry_max = retry_max;
|
||||
this->finish = false;
|
||||
this->consul_index = 0;
|
||||
this->ssl_ctx = NULL;
|
||||
}
|
||||
|
||||
void WFConsulTask::set_service(const struct protocol::ConsulService *service)
|
||||
@@ -170,6 +172,9 @@ void WFConsulTask::dispatch()
|
||||
return;
|
||||
}
|
||||
|
||||
auto *t = (WFComplexClientTask<HttpRequest, HttpResponse> *)task;
|
||||
t->set_ssl_ctx(this->ssl_ctx);
|
||||
|
||||
series_of(this)->push_front(this);
|
||||
series_of(this)->push_front(task);
|
||||
this->subtask_done();
|
||||
@@ -395,7 +400,8 @@ void WFConsulTask::register_callback(WFHttpTask *task)
|
||||
t->finish = true;
|
||||
}
|
||||
|
||||
int WFConsulClient::init(const std::string& proxy_url, ConsulConfig config)
|
||||
int WFConsulClient::init(const std::string& proxy_url, ConsulConfig config,
|
||||
SSL_CTX *ssl_ctx)
|
||||
{
|
||||
ParsedURI uri;
|
||||
|
||||
@@ -411,6 +417,7 @@ int WFConsulClient::init(const std::string& proxy_url, ConsulConfig config)
|
||||
}
|
||||
|
||||
this->config = std::move(config);
|
||||
this->ssl_ctx = ssl_ctx;
|
||||
return 0;
|
||||
}
|
||||
else if (uri.state == URI_STATE_INVALID)
|
||||
@@ -419,11 +426,6 @@ int WFConsulClient::init(const std::string& proxy_url, ConsulConfig config)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int WFConsulClient::init(const std::string& proxy_url)
|
||||
{
|
||||
return this->init(proxy_url, ConsulConfig());
|
||||
}
|
||||
|
||||
WFConsulTask *WFConsulClient::create_discover_task(
|
||||
const std::string& service_namespace,
|
||||
const std::string& service_name,
|
||||
@@ -435,6 +437,7 @@ WFConsulTask *WFConsulClient::create_discover_task(
|
||||
std::move(cb));
|
||||
task->set_api_type(CONSUL_API_TYPE_DISCOVER);
|
||||
task->set_config(this->config);
|
||||
task->set_ssl_ctx(this->ssl_ctx);
|
||||
return task;
|
||||
}
|
||||
|
||||
@@ -448,6 +451,7 @@ WFConsulTask *WFConsulClient::create_list_service_task(
|
||||
std::move(cb));
|
||||
task->set_api_type(CONSUL_API_TYPE_LIST_SERVICE);
|
||||
task->set_config(this->config);
|
||||
task->set_ssl_ctx(this->ssl_ctx);
|
||||
return task;
|
||||
}
|
||||
|
||||
@@ -463,6 +467,7 @@ WFConsulTask *WFConsulClient::create_register_task(
|
||||
std::move(cb));
|
||||
task->set_api_type(CONSUL_API_TYPE_REGISTER);
|
||||
task->set_config(this->config);
|
||||
task->set_ssl_ctx(this->ssl_ctx);
|
||||
return task;
|
||||
}
|
||||
|
||||
@@ -477,6 +482,7 @@ WFConsulTask *WFConsulClient::create_deregister_task(
|
||||
std::move(cb));
|
||||
task->set_api_type(CONSUL_API_TYPE_DEREGISTER);
|
||||
task->set_config(this->config);
|
||||
task->set_ssl_ctx(this->ssl_ctx);
|
||||
return task;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <functional>
|
||||
#include <openssl/ssl.h>
|
||||
#include "HttpMessage.h"
|
||||
#include "WFTaskFactory.h"
|
||||
#include "ConsulDataTypes.h"
|
||||
@@ -83,6 +84,11 @@ protected:
|
||||
this->config = std::move(conf);
|
||||
}
|
||||
|
||||
void set_ssl_ctx(SSL_CTX *ssl_ctx)
|
||||
{
|
||||
this->ssl_ctx = ssl_ctx;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void dispatch();
|
||||
virtual SubTask *done();
|
||||
@@ -102,6 +108,7 @@ protected:
|
||||
|
||||
protected:
|
||||
protocol::ConsulConfig config;
|
||||
SSL_CTX *ssl_ctx;
|
||||
struct protocol::ConsulService service;
|
||||
std::string proxy_url;
|
||||
int retry_max;
|
||||
@@ -125,8 +132,25 @@ class WFConsulClient
|
||||
{
|
||||
public:
|
||||
// example: http://127.0.0.1:8500
|
||||
int init(const std::string& proxy_url);
|
||||
int init(const std::string& proxy_url, protocol::ConsulConfig config);
|
||||
int init(const std::string& proxy_url)
|
||||
{
|
||||
return this->init(proxy_url, NULL);
|
||||
}
|
||||
|
||||
int init(const std::string& proxy_url, protocol::ConsulConfig config)
|
||||
{
|
||||
return this->init(proxy_url, std::move(config), NULL);
|
||||
}
|
||||
|
||||
// with specific SSL_CTX
|
||||
int init(const std::string& proxy_url, SSL_CTX *ctx_ctx)
|
||||
{
|
||||
return this->init(proxy_url, protocol::ConsulConfig(), ssl_ctx);
|
||||
}
|
||||
|
||||
int init(const std::string& proxy_url, protocol::ConsulConfig config,
|
||||
SSL_CTX *ctx);
|
||||
|
||||
void deinit() { }
|
||||
|
||||
WFConsulTask *create_discover_task(const std::string& service_namespace,
|
||||
@@ -149,9 +173,10 @@ public:
|
||||
int retry_max,
|
||||
consul_callback_t cb);
|
||||
|
||||
private:
|
||||
protected:
|
||||
std::string proxy_url;
|
||||
protocol::ConsulConfig config;
|
||||
SSL_CTX *ssl_ctx;
|
||||
|
||||
public:
|
||||
virtual ~WFConsulClient() { }
|
||||
|
||||
Reference in New Issue
Block a user