public Statistics GetStat(CheckBase check) { if (check == null) { throw new ArgumentNullException(nameof(check)); } return(_allStats[check]); }
public CheckResult Check(CheckBase checkBase) { if (checkBase == null) { throw new ArgumentNullException(nameof(checkBase)); } var httpCheck = checkBase as HttpCheck; if (httpCheck == null) { throw new ArgumentException("check is not of type HttpCall"); } var result = HttpUtil.GetContentFromUrl( httpCheck.Url, httpCheck.ConnectTimeout, httpCheck.ReadTimeout, _readBufferSize, _connectSleepMilliseconds, httpCheck.MaxContentLength); var now = _timeService.UtcNow; var conditionResults = new List <ConditionResultDetail>(); foreach (var conditionBase in httpCheck.Conditions) { var condition = (HttpCheckCondition)conditionBase; string checkMessage; switch (condition.Type) { case HttpCheckConditionType.Status: checkMessage = CheckStatus(result, (HttpStatusCondition)condition); break; case HttpCheckConditionType.Content: checkMessage = CheckContent(result, (HttpContentCondition)condition); break; // ReSharper disable once RedundantCaseLabel case HttpCheckConditionType.Undefined: default: throw new ArgumentOutOfRangeException(nameof(checkBase), condition.Type, "condition has no type"); } var conditionResult = new ConditionResultDetail(condition.Name, string.IsNullOrEmpty(checkMessage), checkMessage); conditionResults.Add(conditionResult); if (!conditionResult.Success && condition.StopOnFail) { break; } } var outcome = conditionResults.All(c => c.Success) ? CheckOutcome.Success : CheckOutcome.Fail; return(new CheckResult(checkBase, now, outcome, conditionResults)); }
public IChecker GetChecker(CheckBase check) { if (check == null) { throw new ArgumentNullException(nameof(check)); } var type = check.GetType(); if (type == typeof(HttpCheck)) { return(new HttpChecker(_timeService)); } throw new ArgumentOutOfRangeException($"unknown check type {type}"); }
public CheckRunnerInfo(Thread thread, CheckBase check) { Thread = thread; Check = check; }
public static CheckBase SetDeviceId(string deviceName, CheckBase doc, PrintServiceClient client) { doc.DeviceId = client.GetDeviceIdByDeviceName(deviceName); return(doc); }
/// <summary>Creates service definition that can be registered with a server</summary> /// <param name="serviceImpl">An object implementing the server-side handling logic.</param> public static grpc::ServerServiceDefinition BindService(CheckBase serviceImpl) { return(grpc::ServerServiceDefinition.CreateBuilder() .AddMethod(__Method_Ping, serviceImpl.Ping).Build()); }
/// <summary>Register service method implementations with a service binder. Useful when customizing the service binding logic. /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary> /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param> /// <param name="serviceImpl">An object implementing the server-side handling logic.</param> public static void BindService(grpc::ServiceBinderBase serviceBinder, CheckBase serviceImpl) { serviceBinder.AddMethod(__Method_Ping, serviceImpl.Ping); }