Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move handler code into src/cpp #47769

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ vendor
/src/m2adapter/Makefile
/src/proxy/Makefile
/src/handler/Makefile
/src/handler/libpushpin-handler/Makefile
/src/handler/pushpin-handler/Makefile
/src/handler/libpushpin-handler.a
/src/handler/tests/Makefile
/src/handler/tests/*test/Makefile
/src/handler/tests/*test/*test
/src/rust/Makefile
/src/runner/Makefile
/src/runner/librunner/Makefile
Expand Down
61 changes: 61 additions & 0 deletions src/cpp/cpp/cpp.pri
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,64 @@ SOURCES += \
$$PSRC_DIR/engine.cpp \
$$PSRC_DIR/app.cpp \
$$PSRC_DIR/main.cpp

HSRC_DIR = $$SRC_DIR/handler

HEADERS += \
$$HSRC_DIR/deferred.h \
$$HSRC_DIR/variantutil.h \
$$HSRC_DIR/jsonpointer.h \
$$HSRC_DIR/jsonpatch.h \
$$HSRC_DIR/detectrule.h \
$$HSRC_DIR/lastids.h \
$$HSRC_DIR/cidset.h \
$$HSRC_DIR/sessionrequest.h \
$$HSRC_DIR/requeststate.h \
$$HSRC_DIR/wscontrolmessage.h \
$$HSRC_DIR/publishformat.h \
$$HSRC_DIR/publishitem.h \
$$HSRC_DIR/instruct.h \
$$HSRC_DIR/format.h \
$$HSRC_DIR/idformat.h \
$$HSRC_DIR/httpsession.h \
$$HSRC_DIR/httpsessionupdatemanager.h \
$$HSRC_DIR/wssession.h \
$$HSRC_DIR/publishlastids.h \
$$HSRC_DIR/controlrequest.h \
$$HSRC_DIR/conncheckworker.h \
$$HSRC_DIR/refreshworker.h \
$$HSRC_DIR/ratelimiter.h \
$$HSRC_DIR/sequencer.h \
$$HSRC_DIR/filter.h \
$$HSRC_DIR/filterstack.h \
$$HSRC_DIR/handlerengine.h \
$$HSRC_DIR/handlerapp.h \
$$HSRC_DIR/main.h

SOURCES += \
$$HSRC_DIR/deferred.cpp \
$$HSRC_DIR/variantutil.cpp \
$$HSRC_DIR/jsonpointer.cpp \
$$HSRC_DIR/jsonpatch.cpp \
$$HSRC_DIR/sessionrequest.cpp \
$$HSRC_DIR/requeststate.cpp \
$$HSRC_DIR/wscontrolmessage.cpp \
$$HSRC_DIR/publishformat.cpp \
$$HSRC_DIR/publishitem.cpp \
$$HSRC_DIR/instruct.cpp \
$$HSRC_DIR/format.cpp \
$$HSRC_DIR/idformat.cpp \
$$HSRC_DIR/httpsession.cpp \
$$HSRC_DIR/httpsessionupdatemanager.cpp \
$$HSRC_DIR/wssession.cpp \
$$HSRC_DIR/publishlastids.cpp \
$$HSRC_DIR/controlrequest.cpp \
$$HSRC_DIR/conncheckworker.cpp \
$$HSRC_DIR/refreshworker.cpp \
$$HSRC_DIR/ratelimiter.cpp \
$$HSRC_DIR/sequencer.cpp \
$$HSRC_DIR/filter.cpp \
$$HSRC_DIR/filterstack.cpp \
$$HSRC_DIR/handlerengine.cpp \
$$HSRC_DIR/handlerapp.cpp \
$$HSRC_DIR/handlermain.cpp
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 12 additions & 12 deletions src/handler/app.cpp → src/cpp/handler/handlerapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* $FANOUT_END_LICENSE$
*/

#include "app.h"
#include "handlerapp.h"

#include <assert.h>
#include <QCoreApplication>
Expand All @@ -31,7 +31,7 @@
#include "processquit.h"
#include "log.h"
#include "settings.h"
#include "engine.h"
#include "handlerengine.h"
#include "config.h"

