CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
Loading...
Searching...
No Matches
cmlabs::RequestGateway Class Reference

The request-fabric router/load-balancer (see the file header for the full role description). More...

#include <RequestGateway.h>

Inheritance diagram for cmlabs::RequestGateway:
[legend]
Collaboration diagram for cmlabs::RequestGateway:
[legend]

Public Member Functions

 RequestGateway (uint32 id, const char *version=NULL)
virtual ~RequestGateway ()
bool init (const char *sslCertPath=NULL, const char *sslKeyPath=NULL)
 Start the gateway threads and network stack.
bool setWebServerInfo (const char *name, const char *rootdir, const char *indexfile)
 Configure the built-in file web server.
bool setExternalAPILabel (const char *label)
 Set the URI label under which the external (public) API is exposed.
bool setInternalAPILabel (const char *label)
 Set the URI label under which the internal (management) API is exposed.
bool setCacheFiles (bool cache)
 Enable/disable HTTP caching headers for served files.
bool setResponseType (const char *type)
 Choose the reply serialisation ("xml" or "json").
bool setLongRequestLimit (uint32 limit)
 Cap concurrent long requests per executor.
bool setExecutorHeartbeatTimeout (uint32 timeout)
 Set how long an executor may go silent before being declared dead (its queue is then redistributed).
bool setMaxExecutorRequestTimeout (uint32 timeout)
 Set the maximum time a request may sit with an executor before being failed/retried.
bool setQueuingParameters (uint32 maxRequestQueueSize, uint32 maxRequestProcessingSize, uint32 priorityThreshold)
 Tune queuing/backpressure behaviour.
bool addPort (uint16 port, uint8 encryption, bool enableHTTP=false, uint32 timeout=3000)
 Open a listening port for clients/executors (call before init()).
bool addGateway (uint32 id, std::string addr, uint16 port)
 Register a peer gateway (multi-gateway federation).
bool addAuthUser (const char *user, const char *password)
 Add a basic-auth user for the web interface/APIs.
bool receiveNetworkEvent (NetworkEvent *evt, NetworkChannel *channel, uint64 conid)
 NetworkReceiver hook: connect/disconnect events for clients and executors.
bool receiveMessage (DataMessage *msg, NetworkChannel *channel, uint64 conid)
 NetworkReceiver hook: binary requests/replies/heartbeats from clients and executors.
bool receiveHTTPRequest (HTTPRequest *req, NetworkChannel *channel, uint64 conid)
 NetworkReceiver hook: web ingress — serves files, APIs, or converts the request into an internal DataMessage request.
bool receiveWebsocketData (WebsocketData *wsData, NetworkChannel *channel, uint64 conid)
 NetworkReceiver hook: WebSocket ingress carrying request payloads.
Public Member Functions inherited from cmlabs::Runnable
 Runnable ()
 Initialise flags: not running, allowed to continue.
virtual ~Runnable ()
 Destructor requests a stop (with the default timeout) before destruction proceeds.
virtual bool stop (uint32 timeout=200)
 Ask the worker loop to finish and wait for it to do so.
Public Member Functions inherited from cmlabs::NetworkReceiver
 NetworkReceiver ()
virtual bool receiveTelnetLine (TelnetLine *line, NetworkChannel *channel, uint64 conid)
 A Telnet line arrived.
virtual bool receiveHTTPReply (HTTPReply *reply, HTTPRequest *req, NetworkChannel *channel, uint64 conid)
 An HTTP reply to an earlier async request arrived.

Static Public Member Functions

static bool UnitTest (uint16 port, uint32 executorCount, uint32 gatewayCount, uint32 clientCount, uint32 webCount, uint32 webSocketCount, double sendfreq, int32 reconnect, uint32 payload, uint32 processTime, uint32 runtime)
 End-to-end stress test spinning up a gateway plus the given numbers of executors, extra gateways and binary/web/websocket test clients.

Protected Member Functions

bool runExec ()
 Executor-side worker loop: dispatch queued requests, watch heartbeats, redistribute dead executors' work.
bool runClient ()
 Client-side worker loop: route replies back to callers, expire timed-out requests.
bool callInternalAPI (const char *apiName, HTTPRequest *req, NetworkChannel *channel, uint64 conid)
 Handle a management/API call on the internal API label.
bool callExternalAPI (const char *apiName, HTTPRequest *req, NetworkChannel *channel, uint64 conid)
 Handle a public API call on the external API label.
bool sendRestartToExecutor (uint64 id)
 Ask an executor to restart itself (sent when it misbehaves).
bool distributeDeadExecutorRequests (std::list< RequestReply * > &shortQueue, std::list< RequestReply * > &longQueue)
 Requeue a dead executor's outstanding requests onto surviving executors.
uint64 getBestExecutorID (std::string requestString, uint32 reqSize, bool &isLongReq)
 Pick the executor to receive a request — the core load-balancing decision, based on reported queue sizes, rolling latency stats and liveness.
bool replyToClient (DataMessage *msg)
 Route a reply message back to the client that issued the request.
bool addToRequestQueue (DataMessage *msg, uint64 origin, uint64 conID, uint64 clientRef)
 Wrap an incoming message in a RequestReply and enqueue it for dispatch.
bool addRequestReplyToRequestQueue (RequestReply *reply)
 Enqueue an already-wrapped request (e.g.
bool addToCallLog (uint64 id, uint8 conType, uint8 messageType, bool longRequest, uint64 source, uint16 port, uint64 executorID, uint64 clientID, uint64 startTime, uint64 endTime, uint64 queueTime, uint64 processTime, uint8 requestType, uint32 requestSize, uint32 replySize, const char *status, const char *requestPath, const char *agent, const char *output)
 Append one completed call to the rolling call log (trimmed to ::callLogMax).

Protected Attributes

utils::Mutex callLogMutex
 Guards the call log.
std::list< CallLogEntry * > callLog
 Rolling log of completed calls (owned).
uint32 callLogMax
 Max entries kept in ::callLog.
uint64 callLogCount
 Total calls logged since start.
NetworkManagermanager
 Owned network stack (listeners + connections).
NetworkChannelchannel
 Channel carrying all gateway traffic.
std::map< uint64, RequestConnectionexecutors
 Connected executors by id.
std::map< uint64, RequestConnectionclients
 Connected binary clients by id.
std::map< uint64, RequestConnectionwebClients
 Connected HTTP clients by id.
std::map< uint64, RequestConnectionwebSockets
 Connected WebSocket clients by id.
utils::WaitQueue< RequestReply * > execQ
 Requests awaiting executor dispatch.
utils::WaitQueuePointer< DataMessage * > replyQ
 Replies awaiting client routing.
std::map< uint64, RequestReply * > requestMap
 In-flight requests by gateway ref id.
std::vector< std::string > longReqNames
 Request names classified as long.
std::map< std::string, uint64 > httpAuth
 Basic-auth users (user -> credential hash).
utils::Mutex mutex
 Guards shared gateway state.
uint64 systemStartTime
 Gateway start time (ms epoch), for uptime reporting.
uint32 threadIDClient
 Client-side worker thread id.
uint64 lastRefID
 Last issued gateway reference id.
uint64 clientSentCount
 Messages sent to clients.
uint64 clientReceivedCount
 Messages received from clients.
uint64 execSentCount
 Messages sent to executors.
uint64 execReceivedCount
 Messages received from executors.
uint32 id
 This gateway's id.
uint16 port
 Primary listening port.
uint32 longReqLimit
 Concurrent long-request cap per executor.
uint32 executorHeartbeatTimeout
 Silence threshold before an executor is declared dead (ms).
uint32 maxRequestQueueSize
 Backpressure: max queued requests before TOOBUSY.
uint32 maxRequestProcessingSize
 Backpressure: max requests dispatched concurrently.
uint32 priorityThreshold
 Queue length above which priority ordering applies.
uint32 maxExecutorRequestTimeoutMS
 Max time a request may sit with an executor (ms).
bool sslSupport
 True when an SSL certificate was configured.
bool cacheFiles
 Send caching headers for served files.
bool replyXML
 Reply in XML (true) or JSON (false).
std::string webServerName
 Server header name of the built-in web server.
std::string rootdir
 Document root for file serving.
std::string indexFilename
 Default index file name.
std::string versionString
 Version shown in status pages.
std::string internalAPITitle
 URI label of the internal (management) API.
std::string externalAPITitle
 URI label of the external (public) API.
MovingAverage shortAvgStats
 Rolling latency stats for short requests.
MovingAverage longAvgStats
 Rolling latency stats for long requests.
Protected Attributes inherited from cmlabs::Runnable
uint32 threadID
 ThreadManager slot ID of the worker thread (0 until known).
bool shouldContinue
 Loop-continuation flag; cleared by stop().
bool isRunning
 Set by the worker while its loop is active.

Friends

THREAD_RET THREAD_FUNCTION_CALL RequestGatewayExecRun (THREAD_ARG arg)
 Thread entry point for the gateway's executor-side loop.
THREAD_RET THREAD_FUNCTION_CALL RequestGatewayClientRun (THREAD_ARG arg)
 Thread entry point for the gateway's client-side loop.

Detailed Description

The request-fabric router/load-balancer (see the file header for the full role description).

Runs two worker threads: one servicing executor traffic (runExec()) and one servicing client traffic (runClient()). All ingress arrives through the NetworkReceiver callbacks below; ports are added with addPort() and may simultaneously carry binary, HTTP and WebSocket traffic thanks to protocol auto-detection.

Thread-safety
Configuration methods (set* and add*) should be called before init(); the receive*() callbacks run concurrently on connection threads and are internally synchronised.

Definition at line 138 of file RequestGateway.h.

Constructor & Destructor Documentation

◆ RequestGateway()

◆ ~RequestGateway()

Member Function Documentation

◆ addAuthUser()

bool cmlabs::RequestGateway::addAuthUser ( const char * user,
const char * password )

Add a basic-auth user for the web interface/APIs.

Parameters
userUsername.
passwordPassword.
Returns
true.

Definition at line 493 of file RequestGateway.cpp.

References base64_encode(), cmlabs::GetTimeNow(), httpAuth, and cmlabs::utils::StringFormat().

◆ addGateway()

bool cmlabs::RequestGateway::addGateway ( uint32 id,
std::string addr,
uint16 port )

Register a peer gateway (multi-gateway federation).

Parameters
idGateway id.
addrHost.
portPort.
Returns
true.

Definition at line 503 of file RequestGateway.cpp.

References port.

◆ addPort()

bool cmlabs::RequestGateway::addPort ( uint16 port,
uint8 encryption,
bool enableHTTP = false,
uint32 timeout = 3000 )

Open a listening port for clients/executors (call before init()).

Parameters
portTCP port.
encryptionNOENC or SSLENC.
enableHTTPAlso accept HTTP/WebSocket on this port when true.
timeoutProtocol auto-detection timeout in ms.
Returns
true on success.

Definition at line 448 of file RequestGateway.cpp.

References channel, LOG_SYSTEM, LogPrint, manager, mutex, port, PROTOCOL_HTTP_SERVER, PROTOCOL_MESSAGE, SSLENC, and sslSupport.

Referenced by UnitTest().

◆ addRequestReplyToRequestQueue()

◆ addToCallLog()

bool cmlabs::RequestGateway::addToCallLog ( uint64 id,
uint8 conType,
uint8 messageType,
bool longRequest,
uint64 source,
uint16 port,
uint64 executorID,
uint64 clientID,
uint64 startTime,
uint64 endTime,
uint64 queueTime,
uint64 processTime,
uint8 requestType,
uint32 requestSize,
uint32 replySize,
const char * status,
const char * requestPath,
const char * agent,
const char * output )
protected

◆ addToRequestQueue()

bool cmlabs::RequestGateway::addToRequestQueue ( DataMessage * msg,
uint64 origin,
uint64 conID,
uint64 clientRef )
protected

Wrap an incoming message in a RequestReply and enqueue it for dispatch.

Parameters
msgRequest message (ownership transfers).
originCaller endpoint.
conIDIngress connection id.
clientRefCaller's reference id.
Returns
true if queued (false when over ::maxRequestQueueSize).

Definition at line 642 of file RequestGateway.cpp.

References addRequestReplyToRequestQueue(), clientReceivedCount, cmlabs::RequestReply::clientRef, cmlabs::RequestReply::gatewayRef, GETIPADDRESSQUADPORT, cmlabs::RequestReply::giveRequestMessage(), lastRefID, cmlabs::RequestReply::origin, cmlabs::QUEUED, requestMap, cmlabs::DataMessage::setReference(), cmlabs::RequestReply::setStatus(), cmlabs::DataMessage::setString(), and cmlabs::utils::StringFormat().

Referenced by callExternalAPI(), receiveMessage(), and receiveWebsocketData().

◆ callExternalAPI()

bool cmlabs::RequestGateway::callExternalAPI ( const char * apiName,
HTTPRequest * req,
NetworkChannel * channel,
uint64 conid )
protected

◆ callInternalAPI()

◆ distributeDeadExecutorRequests()

bool cmlabs::RequestGateway::distributeDeadExecutorRequests ( std::list< RequestReply * > & shortQueue,
std::list< RequestReply * > & longQueue )
protected

Requeue a dead executor's outstanding requests onto surviving executors.

Parameters
shortQueueIts short-request backlog.
longQueueIts long-request backlog.
Returns
true on success.

Definition at line 2412 of file RequestGateway.cpp.

References addRequestReplyToRequestQueue(), executors, cmlabs::QUEUED, and cmlabs::RequestReply::setStatus().

Referenced by runExec().

◆ getBestExecutorID()

uint64 cmlabs::RequestGateway::getBestExecutorID ( std::string requestString,
uint32 reqSize,
bool & isLongReq )
protected

Pick the executor to receive a request — the core load-balancing decision, based on reported queue sizes, rolling latency stats and liveness.

Parameters
requestStringRequest name (matched against long-request names).
reqSizePayload size.
isLongReqOut: classification result.
Returns
The chosen executor id, or 0 when none is available.

Definition at line 1798 of file RequestGateway.cpp.

References executors, longReqLimit, longReqNames, MAXVALUINT32, and cmlabs::utils::stristr().

Referenced by addRequestReplyToRequestQueue().

◆ init()

bool cmlabs::RequestGateway::init ( const char * sslCertPath = NULL,
const char * sslKeyPath = NULL )

Start the gateway threads and network stack.

Parameters
sslCertPathOptional PEM certificate enabling SSL ports.
sslKeyPathMatching PEM private key.
Returns
true on success. Call after the set*() and add*() configuration calls.

Definition at line 367 of file RequestGateway.cpp.

References cmlabs::ThreadManager::CreateThread(), LOG_SYSTEM, LogPrint, manager, mutex, RequestGatewayClientRun, RequestGatewayExecRun, cmlabs::Runnable::shouldContinue, sslSupport, cmlabs::Runnable::threadID, and threadIDClient.

Referenced by UnitTest().

◆ receiveHTTPRequest()

◆ receiveMessage()

◆ receiveNetworkEvent()

bool cmlabs::RequestGateway::receiveNetworkEvent ( NetworkEvent * evt,
NetworkChannel * channel,
uint64 conid )
virtual

NetworkReceiver hook: connect/disconnect events for clients and executors.

Reimplemented from cmlabs::NetworkReceiver.

Definition at line 507 of file RequestGateway.cpp.

References channel, clients, executors, cmlabs::GetTimeNow(), mutex, NETWORKEVENT_DISCONNECT, NETWORKEVENT_RECONNECT, cmlabs::NetworkEvent::type, webClients, and webSockets.

◆ receiveWebsocketData()

◆ replyToClient()

◆ runClient()

bool cmlabs::RequestGateway::runClient ( )
protected

Client-side worker loop: route replies back to callers, expire timed-out requests.

Returns
true to continue.

Definition at line 2440 of file RequestGateway.cpp.

References clients, cmlabs::GetTimeAgeMS(), cmlabs::GetTimeNow(), cmlabs::Runnable::isRunning, replyQ, replyToClient(), and cmlabs::Runnable::shouldContinue.

Referenced by RequestGatewayClientRun.

◆ runExec()

◆ sendRestartToExecutor()

bool cmlabs::RequestGateway::sendRestartToExecutor ( uint64 id)
protected

Ask an executor to restart itself (sent when it misbehaves).

Returns
true if sent.

Definition at line 1955 of file RequestGateway.cpp.

References channel, executors, and cmlabs::DataMessage::setString().

Referenced by callInternalAPI(), and runExec().

◆ setCacheFiles()

bool cmlabs::RequestGateway::setCacheFiles ( bool cache)

Enable/disable HTTP caching headers for served files.

Returns
true.

Definition at line 436 of file RequestGateway.cpp.

References cacheFiles.

◆ setExecutorHeartbeatTimeout()

bool cmlabs::RequestGateway::setExecutorHeartbeatTimeout ( uint32 timeout)

Set how long an executor may go silent before being declared dead (its queue is then redistributed).

Parameters
timeoutms.
Returns
true.

Definition at line 395 of file RequestGateway.cpp.

References executorHeartbeatTimeout.

◆ setExternalAPILabel()

bool cmlabs::RequestGateway::setExternalAPILabel ( const char * label)

Set the URI label under which the external (public) API is exposed.

Returns
true.

Definition at line 422 of file RequestGateway.cpp.

References externalAPITitle.

◆ setInternalAPILabel()

bool cmlabs::RequestGateway::setInternalAPILabel ( const char * label)

Set the URI label under which the internal (management) API is exposed.

Returns
true.

Definition at line 429 of file RequestGateway.cpp.

References internalAPITitle.

◆ setLongRequestLimit()

bool cmlabs::RequestGateway::setLongRequestLimit ( uint32 limit)

Cap concurrent long requests per executor.

Parameters
limitMaximum.
Returns
true.

Definition at line 1784 of file RequestGateway.cpp.

References longReqLimit.

◆ setMaxExecutorRequestTimeout()

bool cmlabs::RequestGateway::setMaxExecutorRequestTimeout ( uint32 timeout)

Set the maximum time a request may sit with an executor before being failed/retried.

Parameters
timeoutms.
Returns
true.

Definition at line 400 of file RequestGateway.cpp.

References maxExecutorRequestTimeoutMS.

◆ setQueuingParameters()

bool cmlabs::RequestGateway::setQueuingParameters ( uint32 maxRequestQueueSize,
uint32 maxRequestProcessingSize,
uint32 priorityThreshold )

Tune queuing/backpressure behaviour.

Parameters
maxRequestQueueSizeMax queued requests before rejecting with TOOBUSY.
maxRequestProcessingSizeMax requests dispatched concurrently.
priorityThresholdQueue length above which priority ordering kicks in.
Returns
true.

Definition at line 441 of file RequestGateway.cpp.

References maxRequestProcessingSize, maxRequestQueueSize, and priorityThreshold.

◆ setResponseType()

bool cmlabs::RequestGateway::setResponseType ( const char * type)

Choose the reply serialisation ("xml" or "json").

Returns
true.

Definition at line 405 of file RequestGateway.cpp.

References replyXML.

Referenced by UnitTest().

◆ setWebServerInfo()

bool cmlabs::RequestGateway::setWebServerInfo ( const char * name,
const char * rootdir,
const char * indexfile )

Configure the built-in file web server.

Parameters
nameServer header name.
rootdirDocument root directory.
indexfileDefault index filename.
Returns
true on success.

Definition at line 412 of file RequestGateway.cpp.

References indexFilename, rootdir, and webServerName.

Referenced by UnitTest().

◆ UnitTest()

bool cmlabs::RequestGateway::UnitTest ( uint16 port,
uint32 executorCount,
uint32 gatewayCount,
uint32 clientCount,
uint32 webCount,
uint32 webSocketCount,
double sendfreq,
int32 reconnect,
uint32 payload,
uint32 processTime,
uint32 runtime )
static

End-to-end stress test spinning up a gateway plus the given numbers of executors, extra gateways and binary/web/websocket test clients.

Parameters
portBase port.
executorCountExecutors.
gatewayCountGateways.
clientCountBinary clients.
webCountHTTP clients.
webSocketCountWebSocket clients.
sendfreqRequests per second per client.
reconnectClient reconnect interval (ms; <0 = never).
payloadRequest payload size in bytes.
processTimeSimulated executor processing time (ms).
runtimeTest duration (s).
Returns
true when the run completes without errors.

Definition at line 2492 of file RequestGateway.cpp.

References cmlabs::RequestClient::addGateway(), cmlabs::RequestExecutor::addGateway(), cmlabs::RequestExecutor::addLongRequestName(), addPort(), clients, cmlabs::unittest::detail(), executors, cmlabs::unittest::fail(), cmlabs::RequestClient::finishRequest(), cmlabs::RequestReply::getRequestDuration(), cmlabs::GetTimeAgeMS(), cmlabs::GetTimeNow(), init(), cmlabs::TestRequestClient::init(), cmlabs::TestWebRequestClient::init(), cmlabs::TestWebSocketRequestClient::init(), cmlabs::unittest::metric(), NOENC, port, cmlabs::RequestClient::postRequest(), cmlabs::PrintTimeDifString(), cmlabs::unittest::progress(), RequestGateway(), setResponseType(), cmlabs::DataMessage::setString(), setWebServerInfo(), cmlabs::utils::Sleep(), SSLENC, cmlabs::SUCCESS, cmlabs::RequestClient::waitForConnection(), and cmlabs::RequestReply::waitForResult().

Referenced by cmlabs::Test_RequestGateway().

◆ RequestGatewayClientRun

THREAD_RET THREAD_FUNCTION_CALL RequestGatewayClientRun ( THREAD_ARG arg)
friend

Thread entry point for the gateway's client-side loop.

Definition at line 2470 of file RequestGateway.cpp.

References RequestGateway(), runClient(), THREAD_ARG, THREAD_FUNCTION_CALL, THREAD_RET, and thread_ret_val.

Referenced by init().

◆ RequestGatewayExecRun

THREAD_RET THREAD_FUNCTION_CALL RequestGatewayExecRun ( THREAD_ARG arg)
friend

Thread entry point for the gateway's executor-side loop.

Definition at line 2465 of file RequestGateway.cpp.

References RequestGateway(), runExec(), THREAD_ARG, THREAD_FUNCTION_CALL, THREAD_RET, and thread_ret_val.

Referenced by init().

Member Data Documentation

◆ cacheFiles

bool cmlabs::RequestGateway::cacheFiles
protected

Send caching headers for served files.

Definition at line 308 of file RequestGateway.h.

Referenced by callInternalAPI(), receiveHTTPRequest(), RequestGateway(), and setCacheFiles().

◆ callLog

std::list<CallLogEntry*> cmlabs::RequestGateway::callLog
protected

Rolling log of completed calls (owned).

Definition at line 273 of file RequestGateway.h.

Referenced by addToCallLog(), and callInternalAPI().

◆ callLogCount

uint64 cmlabs::RequestGateway::callLogCount
protected

Total calls logged since start.

Definition at line 275 of file RequestGateway.h.

Referenced by callInternalAPI(), receiveHTTPRequest(), replyToClient(), and RequestGateway().

◆ callLogMax

uint32 cmlabs::RequestGateway::callLogMax
protected

Max entries kept in ::callLog.

Definition at line 274 of file RequestGateway.h.

Referenced by addToCallLog(), and RequestGateway().

◆ callLogMutex

utils::Mutex cmlabs::RequestGateway::callLogMutex
protected

Guards the call log.

Definition at line 272 of file RequestGateway.h.

Referenced by addToCallLog(), and callInternalAPI().

◆ channel

NetworkChannel* cmlabs::RequestGateway::channel
protected

◆ clientReceivedCount

uint64 cmlabs::RequestGateway::clientReceivedCount
protected

Messages received from clients.

Definition at line 295 of file RequestGateway.h.

Referenced by addToRequestQueue(), and RequestGateway().

◆ clients

std::map<uint64,RequestConnection> cmlabs::RequestGateway::clients
protected

◆ clientSentCount

uint64 cmlabs::RequestGateway::clientSentCount
protected

Messages sent to clients.

Definition at line 294 of file RequestGateway.h.

Referenced by replyToClient(), and RequestGateway().

◆ execQ

utils::WaitQueue<RequestReply*> cmlabs::RequestGateway::execQ
protected

Requests awaiting executor dispatch.

Definition at line 283 of file RequestGateway.h.

Referenced by addRequestReplyToRequestQueue(), and runExec().

◆ execReceivedCount

uint64 cmlabs::RequestGateway::execReceivedCount
protected

Messages received from executors.

Definition at line 297 of file RequestGateway.h.

Referenced by receiveMessage(), and RequestGateway().

◆ execSentCount

uint64 cmlabs::RequestGateway::execSentCount
protected

Messages sent to executors.

Definition at line 296 of file RequestGateway.h.

Referenced by RequestGateway(), and runExec().

◆ executorHeartbeatTimeout

uint32 cmlabs::RequestGateway::executorHeartbeatTimeout
protected

Silence threshold before an executor is declared dead (ms).

Definition at line 302 of file RequestGateway.h.

Referenced by RequestGateway(), runExec(), and setExecutorHeartbeatTimeout().

◆ executors

std::map<uint64,RequestConnection> cmlabs::RequestGateway::executors
protected

◆ externalAPITitle

std::string cmlabs::RequestGateway::externalAPITitle
protected

URI label of the external (public) API.

Definition at line 317 of file RequestGateway.h.

Referenced by receiveHTTPRequest(), RequestGateway(), and setExternalAPILabel().

◆ httpAuth

std::map<std::string, uint64> cmlabs::RequestGateway::httpAuth
protected

Basic-auth users (user -> credential hash).

Definition at line 287 of file RequestGateway.h.

Referenced by addAuthUser(), and callInternalAPI().

◆ id

uint32 cmlabs::RequestGateway::id
protected

This gateway's id.

Definition at line 299 of file RequestGateway.h.

◆ indexFilename

std::string cmlabs::RequestGateway::indexFilename
protected

Default index file name.

Definition at line 313 of file RequestGateway.h.

Referenced by callInternalAPI(), receiveHTTPRequest(), and setWebServerInfo().

◆ internalAPITitle

std::string cmlabs::RequestGateway::internalAPITitle
protected

URI label of the internal (management) API.

Definition at line 316 of file RequestGateway.h.

Referenced by receiveHTTPRequest(), RequestGateway(), and setInternalAPILabel().

◆ lastRefID

uint64 cmlabs::RequestGateway::lastRefID
protected

Last issued gateway reference id.

Definition at line 293 of file RequestGateway.h.

Referenced by addToRequestQueue(), and RequestGateway().

◆ longAvgStats

MovingAverage cmlabs::RequestGateway::longAvgStats
protected

Rolling latency stats for long requests.

Definition at line 320 of file RequestGateway.h.

Referenced by callInternalAPI(), and replyToClient().

◆ longReqLimit

uint32 cmlabs::RequestGateway::longReqLimit
protected

Concurrent long-request cap per executor.

Definition at line 301 of file RequestGateway.h.

Referenced by getBestExecutorID(), RequestGateway(), and setLongRequestLimit().

◆ longReqNames

std::vector<std::string> cmlabs::RequestGateway::longReqNames
protected

Request names classified as long.

Definition at line 286 of file RequestGateway.h.

Referenced by getBestExecutorID(), and receiveMessage().

◆ manager

NetworkManager* cmlabs::RequestGateway::manager
protected

Owned network stack (listeners + connections).

Definition at line 277 of file RequestGateway.h.

Referenced by addPort(), init(), RequestGateway(), and ~RequestGateway().

◆ maxExecutorRequestTimeoutMS

uint32 cmlabs::RequestGateway::maxExecutorRequestTimeoutMS
protected

Max time a request may sit with an executor (ms).

Definition at line 306 of file RequestGateway.h.

Referenced by RequestGateway(), runExec(), and setMaxExecutorRequestTimeout().

◆ maxRequestProcessingSize

uint32 cmlabs::RequestGateway::maxRequestProcessingSize
protected

Backpressure: max requests dispatched concurrently.

Definition at line 304 of file RequestGateway.h.

Referenced by addRequestReplyToRequestQueue(), callInternalAPI(), RequestGateway(), runExec(), and setQueuingParameters().

◆ maxRequestQueueSize

uint32 cmlabs::RequestGateway::maxRequestQueueSize
protected

Backpressure: max queued requests before TOOBUSY.

Definition at line 303 of file RequestGateway.h.

Referenced by addRequestReplyToRequestQueue(), callInternalAPI(), RequestGateway(), and setQueuingParameters().

◆ mutex

utils::Mutex cmlabs::RequestGateway::mutex
protected

◆ port

uint16 cmlabs::RequestGateway::port
protected

Primary listening port.

Definition at line 300 of file RequestGateway.h.

Referenced by addGateway(), addPort(), addToCallLog(), callInternalAPI(), and UnitTest().

◆ priorityThreshold

uint32 cmlabs::RequestGateway::priorityThreshold
protected

Queue length above which priority ordering applies.

Definition at line 305 of file RequestGateway.h.

Referenced by addRequestReplyToRequestQueue(), RequestGateway(), and setQueuingParameters().

◆ replyQ

utils::WaitQueuePointer<DataMessage*> cmlabs::RequestGateway::replyQ
protected

Replies awaiting client routing.

Definition at line 284 of file RequestGateway.h.

Referenced by addRequestReplyToRequestQueue(), receiveMessage(), runClient(), and runExec().

◆ replyXML

bool cmlabs::RequestGateway::replyXML
protected

Reply in XML (true) or JSON (false).

Definition at line 309 of file RequestGateway.h.

Referenced by addRequestReplyToRequestQueue(), callInternalAPI(), RequestGateway(), runExec(), and setResponseType().

◆ requestMap

std::map<uint64,RequestReply*> cmlabs::RequestGateway::requestMap
protected

In-flight requests by gateway ref id.

Definition at line 285 of file RequestGateway.h.

Referenced by addToRequestQueue(), receiveMessage(), replyToClient(), runExec(), and ~RequestGateway().

◆ rootdir

std::string cmlabs::RequestGateway::rootdir
protected

Document root for file serving.

Definition at line 312 of file RequestGateway.h.

Referenced by callInternalAPI(), receiveHTTPRequest(), and setWebServerInfo().

◆ shortAvgStats

MovingAverage cmlabs::RequestGateway::shortAvgStats
protected

Rolling latency stats for short requests.

Definition at line 319 of file RequestGateway.h.

Referenced by callInternalAPI(), and replyToClient().

◆ sslSupport

bool cmlabs::RequestGateway::sslSupport
protected

True when an SSL certificate was configured.

Definition at line 307 of file RequestGateway.h.

Referenced by addPort(), init(), and RequestGateway().

◆ systemStartTime

uint64 cmlabs::RequestGateway::systemStartTime
protected

Gateway start time (ms epoch), for uptime reporting.

Definition at line 291 of file RequestGateway.h.

Referenced by callInternalAPI(), and RequestGateway().

◆ threadIDClient

uint32 cmlabs::RequestGateway::threadIDClient
protected

Client-side worker thread id.

Definition at line 292 of file RequestGateway.h.

Referenced by init(), RequestGateway(), and ~RequestGateway().

◆ versionString

std::string cmlabs::RequestGateway::versionString
protected

Version shown in status pages.

Definition at line 314 of file RequestGateway.h.

Referenced by callInternalAPI(), and RequestGateway().

◆ webClients

std::map<uint64,RequestConnection> cmlabs::RequestGateway::webClients
protected

Connected HTTP clients by id.

Definition at line 281 of file RequestGateway.h.

Referenced by addRequestReplyToRequestQueue(), callExternalAPI(), callInternalAPI(), receiveNetworkEvent(), replyToClient(), and runExec().

◆ webServerName

std::string cmlabs::RequestGateway::webServerName
protected

Server header name of the built-in web server.

Definition at line 311 of file RequestGateway.h.

Referenced by callInternalAPI(), receiveHTTPRequest(), replyToClient(), RequestGateway(), and setWebServerInfo().

◆ webSockets

std::map<uint64,RequestConnection> cmlabs::RequestGateway::webSockets
protected

Connected WebSocket clients by id.

Definition at line 282 of file RequestGateway.h.

Referenced by addRequestReplyToRequestQueue(), callInternalAPI(), receiveNetworkEvent(), receiveWebsocketData(), replyToClient(), and runExec().


The documentation for this class was generated from the following files: