refactor: Start WebServices and CoreFacade separately

This commit is contained in:
Lars Toenning
2024-02-15 21:01:12 +01:00
parent 9d3ae3e2b3
commit b939711058
2 changed files with 6 additions and 39 deletions

View File

@@ -808,12 +808,12 @@ namespace BlackCore
// now we can use settings // now we can use settings
// if not yet initialized, init web data services // if not yet initialized, init web data services
if (!m_useWebData) if (!m_webDataServices)
{ {
const CStatusMessageList msgs = this->useWebDataServices(CWebReaderFlags::AllReaders, CDatabaseReaderConfigList::forPilotClient()); const CStatusMessageList msgs = this->useWebDataServices(CWebReaderFlags::AllReaders, CDatabaseReaderConfigList::forPilotClient());
if (msgs.hasErrorMessages()) { return msgs; } if (msgs.hasErrorMessages()) { return msgs; }
} }
return this->startCoreFacadeAndWebDataServices(); // will do nothing if setup is not yet loaded return this->startCoreFacade(); // will do nothing if setup is not yet loaded
} }
CStatusMessageList CApplication::useFacadeNoContexts() CStatusMessageList CApplication::useFacadeNoContexts()
@@ -825,7 +825,7 @@ namespace BlackCore
const CStatusMessage msg = this->initLocalSettings(); const CStatusMessage msg = this->initLocalSettings();
if (msg.isFailure()) { return msg; } if (msg.isFailure()) { return msg; }
return this->startCoreFacadeAndWebDataServices(); // will do nothing if setup is not yet loaded return this->startCoreFacade(); // will do nothing if setup is not yet loaded
} }
CStatusMessageList CApplication::useWebDataServices(const CWebReaderFlags::WebReader webReaders, const CDatabaseReaderConfigList &dbReaderConfig) CStatusMessageList CApplication::useWebDataServices(const CWebReaderFlags::WebReader webReaders, const CDatabaseReaderConfigList &dbReaderConfig)
@@ -839,7 +839,6 @@ namespace BlackCore
m_webReadersUsed = webReaders; m_webReadersUsed = webReaders;
m_dbReaderConfig = dbReaderConfig; m_dbReaderConfig = dbReaderConfig;
m_useWebData = true;
return this->startWebDataServices(); return this->startWebDataServices();
} }
@@ -853,7 +852,7 @@ namespace BlackCore
return this->getIContextApplication() && !this->getIContextApplication()->isUsingImplementingObject() && !this->getIContextApplication()->isEmptyObject(); return this->getIContextApplication() && !this->getIContextApplication()->isUsingImplementingObject() && !this->getIContextApplication()->isEmptyObject();
} }
CStatusMessageList CApplication::startCoreFacadeAndWebDataServices() CStatusMessageList CApplication::startCoreFacade()
{ {
Q_ASSERT_X(m_parsed, Q_FUNC_INFO, "Call this function after parsing"); Q_ASSERT_X(m_parsed, Q_FUNC_INFO, "Call this function after parsing");
@@ -862,9 +861,7 @@ namespace BlackCore
Q_ASSERT_X(m_coreFacade.isNull(), Q_FUNC_INFO, "Cannot alter facade"); Q_ASSERT_X(m_coreFacade.isNull(), Q_FUNC_INFO, "Cannot alter facade");
Q_ASSERT_X(m_setupReader, Q_FUNC_INFO, "No facade without setup possible"); Q_ASSERT_X(m_setupReader, Q_FUNC_INFO, "No facade without setup possible");
Q_ASSERT_X(m_useWebData, Q_FUNC_INFO, "Need web data services"); Q_ASSERT_X(m_webDataServices, Q_FUNC_INFO, "Need running web data services");
this->startWebDataServices();
const CStatusMessageList msgs(CStatusMessage(this).info(u"Will start core facade now")); const CStatusMessageList msgs(CStatusMessage(this).info(u"Will start core facade now"));
m_coreFacade.reset(new CCoreFacade(m_coreFacadeConfig)); m_coreFacade.reset(new CCoreFacade(m_coreFacadeConfig));
@@ -876,7 +873,6 @@ namespace BlackCore
{ {
Q_ASSERT_X(m_parsed, Q_FUNC_INFO, "Call this function after parsing"); Q_ASSERT_X(m_parsed, Q_FUNC_INFO, "Call this function after parsing");
if (!m_useWebData) { return CStatusMessage(this).warning(u"No need to start web data services"); }
if (!m_setupReader || !m_setupReader->isSetupAvailable()) { return CStatusMessage(this).error(u"No setup reader or setup available"); } if (!m_setupReader || !m_setupReader->isSetupAvailable()) { return CStatusMessage(this).error(u"No setup reader or setup available"); }
Q_ASSERT_X(m_setupReader, Q_FUNC_INFO, "No web data services without setup possible"); Q_ASSERT_X(m_setupReader, Q_FUNC_INFO, "No web data services without setup possible");
@@ -1062,16 +1058,6 @@ namespace BlackCore
disconnect(this); disconnect(this);
} }
void CApplication::onSetupHandlingCompleted(bool available)
{
if (available)
{
// start follow ups when setup is avaialable
const CStatusMessageList msgs = this->asyncWebAndContextStart();
m_started = msgs.isSuccess();
}
}
void CApplication::onStartUpCompleted() void CApplication::onStartUpCompleted()
{ {
// void // void
@@ -1219,17 +1205,6 @@ namespace BlackCore
}); });
} }
CStatusMessageList CApplication::asyncWebAndContextStart()
{
if (m_started) { return CStatusMessage(this).info(u"Already started "); }
// follow up startups
CStatusMessageList msgs = this->startWebDataServices();
if (msgs.isFailure()) return msgs;
msgs.push_back(this->startCoreFacadeAndWebDataServices());
return msgs;
}
void CApplication::severeStartupProblem(const CStatusMessage &message) void CApplication::severeStartupProblem(const CStatusMessage &message)
{ {
CLogMessage::preformatted(message); CLogMessage::preformatted(message);
@@ -1617,7 +1592,6 @@ namespace BlackCore
if (!m_setupReader) { return CStatusMessage(this).error(u"No reader for setup/version"); } if (!m_setupReader) { return CStatusMessage(this).error(u"No reader for setup/version"); }
Q_ASSERT_X(m_parsed, Q_FUNC_INFO, "Not yet parsed"); Q_ASSERT_X(m_parsed, Q_FUNC_INFO, "Not yet parsed");
const CStatusMessageList requestMsgs = m_setupReader->loadSetup(); const CStatusMessageList requestMsgs = m_setupReader->loadSetup();
onSetupHandlingCompleted(requestMsgs.isSuccess());
return requestMsgs; return requestMsgs;
} }

View File

@@ -579,9 +579,6 @@ namespace BlackCore
//! Display the failures caused by loading the setup file //! Display the failures caused by loading the setup file
virtual void displaySetupLoadFailure(BlackMisc::CStatusMessageList msgs); virtual void displaySetupLoadFailure(BlackMisc::CStatusMessageList msgs);
//! Setup read/synchronized
void onSetupHandlingCompleted(bool available);
//! Startup completed //! Startup completed
virtual void onStartUpCompleted(); virtual void onStartUpCompleted();
@@ -612,7 +609,7 @@ namespace BlackCore
//! Start the core facade //! Start the core facade
//! \note does nothing when setup is not yet loaded //! \note does nothing when setup is not yet loaded
BlackMisc::CStatusMessageList startCoreFacadeAndWebDataServices(); BlackMisc::CStatusMessageList startCoreFacade();
//! Start the web data services //! Start the web data services
//! \note does nothing when setup is not yet loaded //! \note does nothing when setup is not yet loaded
@@ -680,9 +677,6 @@ namespace BlackCore
//! Init the local settings //! Init the local settings
BlackMisc::CStatusMessage initLocalSettings(); BlackMisc::CStatusMessage initLocalSettings();
//! Async. start when setup is loaded
BlackMisc::CStatusMessageList asyncWebAndContextStart();
using NetworkRequestOrPostFunction = std::function<QNetworkReply *(QNetworkAccessManager &, const QNetworkRequest &)>; using NetworkRequestOrPostFunction = std::function<QNetworkReply *(QNetworkAccessManager &, const QNetworkRequest &)>;
//! Implementation for getFromNetwork(), postToNetwork() and headerFromNetwork() //! Implementation for getFromNetwork(), postToNetwork() and headerFromNetwork()
@@ -741,7 +735,6 @@ namespace BlackCore
Db::CDatabaseReaderConfigList m_dbReaderConfig; //!< Load or used caching? Db::CDatabaseReaderConfigList m_dbReaderConfig; //!< Load or used caching?
bool m_noNwAccessPoint = false; //!< no network access point? bool m_noNwAccessPoint = false; //!< no network access point?
bool m_useContexts = false; //!< use contexts bool m_useContexts = false; //!< use contexts
bool m_useWebData = false; //!< use web data
bool m_devFlag = false; //!< dev. environment bool m_devFlag = false; //!< dev. environment
bool m_saveSettingsOnShutdown = true; //!< saving all settings on shutdown bool m_saveSettingsOnShutdown = true; //!< saving all settings on shutdown
bool m_localSettingsLoaded = false; //!< local settings loaded? bool m_localSettingsLoaded = false; //!< local settings loaded?