Cutelyst
2.13.0
|
Signals | |
void | processRequestAsync (Cutelyst::EngineRequest *request) |
Public Member Functions | |
Engine (Application *app, int workerCore, const QVariantMap &opts) | |
Application * | app () const |
application More... | |
QVariantMap | config (const QString &entity) const |
user configuration for the application More... | |
bool | isZeroWorker () const |
QVariantMap | opts () const |
void | processRequest (EngineRequest *request) |
void | setConfig (const QVariantMap &config) |
virtual quint64 | time () |
int | workerCore () const |
Each worker process migth have a number of worker cores (threads), a single process with two worker threads will return 0 and 1 for each of the thread respectively. More... | |
virtual int | workerId () const =0 |
Static Public Member Functions | |
static void | camelCaseByteArrayHeader (QByteArray &key) |
static QString | camelCaseHeader (const QString &headerKey) |
static const char * | httpStatusMessage (quint16 status, int *len=nullptr) |
static QVariantMap | loadIniConfig (const QString &filename) |
static QVariantMap | loadJsonConfig (const QString &filename) |
Protected Member Functions | |
Headers & | defaultHeaders () |
bool | initApplication () |
initApplication More... | |
bool | postForkApplication () |
postForkApplication More... | |
Friends | |
class | Application |
class | Response |
This class is responsible receiving the request and sending the response. It must be reimplemented by real HTTP engines due some pure virtual methods.
The subclass must create an Engine per thread (worker core), if the Application passed to the constructor has a worker core greater than 0 it will issue a new Application instance, failing to do so a fatal error is generated (usually indicating that the Application does not have a Q_INVOKABLE constructor).
|
explicit |
Constructs an Engine object, where app
is the application that might be used to create new instances if workerCore
is greater than 1, opts
is the options loaded by the engine subclass.
app | The application loaded |
workerCore | The thread number |
opts | The configuation options |
Definition at line 57 of file engine.cpp.
References app(), opts(), processRequest(), processRequestAsync(), and workerCore().
Application * Engine::app | ( | ) | const |
Returns the application associated with this engine.
Definition at line 93 of file engine.cpp.
Referenced by Engine().
|
inlinestatic |
|
inlinestatic |
QVariantMap Engine::config | ( | const QString & | entity | ) | const |
entity | the entity you are interested in |
Definition at line 320 of file engine.cpp.
Referenced by Cutelyst::MemcachedSessionStore::MemcachedSessionStore(), setConfig(), Cutelyst::Session::setup(), Cutelyst::StaticCompressed::setup(), Cutelyst::CSRFProtection::setup(), Cutelyst::Application::setup(), and Cutelyst::Memcached::setup().
|
protected |
This is the HTTP default response headers that each request gets
Definition at line 302 of file engine.cpp.
|
static |
Returns the HTTP status message for the given status
.
Definition at line 161 of file engine.cpp.
|
protected |
This method inits the application and calls init on the engine. It must be called on the engine's thread
Definition at line 125 of file engine.cpp.
|
inline |
Returns true if this is the Zero worker, ie if workerId() == 0 and workerCore() == 0
Definition at line 217 of file engine.h.
References workerCore(), and workerId().
|
static |
Returns a QVariantMap with the INI parsed from filename
.
Definition at line 332 of file engine.cpp.
|
static |
Returns a QVariantMap with the JSON parsed from filename
.
Definition at line 356 of file engine.cpp.
QVariantMap Engine::opts | ( | ) | const |
|
protected |
Subclasses must be call after the engine forks by the worker thread, if no forking is involved it must be called once the worker thread has started.
For convenience QThread::currentThread() has it's object name set with the worker core number.
Definition at line 142 of file engine.cpp.
void Engine::processRequest | ( | EngineRequest * | request | ) |
Process the EngineRequest req
, the caller must delete the context when the request is finished.
This method allows for engines to keep the Context alive while processing websocket data.
Definition at line 308 of file engine.cpp.
Referenced by Engine().
|
signal |
Process the EngineRequest req
Async, the caller must delete the context when the request is finished.
This method allows for engines to keep the Context alive while processing websocket data.
Referenced by Engine().
void Engine::setConfig | ( | const QVariantMap & | config | ) |
Sets the configuration to be used by Application
Definition at line 326 of file engine.cpp.
References config().
|
virtual |
Definition at line 156 of file engine.cpp.
int Engine::workerCore | ( | ) | const |
Returns the worker core set when constructing the engine
Definition at line 119 of file engine.cpp.
Referenced by Engine(), isZeroWorker(), and Cutelyst::Application::setup().
|
pure virtual |
Reimplement this to get the workerId of the engine subclass, this is the same as processes id.
The id is the number of the spawned engine process, a single process workerId = 0, two process 0 for the first 1 for the second.
Referenced by isZeroWorker().