Exemple #1
0
        /// <summary>
        /// Get the status of the selected component
        /// </summary>
        /// <returns>Dependency object containing the status and other information</returns>
        public Dependency GetHealth()
        {
            //Prevent multiple parallel invocations
            lock (lockObj)
            {
                //Initially assume status is down
                attachedDependency.Status = Enums.DependencyStatus.DOWN;

                try
                {
                    if (cache.IsCached)
                    {
                        if (cacheManager.Contains(attachedDependency.Name))
                        {
                            return(cacheManager.GetData <Dependency>(attachedDependency.Name));
                        }
                    }

                    SetHealthImplementation();

                    if (cache.IsCached)
                    {
                        //TODO: cache policy/expiry handling
                        cacheManager.Add <Dependency>(attachedDependency.Name, attachedDependency);
                    }
                }
                catch
                {
                    //TODO: Log?
                }
                return(attachedDependency);
            }
        }