#define DEFAULT_HTTP_MAX_HEADERS_SIZE 10000
Expand Down Expand Up @@ -144,16 +144,16 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, ArgsD
return CommandLineOk;
}

class App::Private : public QObject
class HandlerApp::Private : public QObject
{
Q_OBJECT

public:
App *q;
HandlerApp *q;
ArgsData args;
Engine *engine;
HandlerEngine *engine;

Private(App *_q) :
Private(HandlerApp *_q) :
QObject(_q),
q(_q),
engine(0)
Expand Down Expand Up @@ -299,7 +299,7 @@ class App::Private : public QObject
return;
}

Engine::Configuration config;
HandlerEngine::Configuration config;
config.appVersion = VERSION;
config.instanceId = "pushpin-handler_" + QByteArray::number(QCoreApplication::applicationPid());
if(!services.contains("mongrel2") && (!condure_in_stream_specs.isEmpty() || !condure_out_specs.isEmpty()))
Expand Down Expand Up @@ -350,7 +350,7 @@ class App::Private : public QObject
config.prometheusPort = prometheusPort;
config.prometheusPrefix = prometheusPrefix;

engine = new Engine(this);
engine = new HandlerEngine(this);
if(!engine->start(config))
{
emit q->quit();
Expand Down Expand Up @@ -383,20 +383,20 @@ private slots:
}
};

App::App(QObject *parent) :
HandlerApp::HandlerApp(QObject *parent) :
QObject(parent)
{
d = new Private(this);
}

App::~App()
HandlerApp::~HandlerApp()
{
delete d;
}

void App::start()
void HandlerApp::start()
{
d->start();
}

#include "app.moc"
#include "handlerapp.moc"
10 changes: 5 additions & 5 deletions src/handler/app.h → src/cpp/handler/handlerapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@
* $FANOUT_END_LICENSE$
*/

#ifndef APP_H
#define APP_H
#ifndef HANDLERAPP_H
#define HANDLERAPP_H

#include <QObject>

class App : public QObject
class HandlerApp : public QObject
{
Q_OBJECT

public:
App(QObject *parent = 0);
~App();
HandlerApp(QObject *parent = 0);
~HandlerApp();

void start();

Expand Down
22 changes: 11 additions & 11 deletions src/handler/engine.cpp → src/cpp/handler/handlerengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* $FANOUT_END_LICENSE$
*/

#include "engine.h"
#include "handlerengine.h"

#include <assert.h>
#include <algorithm>
Expand Down Expand Up @@ -1181,20 +1181,20 @@ private slots:
}
};

class Engine::Private : public QObject
class HandlerEngine::Private : public QObject
{
Q_OBJECT

public:
class PublishAction : public RateLimiter::Action
{
public:
Engine::Private *ep;
HandlerEngine::Private *ep;
QPointer<QObject> target;
PublishItem item;
QList<QByteArray> exposeHeaders;

PublishAction(Engine::Private *_ep, QObject *_target, const PublishItem &_item, const QList<QByteArray> &_exposeHeaders = QList<QByteArray>()) :
PublishAction(HandlerEngine::Private *_ep, QObject *_target, const PublishItem &_item, const QList<QByteArray> &_exposeHeaders = QList<QByteArray>()) :
ep(_ep),
target(_target),
item(_item),
Expand All @@ -1212,7 +1212,7 @@ class Engine::Private : public QObject
}
};

Engine *q;
HandlerEngine *q;
Configuration config;
ZhttpManager *zhttpIn;
ZhttpManager *zhttpOut;
Expand Down Expand Up @@ -1244,7 +1244,7 @@ class Engine::Private : public QObject
QSet<Deferred*> deferreds;
Deferred *report;

Private(Engine *_q) :
Private(HandlerEngine *_q) :
QObject(_q),
q(_q),
zhttpIn(0),
Expand Down Expand Up @@ -3143,25 +3143,25 @@ private slots:
}
};

