public CheckServiceStatus(NaturalLanguageClassifier service, ServiceStatus callback) { m_Service = service; m_Callback = callback; string customClassifierID = Config.Instance.GetVariableValue(SERVICE_ID + "_ID"); m_Service.DisableCache = true; //If custom classifierID is defined then we are using it to check the service health if (!string.IsNullOrEmpty(customClassifierID)) { if (!m_Service.GetClassifier(customClassifierID, OnCheckService)) { OnFailure("Failed to call GetClassifier()"); } else { m_GetClassifierCount += 1; } } else { if (!m_Service.GetClassifiers(OnCheckServices)) { OnFailure("Failed to call GetClassifiers()"); } } }
private void OnCheckServices(Classifiers classifiers) { if (m_Callback != null) { if (classifiers.classifiers.Length > 0) { foreach (var classifier in classifiers.classifiers) { // check the status of one classifier, if it's listed as "Unavailable" then fail if (!m_Service.GetClassifier(classifier.classifier_id, OnCheckService)) { OnFailure("Failed to call GetClassifier()"); break; } else { m_GetClassifierCount += 1; } } } else { if (m_Callback != null && m_Callback.Target != null) { m_Callback(SERVICE_ID, true); // no classifiers to check, just return success then.. } } } else { if (m_Callback != null && m_Callback.Target != null) { m_Callback(SERVICE_ID, false); } } }