Commit 269080e7 authored by fred's avatar fred
Browse files

added a zm proxy to improve api payload

parent 50d589e0
......@@ -54,16 +54,8 @@ void ZerogwProxy::init()
QString uri = "ipc://" + m_ncs_params.base_directory + "/payloads";
worker_payload->bind (uri.toLatin1());
QThread *thread_api_payload = new QThread;
api_payload = new Api_payload(m_ncs_params.base_directory, 0);
api_payload->moveToThread(thread_api_payload);
thread_api_payload->start();
QThread *thread_api_payload2 = new QThread;
api_payload2 = new Api_payload(m_ncs_params.base_directory, 0);
api_payload2->moveToThread(thread_api_payload2);
thread_api_payload2->start();
qDebug() << "ZerogwProxy::init BEFORE PROXY";
zmq::proxy (*zerogw, *worker_payload, NULL);
......@@ -169,26 +161,17 @@ void Service::Http_api_init()
//connect(api_payload, SIGNAL(forward_payload(BSONObj)), dispatch, SLOT(push_payload(BSONObj)), Qt::QueuedConnection);
QThread *thread_api_node = new QThread;
api_node = new Api_node(m_ncs_params.base_directory, port + 1);
api_node->moveToThread(thread_api_node);
thread_api_node->start();
//connect(this, SIGNAL(shutdown()), api_node, SLOT(destructor()), Qt::BlockingQueuedConnection);
//connect(api_node, SIGNAL(forward_payload(BSONObj)), dispatch, SLOT(push_payload(BSONObj)), Qt::QueuedConnection);
QThread *thread_api_workflow = new QThread;
api_workflow = new Api_workflow(m_ncs_params.base_directory, port + 2);
api_workflow->moveToThread(thread_api_workflow);
thread_api_workflow->start();
//connect(this, SIGNAL(shutdown()), api_workflow, SLOT(destructor()), Qt::BlockingQueuedConnection);
//connect(api_workflow, SIGNAL(forward_payload(BSONObj)), dispatch, SLOT(push_payload(BSONObj)), Qt::QueuedConnection);
QThread *thread_api_user = new QThread;
api_user = new Api_user(m_ncs_params.base_directory, port + 3);
api_user->moveToThread(thread_api_user);
thread_api_user->start();
}
......
......@@ -22,15 +22,25 @@
Zerogw::Zerogw(QString basedirectory, int port, QObject *parent) : m_basedirectory(basedirectory), QObject(parent)
Zerogw::Zerogw(QString basedirectory, int port, QObject *parent) : m_basedirectory(basedirectory), m_port(port), QObject(parent)
{
std::cout << "Zerogw::Zerogw construct" << std::endl;
thread = new QThread;
this->moveToThread(thread);
thread->start();
thread->connect(thread, SIGNAL(started()), this, SLOT(init()));
mongodb_ = Mongodb::getInstance();
zeromq_ = Zeromq::getInstance ();
m_context = zeromq_->m_context;
m_mutex = new QMutex();
}
void Zerogw::init()
{
// Socket to ZPULL class
......@@ -53,7 +63,7 @@ Zerogw::Zerogw(QString basedirectory, int port, QObject *parent) : m_basedirecto
m_socket_zerogw->setsockopt(ZMQ_SNDHWM, &hwm, sizeof (hwm));
m_socket_zerogw->setsockopt(ZMQ_RCVHWM, &hwm, sizeof (hwm));
if (port == 0 )
if (m_port == 0 )
{
// QString uri = "tcp://127.0.0.1:2504" + QString::number(port);
QString uri = "ipc://" + m_basedirectory + "/payloads";
......@@ -61,7 +71,7 @@ Zerogw::Zerogw(QString basedirectory, int port, QObject *parent) : m_basedirecto
}
else
{
QString uri = "tcp://*:" + QString::number(port);
QString uri = "tcp://*:" + QString::number(m_port);
m_socket_zerogw->bind(uri.toAscii());
}
......
......@@ -67,10 +67,11 @@ public:
~Zerogw();
protected:
QThread *thread;
QBool checkAuth(QString token, BSONObjBuilder &payload_builder, BSONObj &a_user);
QString buildResponse(QString action, QString data1, QString data2="");
QString m_basedirectory;
int m_port;
Mongodb *mongodb_;
Zeromq *zeromq_;
zmq::context_t *m_context;
......@@ -89,6 +90,7 @@ signals:
private slots:
void init();
virtual void receive_http_payload()=0;
void forward_payload_to_zpull(BSONObj payload);
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment