Committing updates.

This commit is contained in:
Преподобный Ален
2022-06-09 02:01:55 +03:00
parent 63740a62f2
commit bfcfe3121d
2 changed files with 15 additions and 15 deletions

View File

@@ -291,12 +291,23 @@ namespace Apostol {
Context.Tokens().Values("access_token", Json["access_token"].AsString()); Context.Tokens().Values("access_token", Json["access_token"].AsString());
Context.SetFixedDate(0); Context.SetFixedDate(0);
Context.SetCheckDate(Now() + (CDateTime) 55 / MinsPerDay); // 55 min Context.SetCheckDate(Now() + (CDateTime) 50 / MinsPerDay); // 50 min
} }
return true; return true;
}; };
auto OnFail = [&Context](CTCPConnection *Sender, const Delphi::Exception::Exception &E) {
Context.SetStatus(csInitialized);
auto pConnection = dynamic_cast<CHTTPClientConnection *> (Sender);
auto pClient = dynamic_cast<CHTTPClient *> (pConnection->Client());
DebugReply(pConnection->Reply());
Log()->Error(APP_LOG_ERR, 0, "[%s:%d] %s", pClient->Host().c_str(), pClient->Port(), E.what());
};
auto OnHTTPClient = [this](const CLocation &URI) { auto OnHTTPClient = [this](const CLocation &URI) {
return GetClient(URI.hostname, URI.port); return GetClient(URI.hostname, URI.port);
}; };
@@ -309,7 +320,7 @@ namespace Apostol {
Context.Tokens().Values("service_token", service_token); Context.Tokens().Values("service_token", service_token);
if (!token_uri.IsEmpty()) { if (!token_uri.IsEmpty()) {
CToken::FetchAccessToken(token_uri.front() == '/' ? server_uri + token_uri : token_uri, service_token, OnHTTPClient, OnDone); CToken::FetchAccessToken(token_uri.front() == '/' ? server_uri + token_uri : token_uri, service_token, OnHTTPClient, OnDone, OnFail);
} }
} }
//-------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------
@@ -342,14 +353,6 @@ namespace Apostol {
} }
//-------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------
int CWebService::NextServerIndex() {
m_ServerIndex++;
if (m_ServerIndex >= m_Servers.Count())
m_ServerIndex = -1;
return m_ServerIndex;
}
//--------------------------------------------------------------------------------------------------------------
bool CWebService::DoProxyExecute(CTCPConnection *AConnection) { bool CWebService::DoProxyExecute(CTCPConnection *AConnection) {
auto pConnection = dynamic_cast<CHTTPClientConnection *> (AConnection); auto pConnection = dynamic_cast<CHTTPClientConnection *> (AConnection);
@@ -420,8 +423,7 @@ namespace Apostol {
} }
} }
Log()->Error(APP_LOG_EMERG, 0, "[%s:%d] %s", pProxy->Host().c_str(), pProxy->Port(), Log()->Error(APP_LOG_EMERG, 0, "[%s:%d] %s", pProxy->Host().c_str(), pProxy->Port(), E.what());
E.what());
} }
//-------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------
@@ -1671,7 +1673,7 @@ namespace Apostol {
if (Now >= Context.CheckDate()) { if (Now >= Context.CheckDate()) {
Context.SetCheckDate(Now + (CDateTime) 30 / SecsPerDay); // 30 sec Context.SetCheckDate(Now + (CDateTime) 30 / SecsPerDay); // 30 sec
if ((Context.Status() == Context::csInitialized) || (Context.Status() == Context::csRunning)) { if (Context.Status() != Context::csAuthorization) {
Context.SetStatus(Context::csAuthorization); Context.SetStatus(Context::csAuthorization);
CheckProviders(Now, Context); CheckProviders(Now, Context);

View File

@@ -73,8 +73,6 @@ namespace Apostol {
protected: protected:
int NextServerIndex();
CHTTPProxy *GetProxy(CHTTPServerConnection *AConnection); CHTTPProxy *GetProxy(CHTTPServerConnection *AConnection);
const CContext &CurrentServer() const; const CContext &CurrentServer() const;