static ReceiveEndpointHealthCheck AddAndGetHealthChecks(this IServiceCollection collection) { var busHealthCheck = new BusHealthCheck(); var endpointHealthCheck = new ReceiveEndpointHealthCheck(); collection.AddSingleton(busHealthCheck); collection.AddHealthChecks() .AddBusHealthCheck("bus", busHealthCheck) .AddBusHealthCheck("endpoint", endpointHealthCheck); return(endpointHealthCheck); }
/// <summary> /// Adds the MassTransit <see cref="IHostedService"/>, which includes a bus and endpoint health check /// </summary> /// <param name="collection"></param> public static IServiceCollection AddMassTransitHostedService(this IServiceCollection collection) { var busCheck = new BusHealthCheck(); var receiveEndpointCheck = new ReceiveEndpointHealthCheck(); collection.AddSingleton(busCheck); collection.AddHealthChecks() .AddBusHealthCheck("bus", busCheck) .AddBusHealthCheck("endpoint", receiveEndpointCheck); return(collection.AddSingleton <IHostedService>(p => { var bus = p.GetRequiredService <IBusControl>(); return new MassTransitHostedService(bus, new SimplifiedBusHealthCheck(), receiveEndpointCheck); })); }