-
Notifications
You must be signed in to change notification settings - Fork 798
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
47 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 33 additions & 30 deletions
63
...ecks.System/DiskStorageLivenessOptions.cs → ...HealthChecks.System/DiskStorageOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,33 @@ | ||
namespace HealthChecks.System; | ||
|
||
public class DiskStorageOptions | ||
{ | ||
internal Dictionary<string, (string DriveName, long MinimumFreeMegabytes)> ConfiguredDrives { get; } = new(); | ||
|
||
public DiskStorageOptions AddDrive(string driveName, long minimumFreeMegabytes = 1) | ||
{ | ||
ConfiguredDrives.Add(driveName, (driveName, minimumFreeMegabytes)); | ||
return this; | ||
} | ||
|
||
public bool CheckAllDrives { get; set; } | ||
|
||
public DiskStorageOptions WithCheckAllDrives() | ||
{ | ||
CheckAllDrives = true; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// Allows to set custom description of the failed disk check. | ||
/// </summary> | ||
public ErrorDescription FailedDescription = (driveName, minimumFreeMegabytes, actualFreeMegabytes) | ||
=> actualFreeMegabytes == null | ||
? $"Configured drive {driveName} is not present on system" | ||
: $"Minimum configured megabytes for disk {driveName} is {minimumFreeMegabytes} but actual free space are {actualFreeMegabytes} megabytes"; | ||
|
||
public delegate string ErrorDescription(string driveName, long minimumFreeMegabytes, long? actualFreeMegabytes); | ||
} | ||
namespace HealthChecks.System; | ||
|
||
/// <summary> | ||
/// Options for <see cref="DiskStorageHealthCheck"/>. | ||
/// </summary> | ||
public class DiskStorageOptions | ||
{ | ||
internal Dictionary<string, (string DriveName, long MinimumFreeMegabytes)> ConfiguredDrives { get; } = new(); | ||
|
||
public DiskStorageOptions AddDrive(string driveName, long minimumFreeMegabytes = 1) | ||
{ | ||
ConfiguredDrives.Add(driveName, (driveName, minimumFreeMegabytes)); | ||
return this; | ||
} | ||
|
||
public bool CheckAllDrives { get; set; } | ||
|
||
public DiskStorageOptions WithCheckAllDrives() | ||
{ | ||
CheckAllDrives = true; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// Allows to set custom description of the failed disk check. | ||
/// </summary> | ||
public ErrorDescription FailedDescription = (driveName, minimumFreeMegabytes, actualFreeMegabytes) | ||
=> actualFreeMegabytes == null | ||
? $"Configured drive {driveName} is not present on system" | ||
: $"Minimum configured megabytes for disk {driveName} is {minimumFreeMegabytes} but actual free space are {actualFreeMegabytes} megabytes"; | ||
|
||
public delegate string ErrorDescription(string driveName, long minimumFreeMegabytes, long? actualFreeMegabytes); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters