public MassTransitHostedService(IBusControl bus, ILoggerFactory loggerFactory, SimplifiedBusHealthCheck simplifiedBusCheck, ReceiveEndpointHealthCheck receiveEndpointCheck) { _bus = bus; _simplifiedBusCheck = simplifiedBusCheck; _receiveEndpointCheck = receiveEndpointCheck; if (loggerFactory != null && Logging.Logger.Current.GetType() == typeof(TraceLogger)) { ExtensionsLoggingIntegration.ExtensionsLogger.Use(loggerFactory); } }
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); })); }
static void AddSimplifiedHostedService(this IServiceCollection services, Action <HealthCheckOptions> configureHealthChecks) { var busCheck = new SimplifiedBusHealthCheck(); var receiveEndpointCheck = new ReceiveEndpointHealthCheck(); var healthCheckOptions = HealthCheckOptions.Default; configureHealthChecks?.Invoke(healthCheckOptions); services.AddHealthChecks() .AddCheck(healthCheckOptions.BusHealthCheckName, busCheck, healthCheckOptions.FailureStatus, healthCheckOptions.Tags) .AddCheck(healthCheckOptions.ReceiveEndpointHealthCheckName, receiveEndpointCheck, healthCheckOptions.FailureStatus, healthCheckOptions.Tags); services.AddSingleton <IHostedService>(p => { var bus = p.GetRequiredService <IBusControl>(); return(new MassTransitHostedService(bus, busCheck, receiveEndpointCheck)); }); }
public MassTransitHostedService(IBusControl bus, ReceiveEndpointHealthCheck receiveEndpointCheck) { _bus = bus; _receiveEndpointCheck = receiveEndpointCheck; }
public MassTransitHostedService(IBusControl bus, SimplifiedBusHealthCheck simplifiedBusCheck, ReceiveEndpointHealthCheck receiveEndpointCheck) { _bus = bus; _simplifiedBusCheck = simplifiedBusCheck; _receiveEndpointCheck = receiveEndpointCheck; }