public static gHardwareOptions Convert(this HardwareCheckOptions opts) { if (opts == null) { return(null); } return(new gHardwareOptions() { MemoryThreshold = opts.MemoryThreshold, StorageThreshold = opts.StorageThreshold }); }
/// <summary> /// Sets the hardware options for a given server (must be called only in the GrpcServices project) /// </summary> public void SetHardwareOptions(HardwareCheckOptions options, string callerAddress) { if (_serversConfig.TryGetValue(callerAddress, out HardwareCheckOptions opts)) { // update entry _serversConfig[callerAddress] = options; } else { // create new entry _serversConfig.TryAdd(callerAddress, options); } _signal.Release(); }
/// <summary> /// Sets the <see cref="HardwareCheckOptions"/> for the given server /// </summary> public async Task <OperationResult> WriteHardwareOptions(HardwareCheckOptions hardwareOpts, string serverAddress) { OperationResult Result = new OperationResult(); WriteHardwareOptionsRequested?.Invoke(this, new WriteHardwareOptionsEventArgs(hardwareOpts, serverAddress)); if (await _signal.WaitAsync(WAIT_TIME)) { if (!_serversConfig.TryGetValue(serverAddress, out HardwareCheckOptions options)) { _logger.LogError("No record found for the server: " + serverAddress); Result.ErrorContent = new ErrorContent("No record found, please try again.", ErrorOrigin.Server); } } else { _logger.LogError("Response timed out for server: " + serverAddress); Result.ErrorContent = new ErrorContent("Timeout: Response not received, please check that the server is up and running.", ErrorOrigin.Server); } return(Result); }
public WriteHardwareOptsRequestedEventArgs(HardwareCheckOptions hardwareOpt, string serverAddress) { HardwareOpts = hardwareOpt; ServerAddress = serverAddress; }
public MemoryHealthCheck(IOptionsMonitor <HardwareCheckOptions> options) { _options = options.CurrentValue; }
public StorageHealthCheck(IOptionsMonitor<HardwareCheckOptions> hardwraeOpts, IOptionsMonitor<UploadOptions> uploadsOpts) { _hardwareOpts = hardwraeOpts.CurrentValue; _uploadOpts = uploadsOpts.CurrentValue; }
public async Task <IActionResult> UpdateHardwareOpts(HardwareCheckOptions model) { OperationResult result = await _mediatr.Send(new UpdateConfigSectionCommand(model)); return(HandleResult(result)); }