Mayor McCheese
Mayor McCheese
Explore posts from servers
CC#
Created by Mayor McCheese on 1/30/2024 in #help
✅ Supporting multiple routes for health checks in asp.net core
I have a couple monitoring systems that need are calling some api's and I need to support different response types for each monitoring system. Is there a way in asp.net core? Assume I have a number of health probes, for example... .AddHealthCheck<Db2HealthCheck>() .AddHealthCheck<SqlHealthCheck>() .AddHealthCheck<DynamoHealthCheck>() .AddHealthCheck<CognitoHealthCheck>() .AddHealthCheck<YadaYadaYada>() The yadayadayada monitor should only check the YadaYadaYada health check, for example The Aws monitor should only check the CognitoHealthCheck The database monitor should oinly check Db2, Dynamo, and SqlHealthCheck
48 replies
CC#
Created by Mayor McCheese on 9/12/2023 in #help
❔ Mediatr Notification using a Base Class Not Publishing
I'm using a base class as a constraint on a generic notification in mediatr. When I publish my notification via mediatr my notification handler isn't found. I believe mediatr is supposed to support this idea; so maybe I'm just chasing a red-herring.
<Project Sdk="Microsoft.NET.Sdk.Worker">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MediatR" Version="12.1.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk.Worker">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MediatR" Version="12.1.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
</ItemGroup>
</Project>
using MediatR;

IHost host = Host.CreateDefaultBuilder(args)
.ConfigureServices(services =>
{
services.AddMediatR(o=>o.RegisterServicesFromAssembly(typeof(Program).Assembly));
})
.Build();


host.Start();

var mediator = host.Services.GetRequiredService<IMediator>();

Console.WriteLine("Sending Event One");
await mediator.Publish(new EventNotification<EventOne>());

Console.WriteLine("Sending Event Two");
await mediator.Publish(new EventNotification<EventTwo>());

class EventHandler<TModel> : NotificationHandler<EventNotification<TModel>> where TModel : TestEvent
{
protected override void Handle(EventNotification<TModel> notification)
{
Console.WriteLine(notification.Model.DateTime);
}
}

class EventNotification<T> : INotification where T : TestEvent
{
public T Model { get; set; }
}

abstract class TestEvent
{
public DateTime DateTime = DateTime.Now;
}

class EventOne : TestEvent
{

}

class EventTwo:TestEvent
{

}
using MediatR;

IHost host = Host.CreateDefaultBuilder(args)
.ConfigureServices(services =>
{
services.AddMediatR(o=>o.RegisterServicesFromAssembly(typeof(Program).Assembly));
})
.Build();


host.Start();

var mediator = host.Services.GetRequiredService<IMediator>();

Console.WriteLine("Sending Event One");
await mediator.Publish(new EventNotification<EventOne>());

Console.WriteLine("Sending Event Two");
await mediator.Publish(new EventNotification<EventTwo>());

class EventHandler<TModel> : NotificationHandler<EventNotification<TModel>> where TModel : TestEvent
{
protected override void Handle(EventNotification<TModel> notification)
{
Console.WriteLine(notification.Model.DateTime);
}
}

class EventNotification<T> : INotification where T : TestEvent
{
public T Model { get; set; }
}

abstract class TestEvent
{
public DateTime DateTime = DateTime.Now;
}

class EventOne : TestEvent
{

}

class EventTwo:TestEvent
{

}
3 replies
ATApache TinkerPop
Created by Mayor McCheese on 2/4/2023 in #questions
running in k8s
Are there any nuances to running in k8s, are there helm charts or manifests available?
3 replies