Singleton. Creates an HTTP REST server to register newly created EngineJSONServers and store their addresses.
More...
#include <engine_json_registration_server.h>
|
static constexpr std::string_view | JSONEngineName = "engine_name" |
| JSON Engine Name locator used during registration. More...
|
|
static constexpr std::string_view | JSONAddress = "address" |
| JSON Engine Address locator used during registration. More...
|
|
Singleton. Creates an HTTP REST server to register newly created EngineJSONServers and store their addresses.
◆ EngineJSONRegistrationServer() [1/2]
◆ EngineJSONRegistrationServer() [2/2]
◆ ~EngineJSONRegistrationServer()
EngineJSONRegistrationServer::~EngineJSONRegistrationServer |
( |
| ) |
|
◆ clearInstance()
void EngineJSONRegistrationServer::clearInstance |
( |
| ) |
|
|
static |
◆ getInstance()
◆ getNumWaitingEngines()
size_t EngineJSONRegistrationServer::getNumWaitingEngines |
( |
| ) |
|
Get the number of engines that are still waiting for registration.
◆ isRunning()
bool EngineJSONRegistrationServer::isRunning |
( |
| ) |
const |
Returns true when server is running, false otherwise.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ registerEngineAddress()
void EngineJSONRegistrationServer::registerEngineAddress |
( |
const engine_name_t & |
engineName, |
|
|
const std::string & |
address |
|
) |
| |
Register an engine's address.
- Parameters
-
engineName | Name of engine |
address | Address of engine |
◆ requestEngine()
std::string EngineJSONRegistrationServer::requestEngine |
( |
const engine_name_t & |
engineName | ) |
|
Request an engine's address. If available, erases entry from _registeredAddresses.
- Parameters
-
engineName | Name of engine to wait for |
- Returns
- If available, returns name of engine. Else, returns empty string
◆ resetInstance()
Reset EngineJSONRegistrationServer with the given address.
- Parameters
-
serverAddress | Server Address to bind to |
- Returns
- Returns pointer to created instance
◆ retrieveEngineAddress()
std::string EngineJSONRegistrationServer::retrieveEngineAddress |
( |
const engine_name_t & |
engineName | ) |
|
Retrieve a registered engine address. If available and non-empty, erase it from _registeredAddresses.
- Parameters
-
engineName | Engine Name for which to find the address |
- Returns
- If address available, return it. Otherwise return empty string
◆ sendClientEngineRequest()
bool EngineJSONRegistrationServer::sendClientEngineRequest |
( |
const std::string & |
address, |
|
|
const engine_name_t & |
engineName, |
|
|
const std::string & |
engineAddress, |
|
|
const unsigned int |
numTries = 1 , |
|
|
const unsigned int |
waitTime = 0 |
|
) |
| |
|
static |
Send Engine Name and address to specified address.
- Parameters
-
address | Address to send data to |
engineName | Name of engine |
engineAddress | Address of engine |
numTries | Number of times to try and contact the registration server |
waitTime | Time (in seconds) to wait between contact attempts |
- Returns
- Returns true on success, false otherwise
◆ serverAddress()
const std::string EngineJSONRegistrationServer::serverAddress |
( |
| ) |
const |
◆ shutdownServer()
void EngineJSONRegistrationServer::shutdownServer |
( |
| ) |
|
◆ startServerAsync()
void EngineJSONRegistrationServer::startServerAsync |
( |
| ) |
|
Start the server if it's not already running.
◆ tryInstantiate()
std::string EngineJSONRegistrationServer::tryInstantiate |
( |
const std::string & |
initialAddress, |
|
|
const unsigned |
numRetries = 0 |
|
) |
| |
|
static |
Attempts to instantiate and start the registration server.
- Parameters
-
initialAddress | Initial address that the server will try to use |
numRetries | Maximum number of attempts to start the server |
- Returns
- The actual address of the server. If the first attempt to start was successful, then it will be the initialAddress. Otherwise, the address will consist of the hostname from the initialAddress and a random port.
- Exceptions
-
When | numRetires has been exceeded. |
The function will try to start the registration server at the given address. If the initial attempt fails, then the function will try again, until numRetries limit is exceeded. On every attempt, except for the first one, the address will be modified. The host will be taken from the initialAddress argument, but the port will be changed - the function will ask the OS to provide an unused port for the server.
◆ EngineJSONRegistrationServer::RequestHandler
friend struct EngineJSONRegistrationServer::RequestHandler |
|
friend |
◆ JSONAddress
constexpr std::string_view EngineJSONRegistrationServer::JSONAddress = "address" |
|
staticconstexpr |
JSON Engine Address locator used during registration.
◆ JSONEngineName
constexpr std::string_view EngineJSONRegistrationServer::JSONEngineName = "engine_name" |
|
staticconstexpr |
JSON Engine Name locator used during registration.
The documentation for this class was generated from the following files: