feat(operations): add capacity and resilience gates (#18)
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using System.Text.Json;
|
||||
|
||||
namespace FinalFactory.Rendezvous.Capacity;
|
||||
|
||||
internal static class Program
|
||||
{
|
||||
private static readonly JsonSerializerOptions JsonOptions = new(JsonSerializerDefaults.Web)
|
||||
{
|
||||
WriteIndented = true,
|
||||
};
|
||||
|
||||
public static async Task<int> Main(string[] args)
|
||||
{
|
||||
CapacityOptions options;
|
||||
try
|
||||
{
|
||||
options = CapacityOptions.Parse(args);
|
||||
}
|
||||
catch (ArgumentException exception)
|
||||
{
|
||||
Console.Error.WriteLine(exception.Message);
|
||||
return 2;
|
||||
}
|
||||
|
||||
CapacityReport report = await CapacityRunner.RunAsync(options).ConfigureAwait(false);
|
||||
string json = JsonSerializer.Serialize(report, JsonOptions);
|
||||
Console.WriteLine(json);
|
||||
if (options.OutputPath is not null)
|
||||
{
|
||||
string fullPath = Path.GetFullPath(options.OutputPath);
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(fullPath)!);
|
||||
await File.WriteAllTextAsync(fullPath, json + Environment.NewLine).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
return report.Passed ? 0 : 1;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user