23#if !defined(_REQUESTEXECUTOR_H_)
24#define _REQUESTEXECUTOR_H_
90 bool addGateway(uint32
id, std::string addr, uint16 port, uint8 encryption =
NOENC);
#define NOENC
Plain, unencrypted transport.
Connection/channel management layer: multi-protocol listeners, typed dispatch, HTTP client — and the ...
Request-system client side: RequestReply futures, RequestQueue, gateway connection records and the Re...
#define THREAD_FUNCTION_CALL
The central Psyclone data container: a self-contained binary message with typed, named user entries.
A parsed or generated HTTP request (also used for WebSocket upgrade handshakes).
One logical network interface: a group of listeners/connections with shared dispatch.
Central owner of all channels, listeners and connections in a process.
uint64 lastHeartbeat
Time of last heartbeat (ms epoch).
uint64 longReceivedCount
Total long requests received.
uint32 sendStatusNow()
Send a status heartbeat (queue sizes) to all gateways.
bool replyToQuery(DataMessage *msg)
Send a reply for a previously pulled request back to its gateway.
bool shutdownNetwork()
Disconnect from all gateways and stop the network stack.
utils::WaitQueuePointer< DataMessage * > replyQ
Outgoing replies awaiting dispatch.
utils::Semaphore shortExecQSemaphore
Signals short-queue arrivals.
DataMessage * waitForShortRequest(uint32 timeoutMS)
Pull the next short request (worker thread API).
utils::Mutex mutex
Guards request bookkeeping.
NetworkManager * manager
Owned network stack.
bool replyToGateway(DataMessage *msg)
Route a finished reply to the gateway that sent the request.
std::string executorName
Display name for logging.
bool run()
Worker loop: gateway upkeep, heartbeats, reply dispatch.
uint32 threadID
Worker thread id.
uint64 shortReceivedCount
Total short requests received.
utils::WaitQueuePointer< DataMessage * > shortExecQ
Pending short requests.
int32 heartbeatIntervalMS
Interval between status heartbeats (ms).
std::map< uint64, RequestReply * > requestMap
In-flight request bookkeeping by ref id.
bool receiveMessage(DataMessage *msg, NetworkChannel *channel, uint64 conid)
NetworkReceiver hook: incoming request messages, routed to the short/long queue.
uint64 sentCount
Total messages sent to gateways.
bool receiveHTTPRequest(HTTPRequest *req, NetworkChannel *channel, uint64 conid)
HTTP is not served by executors; always returns false.
bool addGateway(uint32 id, std::string addr, uint16 port, uint8 encryption=NOENC)
Register a gateway to connect to (repeatable for redundancy).
DataMessage * waitForLongRequest(uint32 timeoutMS)
Pull the next long request (worker thread API).
bool setLongRequestLimit(uint32 limit)
Cap the number of long requests processed concurrently.
utils::Mutex conMutex
Guards connections.
std::vector< std::string > longReqNames
Request names classified as long.
bool receiveNetworkEvent(NetworkEvent *evt, NetworkChannel *channel, uint64 conid)
NetworkReceiver hook: gateway connect/disconnect events (drives reconnection).
bool sendMessageToGateway(DataMessage *msg, RequestGatewayConnection &con)
Send a message on one gateway link.
NetworkChannel * channel
Channel carrying the gateway links.
uint32 executorID
Numeric id reported to gateways.
utils::Semaphore longExecQSemaphore
Signals long-queue arrivals.
utils::WaitQueuePointer< DataMessage * > longExecQ
Pending long requests.
std::list< RequestGatewayConnection > connections
Configured gateways and their state.
uint32 longReqLimit
Max concurrent long requests (see setLongRequestLimit()).
virtual ~RequestExecutor()
uint64 lastRefID
Last issued executor reference id.
bool addLongRequestName(const char *name)
Register a request name to be treated as a long-running request.
friend THREAD_RET THREAD_FUNCTION_CALL RequestExecutorRun(THREAD_ARG arg)
Thread entry point for the RequestExecutor worker loop.
RequestExecutor(uint32 id=0, const char *name=NULL)
uint64 repliedCount
Total replies sent.
Runnable()
Initialise flags: not running, allowed to continue.
friend THREAD_RET THREAD_FUNCTION_CALL ShortExecutorRun(THREAD_ARG arg)
TestRequestExecutor(uint32 id, uint32 processTimeMS)
friend THREAD_RET THREAD_FUNCTION_CALL LongExecutorRun(THREAD_ARG arg)
Recursive mutual-exclusion lock, optionally named for cross-process use.
Counting semaphore, optionally named for cross-process use.
WaitQueue specialization for owned heap pointers: clear()/destructor delete remaining entries.
THREAD_RET THREAD_FUNCTION_CALL RequestExecutorRun(THREAD_ARG arg)
Thread entry point for the RequestExecutor worker loop.
THREAD_RET THREAD_FUNCTION_CALL ShortExecutorRun(THREAD_ARG arg)
THREAD_RET THREAD_FUNCTION_CALL LongExecutorRun(THREAD_ARG arg)
Notification of a connection lifecycle change (connect, disconnect, buffer state.....
Client/executor-side record of one gateway it connects to.