Skip to content

affecto/dotnet-Wcf.Monitoring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Affecto.Wcf.Monitoring

Generate shallow and/or deep monitoring endpoints dynamically for WCF services. Endpoints are generated for all service contracts hosted by a service host. Shallow endpoint simply returns message "OK". Deep endpoint uses a specific service interface to call a health check method.

NuGet: https://www.nuget.org/packages/Affecto.Wcf.Monitoring

Build status

Build status

Code examples

Implementing IHealthCheckService

internal class HealthCheckService : IHealthCheckService
{
    private readonly IDataStore store;

    public HealthCheckService(IDataStore store)
    {
        if (store == null)
        {
            throw new ArgumentNullException(nameof(store));
        }
        this.store = store;
    }

    public void CheckHealth()
    {
        store.Ping();
    }
}

Registering health check service and monitoring endpoints with Autofac

ContainerBuilder builder = new ContainerBuilder();

// Register health check service
builder.RegisterType<HealthCheckService>().As<IHealthCheckService>();

// Register other components into container here
// ...

IContainer container = builder.Build();
AutofacHostFactory.Container = container;

AutofacHostFactory.HostConfigurationAction = serviceHost =>
{
    serviceHost.Opening += (sender, args) =>
    {
        // Generate only shallow endpoints:
        serviceHost.GenerateShallowMonitoringEndpoints();

        // Generate only deep endpoints:
        serviceHost.GenerateDeepMonitoringEndpoints(container.Resolve<Func<IHealthCheckService>>());

        // Generate both shallow and deep endpoints:
        serviceHost.GenerateMonitoringEndpoints(container.Resolve<Func<IHealthCheckService>>());
    };
};

About

Create dynamic monitoring endpoints for WCF services

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages