Skip to content

Commit 6083ef1

Browse files
authored
Merge pull request #47769 from fastly/jkarneges/handler-cpplib
move handler code into src/cpp
2 parents 7ac8824 + be7fba2 commit 6083ef1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+152
-213
lines changed

.gitignore

-6
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@ vendor
3131
/src/m2adapter/Makefile
3232
/src/proxy/Makefile
3333
/src/handler/Makefile
34-
/src/handler/libpushpin-handler/Makefile
35-
/src/handler/pushpin-handler/Makefile
36-
/src/handler/libpushpin-handler.a
37-
/src/handler/tests/Makefile
38-
/src/handler/tests/*test/Makefile
39-
/src/handler/tests/*test/*test
4034
/src/rust/Makefile
4135
/src/runner/Makefile
4236
/src/runner/librunner/Makefile

src/cpp/cpp/cpp.pri

+61
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,64 @@ SOURCES += \
143143
$$PSRC_DIR/engine.cpp \
144144
$$PSRC_DIR/app.cpp \
145145
$$PSRC_DIR/main.cpp
146+
147+
HSRC_DIR = $$SRC_DIR/handler
148+
149+
HEADERS += \
150+
$$HSRC_DIR/deferred.h \
151+
$$HSRC_DIR/variantutil.h \
152+
$$HSRC_DIR/jsonpointer.h \
153+
$$HSRC_DIR/jsonpatch.h \
154+
$$HSRC_DIR/detectrule.h \
155+
$$HSRC_DIR/lastids.h \
156+
$$HSRC_DIR/cidset.h \
157+
$$HSRC_DIR/sessionrequest.h \
158+
$$HSRC_DIR/requeststate.h \
159+
$$HSRC_DIR/wscontrolmessage.h \
160+
$$HSRC_DIR/publishformat.h \
161+
$$HSRC_DIR/publishitem.h \
162+
$$HSRC_DIR/instruct.h \
163+
$$HSRC_DIR/format.h \
164+
$$HSRC_DIR/idformat.h \
165+
$$HSRC_DIR/httpsession.h \
166+
$$HSRC_DIR/httpsessionupdatemanager.h \
167+
$$HSRC_DIR/wssession.h \
168+
$$HSRC_DIR/publishlastids.h \
169+
$$HSRC_DIR/controlrequest.h \
170+
$$HSRC_DIR/conncheckworker.h \
171+
$$HSRC_DIR/refreshworker.h \
172+
$$HSRC_DIR/ratelimiter.h \
173+
$$HSRC_DIR/sequencer.h \
174+
$$HSRC_DIR/filter.h \
175+
$$HSRC_DIR/filterstack.h \
176+
$$HSRC_DIR/handlerengine.h \
177+
$$HSRC_DIR/handlerapp.h \
178+
$$HSRC_DIR/main.h
179+
180+
SOURCES += \
181+
$$HSRC_DIR/deferred.cpp \
182+
$$HSRC_DIR/variantutil.cpp \
183+
$$HSRC_DIR/jsonpointer.cpp \
184+
$$HSRC_DIR/jsonpatch.cpp \
185+
$$HSRC_DIR/sessionrequest.cpp \
186+
$$HSRC_DIR/requeststate.cpp \
187+
$$HSRC_DIR/wscontrolmessage.cpp \
188+
$$HSRC_DIR/publishformat.cpp \
189+
$$HSRC_DIR/publishitem.cpp \
190+
$$HSRC_DIR/instruct.cpp \
191+
$$HSRC_DIR/format.cpp \
192+
$$HSRC_DIR/idformat.cpp \
193+
$$HSRC_DIR/httpsession.cpp \
194+
$$HSRC_DIR/httpsessionupdatemanager.cpp \
195+
$$HSRC_DIR/wssession.cpp \
196+
$$HSRC_DIR/publishlastids.cpp \
197+
$$HSRC_DIR/controlrequest.cpp \
198+
$$HSRC_DIR/conncheckworker.cpp \
199+
$$HSRC_DIR/refreshworker.cpp \
200+
$$HSRC_DIR/ratelimiter.cpp \
201+
$$HSRC_DIR/sequencer.cpp \
202+
$$HSRC_DIR/filter.cpp \
203+
$$HSRC_DIR/filterstack.cpp \
204+
$$HSRC_DIR/handlerengine.cpp \
205+
$$HSRC_DIR/handlerapp.cpp \
206+
$$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.

src/handler/app.cpp src/cpp/handler/handlerapp.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* $FANOUT_END_LICENSE$
2121
*/
2222

23-
#include "app.h"
23+
#include "handlerapp.h"
2424

2525
#include <assert.h>
2626
#include <QCoreApplication>
@@ -31,7 +31,7 @@
3131
#include "processquit.h"
3232
#include "log.h"
3333
#include "settings.h"
34-
#include "engine.h"
34+
#include "handlerengine.h"
3535
#include "config.h"
3636

3737
#define DEFAULT_HTTP_MAX_HEADERS_SIZE 10000
@@ -144,16 +144,16 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, ArgsD
144144
return CommandLineOk;
145145
}
146146

147-
class App::Private : public QObject
147+
class HandlerApp::Private : public QObject
148148
{
149149
Q_OBJECT
150150

151151
public:
152-
App *q;
152+
HandlerApp *q;
153153
ArgsData args;
154-
Engine *engine;
154+
HandlerEngine *engine;
155155

156-
Private(App *_q) :
156+
Private(HandlerApp *_q) :
157157
QObject(_q),
158158
q(_q),
159159
engine(0)
@@ -299,7 +299,7 @@ class App::Private : public QObject
299299
return;
300300
}
301301

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

353-
engine = new Engine(this);
353+
engine = new HandlerEngine(this);
354354
if(!engine->start(config))
355355
{
356356
emit q->quit();
@@ -383,20 +383,20 @@ private slots:
383383
}
384384
};
385385

386-
App::App(QObject *parent) :
386+
HandlerApp::HandlerApp(QObject *parent) :
387387
QObject(parent)
388388
{
389389
d = new Private(this);
390390
}
391391

392-
App::~App()
392+
HandlerApp::~HandlerApp()
393393
{
394394
delete d;
395395
}
396396

397-
void App::start()
397+
void HandlerApp::start()
398398
{
399399
d->start();
400400
}
401401

402-
#include "app.moc"
402+
#include "handlerapp.moc"

src/handler/app.h src/cpp/handler/handlerapp.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@
2020
* $FANOUT_END_LICENSE$
2121
*/
2222

23-
#ifndef APP_H
24-
#define APP_H
23+
#ifndef HANDLERAPP_H
24+
#define HANDLERAPP_H
2525

2626
#include <QObject>
2727

28-
class App : public QObject
28+
class HandlerApp : public QObject
2929
{
3030
Q_OBJECT
3131

3232
public:
33-
App(QObject *parent = 0);
34-
~App();
33+
HandlerApp(QObject *parent = 0);
34+
~HandlerApp();
3535

3636
void start();
3737

src/handler/engine.cpp src/cpp/handler/handlerengine.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* $FANOUT_END_LICENSE$
2222
*/
2323

24-
#include "engine.h"
24+
#include "handlerengine.h"
2525

2626
#include <assert.h>
2727
#include <algorithm>
@@ -1181,20 +1181,20 @@ private slots:
11811181
}
11821182
};
11831183

1184-
class Engine::Private : public QObject
1184+
class HandlerEngine::Private : public QObject
11851185
{
11861186
Q_OBJECT
11871187

11881188
public:
11891189
class PublishAction : public RateLimiter::Action
11901190
{
11911191
public:
1192-
Engine::Private *ep;
1192+
HandlerEngine::Private *ep;
11931193
QPointer<QObject> target;
11941194
PublishItem item;
11951195
QList<QByteArray> exposeHeaders;
11961196

1197-
PublishAction(Engine::Private *_ep, QObject *_target, const PublishItem &_item, const QList<QByteArray> &_exposeHeaders = QList<QByteArray>()) :
1197+
PublishAction(HandlerEngine::Private *_ep, QObject *_target, const PublishItem &_item, const QList<QByteArray> &_exposeHeaders = QList<QByteArray>()) :
11981198
ep(_ep),
11991199
target(_target),
12001200
item(_item),
@@ -1212,7 +1212,7 @@ class Engine::Private : public QObject
12121212
}
12131213
};
12141214

1215-
Engine *q;
1215+
HandlerEngine *q;
12161216
Configuration config;
12171217
ZhttpManager *zhttpIn;
12181218
ZhttpManager *zhttpOut;
@@ -1244,7 +1244,7 @@ class Engine::Private : public QObject
12441244
QSet<Deferred*> deferreds;
12451245
Deferred *report;
12461246

1247-
Private(Engine *_q) :
1247+
Private(HandlerEngine *_q) :
12481248
QObject(_q),
12491249
q(_q),
12501250
zhttpIn(0),
@@ -3143,25 +3143,25 @@ private slots:
31433143
}
31443144
};
31453145

3146-
Engine::Engine(QObject *parent) :
3146+
HandlerEngine::HandlerEngine(QObject *parent) :
31473147
QObject(parent)
31483148
{
31493149
d = new Private(this);
31503150
}
31513151

3152-
Engine::~Engine()
3152+
HandlerEngine::~HandlerEngine()
31533153
{
31543154
delete d;
31553155
}
31563156

3157-
bool Engine::start(const Configuration &config)
3157+
bool HandlerEngine::start(const Configuration &config)
31583158
{
31593159
return d->start(config);
31603160
}
31613161

3162-
void Engine::reload()
3162+
void HandlerEngine::reload()
31633163
{
31643164
d->reload();
31653165
}
31663166

3167-
#include "engine.moc"
3167+
#include "handlerengine.moc"

src/handler/engine.h src/cpp/handler/handlerengine.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
* $FANOUT_END_LICENSE$
2121
*/
2222

23-
#ifndef ENGINE_H
24-
#define ENGINE_H
23+
#ifndef HANDLERENGINE_H
24+
#define HANDLERENGINE_H
2525

2626
#include <QObject>
2727
#include <QStringList>
2828
#include <QHostAddress>
2929

30-
class Engine : public QObject
30+
class HandlerEngine : public QObject
3131
{
3232
Q_OBJECT
3333

@@ -100,8 +100,8 @@ class Engine : public QObject
100100
}
101101
};
102102

103-
Engine(QObject *parent = 0);
104-
~Engine();
103+
HandlerEngine(QObject *parent = 0);
104+
~HandlerEngine();
105105

106106
bool start(const Configuration &config);
107107
void reload();

src/handler/main.cpp src/cpp/handler/handlermain.cpp

+12-8
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@
2222

2323
#include <QCoreApplication>
2424
#include <QTimer>
25-
#include "app.h"
25+
#include "handlerapp.h"
2626

27-
class AppMain : public QObject
27+
class HandlerAppMain : public QObject
2828
{
2929
Q_OBJECT
3030

3131
public:
32-
App *app;
32+
HandlerApp *app;
3333

3434
public slots:
3535
void start()
3636
{
37-
app = new App(this);
38-
connect(app, &App::quit, this, &AppMain::app_quit);
37+
app = new HandlerApp(this);
38+
connect(app, &HandlerApp::quit, this, &HandlerAppMain::app_quit);
3939
app->start();
4040
}
4141

@@ -46,13 +46,17 @@ public slots:
4646
}
4747
};
4848

49-
int main(int argc, char **argv)
49+
extern "C" {
50+
51+
int handler_main(int argc, char **argv)
5052
{
5153
QCoreApplication qapp(argc, argv);
5254

53-
AppMain appMain;
55+
HandlerAppMain appMain;
5456
QTimer::singleShot(0, &appMain, SLOT(start()));
5557
return qapp.exec();
5658
}
5759

58-
#include "main.moc"
60+
}
61+
62+
#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.

src/cpp/handler/main.h

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef HANDLER_MAIN_H
2+
#define HANDLER_MAIN_H
3+
4+
int handler_main(int argc, char **argv);
5+
6+
#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.

src/handler/tests/enginetest/enginetest.cpp src/cpp/tests/handlerenginetest/enginetest.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "zhttprequestpacket.h"
3030
#include "zhttpresponsepacket.h"
3131
#include "packet/httpresponsedata.h"
32-
#include "engine.h"
32+
#include "handlerengine.h"
3333

3434
class Wrapper : public QObject
3535
{
@@ -253,7 +253,7 @@ class EngineTest : public QObject
253253
Q_OBJECT
254254

255255
private:
256-
Engine *engine;
256+
HandlerEngine *engine;
257257
Wrapper *wrapper;
258258

259259
private slots:
@@ -266,9 +266,9 @@ private slots:
266266
wrapper->startHttp();
267267
wrapper->startProxy();
268268

269-
engine = new Engine(this);
269+
engine = new HandlerEngine(this);
270270

271-
Engine::Configuration config;
271+
HandlerEngine::Configuration config;
272272
config.instanceId = "handler";
273273
config.serverInStreamSpecs = QStringList() << "ipc://client-out-stream";
274274
config.serverOutSpecs = QStringList() << "ipc://client-in";

src/cpp/tests/tests.pri

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ include($$PWD/../../../conf.pri)
1616

1717
INCLUDEPATH += $$SRC_DIR
1818
INCLUDEPATH += $$SRC_DIR/proxy
19+
INCLUDEPATH += $$SRC_DIR/handler
1920
INCLUDEPATH += $$QZMQ_DIR/src
2021

2122
DEFINES += NO_IRISNET

src/cpp/tests/tests.pro

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,10 @@ SUBDIRS += \
44
httpheaderstest \
55
jwttest \
66
routesfiletest \
7-
proxyenginetest
7+
proxyenginetest \
8+
jsonpatchtest \
9+
instructtest \
10+
idformattest \
11+
publishformattest \
12+
publishitemtest \
13+
handlerenginetest

0 commit comments

Comments
 (0)