Engine::Engine(QObject *parent) :
HandlerEngine::HandlerEngine(QObject *parent) :
QObject(parent)
{
d = new Private(this);
}

Engine::~Engine()
HandlerEngine::~HandlerEngine()
{
delete d;
}

bool Engine::start(const Configuration &config)
bool HandlerEngine::start(const Configuration &config)
{
return d->start(config);
}

void Engine::reload()
void HandlerEngine::reload()
{
d->reload();
}

#include "engine.moc"
#include "handlerengine.moc"
10 changes: 5 additions & 5 deletions src/handler/engine.h → src/cpp/handler/handlerengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
* $FANOUT_END_LICENSE$
*/

#ifndef ENGINE_H
#define ENGINE_H
#ifndef HANDLERENGINE_H
#define HANDLERENGINE_H

#include <QObject>
#include <QStringList>
#include <QHostAddress>

class Engine : public QObject
class HandlerEngine : public QObject
{
Q_OBJECT

Expand Down Expand Up @@ -100,8 +100,8 @@ class Engine : public QObject
}
};

Engine(QObject *parent = 0);
~Engine();
HandlerEngine(QObject *parent = 0);
~HandlerEngine();

bool start(const Configuration &config);
void reload();
Expand Down
20 changes: 12 additions & 8 deletions src/handler/main.cpp → src/cpp/handler/handlermain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@

#include <QCoreApplication>
#include <QTimer>
#include "app.h"
#include "handlerapp.h"

class AppMain : public QObject
class HandlerAppMain : public QObject
{
Q_OBJECT

public:
App *app;
HandlerApp *app;

public slots:
void start()
{
app = new App(this);
connect(app, &App::quit, this, &AppMain::app_quit);
app = new HandlerApp(this);
connect(app, &HandlerApp::quit, this, &HandlerAppMain::app_quit);
app->start();
}

Expand All @@ -46,13 +46,17 @@ public slots:
}
};

int main(int argc, char **argv)
extern "C" {

int handler_main(int argc, char **argv)
{
QCoreApplication qapp(argc, argv);

AppMain appMain;
HandlerAppMain appMain;
QTimer::singleShot(0, &appMain, SLOT(start()));
return qapp.exec();
}

#include "main.moc"
}

#include "handlermain.moc"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions src/cpp/handler/main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef HANDLER_MAIN_H
#define HANDLER_MAIN_H

int handler_main(int argc, char **argv);

#endif
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "zhttprequestpacket.h"
#include "zhttpresponsepacket.h"
#include "packet/httpresponsedata.h"
#include "engine.h"
#include "handlerengine.h"

class Wrapper : public QObject
{
Expand Down Expand Up @@ -253,7 +253,7 @@ class EngineTest : public QObject
Q_OBJECT

private:
Engine *engine;
HandlerEngine *engine;
Wrapper *wrapper;

private slots:
Expand All @@ -266,9 +266,9 @@ private slots:
wrapper->startHttp();
wrapper->startProxy();

engine = new Engine(this);
engine = new HandlerEngine(this);

Engine::Configuration config;
HandlerEngine::Configuration config;
config.instanceId = "handler";
config.serverInStreamSpecs = QStringList() << "ipc://client-out-stream";
config.serverOutSpecs = QStringList() << "ipc://client-in";
Expand Down
1 change: 1 addition & 0 deletions src/cpp/tests/tests.pri
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ include($$PWD/../../../conf.pri)

INCLUDEPATH += $$SRC_DIR
INCLUDEPATH += $$SRC_DIR/proxy
INCLUDEPATH += $$SRC_DIR/handler
INCLUDEPATH += $$QZMQ_DIR/src

DEFINES += NO_IRISNET
Expand Down
8 changes: 7 additions & 1 deletion src/cpp/tests/tests.pro
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@ SUBDIRS += \
httpheaderstest \
jwttest \
routesfiletest \
proxyenginetest
proxyenginetest \
jsonpatchtest \
instructtest \
idformattest \
publishformattest \
publishitemtest \
handlerenginetest
Loading