CommonBackend

The class CommonBackend contains handlers and general logic for interacting with the NextGen Archiver (NGA) Manager.

The following methods of the CommonBackend class are mandatory:

  • startReadAndWriteThread - Starts threads to process read and write messages.
    commonBackend.startReadAndWriteThread();
  • waitForDone - Waits for the read, write, and channel-serving threads to complete. The call of this function is necessary for the correct completion of an instance of the CommonBackend class.
    commonBackend.waitForDone();
  • getConfigChannelHandlerUnprepared - Gets the config channel handler object, but it does not make sure that it is actually in a usable state.
    commonBackend.getConfigChannelHandlerUnprepared();
  • runCommonBackendWithConfigChannelOnly - Runs the configuration channel thread only for synchronous requests to get configuration settings without triggering read-write processing. When calling this function, you need to start the read-write processing threads using the startReadAndWriteThread. Call startReadAndWriteThread only after the configuration has been received. The third parameter serverPublicKey is optional and can be used to pass a public key for encrypted communication with the NGA Manager.
    auto& configChannelHandler = commonBackend.runCommonBackendWithConfigChannelOnly(zmqAddress, pollingInterval,serverPublicKey);
  • onConnectionLost - Sets up a callback to handle the loss of communication with the NGA Manager. The doExit flag defines the backend shutdown event. When starting the backend, this flag is set to false.
    commonBackend.onConnectionLost([&]()
    {
        logDebug("Connection to the frontend lost, the backend will exit.");
        doExit = true;
    });
  • onWriteRequest - Sets up a callback function responsible for writing. This callback function should return a write success flag (see Write handler).
  • onReadRequest - Sets up a callback function responsible for reading (see Read handler).
  • makeReadResponseSender - Creates an instance of the ReadResponseSender class to send the read result to the NGA Manager. (see Read handler).
  • getLoggingInterface - Gets an instance of LogMessageQueue class for logging messages to the NGA Manager.
    LogMessageQueue& logMessageQueue = commonBackend.getLoggingInterface();
    logMessageQueue.queueLogMessage(ErrorMessageFromBackend_Priority_Information, message, std::string(), 0);