This commit is contained in:
Naresh Kumar 2024-03-02 12:17:21 +05:30
Родитель 9ec61d9437
Коммит c7b8ad4181
6 изменённых файлов: 23 добавлений и 23 удалений

Просмотреть файл

@ -0,0 +1,10 @@
using FabricHealer.Utilities.Telemetry;
using Guan.Logic;
namespace FabricHealer.Interfaces
{
public interface ICustomPredicateType
{
void RegisterToPredicateTypesCollection(FunctorTable functorTable, TelemetryData repairData);
}
}

Просмотреть файл

@ -1,10 +0,0 @@
using FabricHealer.Utilities.Telemetry;
using Guan.Logic;
namespace FabricHealer.Interfaces
{
public interface IPredicateTypesCollection
{
void RegisterPredicateTypes(FunctorTable functorTable, TelemetryData repairData);
}
}

Просмотреть файл

@ -199,4 +199,4 @@ TimeScopedRestartCodePackage :- RestartCodePackage(DoHealthChecks=false, MaxWait
## Restart individual replica hosted in the process. If you do not specify a value for MaxExecutionTime argument, the default is 60 minutes.
TimeScopedRestartReplica :- RestartReplica(DoHealthChecks=false, MaxWaitTimeForHealthStateOk=00:01:00, MaxExecutionTime=00:15:00).
##Mitigate(HealthState="Warning") :- SampleHealerPluginPredicateType("repair rule loaded from plugin").
##Mitigate(HealthState="Warning") :- CustomRepair("repair rule loaded from plugin").

Просмотреть файл

@ -199,7 +199,7 @@ namespace FabricHealer.Repair
}
PluginLoader[] pluginLoaders = new PluginLoader[pluginDlls.Length];
Type[] sharedTypes = { typeof(CustomRepairPredicateTypeAttribute), typeof(IPredicateTypesCollection) };
Type[] sharedTypes = { typeof(CustomRepairPredicateTypeAttribute), typeof(ICustomPredicateType) };
string dll = "";
for (int i = 0; i < pluginDlls.Length; ++i)
@ -223,9 +223,9 @@ namespace FabricHealer.Repair
object customPredicateObject = Activator.CreateInstance(customPredicateAttribute.CustomRepairPredicateType);
if (customPredicateObject is IPredicateTypesCollection predicateTypesCollection)
if (customPredicateObject is ICustomPredicateType customPredicateType)
{
predicateTypesCollection.RegisterPredicateTypes(functorTable, repairData);
customPredicateType.RegisterToPredicateTypesCollection(functorTable, repairData);
}
else
{

Просмотреть файл

@ -15,9 +15,9 @@ namespace FabricHealer.Repair.Guan
/// <summary>
/// Helper external predicate that generates health/etw/telemetry events.
/// </summary>
public class SampleHealerPluginPredicateType : PredicateType
public class CustomRepairPredicateType : PredicateType
{
private static SampleHealerPluginPredicateType Instance;
private static CustomRepairPredicateType Instance;
private static TelemetryData RepairData;
private class Resolver : BooleanPredicateResolver
@ -36,7 +36,7 @@ namespace FabricHealer.Repair.Guan
if (count == 0)
{
throw new GuanException("SampleHealerPluginPredicateType: At least 1 argument is required.");
throw new GuanException("CustomRepairPredicateType: At least 1 argument is required.");
}
format = Input.Arguments[0].Value.GetEffectiveTerm().GetStringValue();
@ -73,13 +73,13 @@ namespace FabricHealer.Repair.Guan
}
}
public static SampleHealerPluginPredicateType Singleton(string name, TelemetryData repairData)
public static CustomRepairPredicateType Singleton(string name, TelemetryData repairData)
{
RepairData = repairData;
return Instance ??= new SampleHealerPluginPredicateType(name);
return Instance ??= new CustomRepairPredicateType(name);
}
private SampleHealerPluginPredicateType(string name)
private CustomRepairPredicateType(string name)
: base(name, true, 1)
{

Просмотреть файл

@ -9,14 +9,14 @@ using FabricHealer.Repair.Guan;
using Guan.Logic;
using FabricHealer.Utilities.Telemetry;
[assembly: CustomRepairPredicateType(typeof(SampleNewHealerStartup))]
[assembly: CustomRepairPredicateType(typeof(CustomRepairPredicateTypeStartup))]
namespace FabricHealer.Repair.Guan
{
public class SampleNewHealerStartup : IPredicateTypesCollection
public class CustomRepairPredicateTypeStartup : IPredicateTypesCollection
{
public void RegisterPredicateTypes(FunctorTable functorTable, TelemetryData repairData)
{
functorTable.Add(SampleHealerPluginPredicateType.Singleton(nameof(SampleHealerPluginPredicateType), repairData));
functorTable.Add(CustomRepairPredicateType.Singleton("CustomRepair", repairData));
}
}
}