Skip to content

ServiceGovernance/ServiceGovernance.Registry.Agent

Repository files navigation

ServiceGovernance.Registry.Agent

Build status NuGet Version License

Provides an Agent (client) for the ServiceRegistry. This agent registers the ASP.NET Core Service (your API web service) in the ServiceRegistry on application startup and unregisters it on application shutdown.

Usage

Install the NuGet package ServiceGovernance.Registry.Agent.

public void ConfigureServices(IServiceCollection services)
{
    ...
    services.AddServiceRegistryAgent(options => {
            options.Registry = new Uri("https://myserviceregistry.mycompany.com");
            options.ServiceIdentifier = "Api1";
            options.ServiceDisplayName = "My Api";
            options.PublicUrls = new[]{new Uri("https://api1.mycompany.com")}
            });
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    ...
    app.UseMvc();
    ...
    app.UseServiceRegistryAgent();
}

Configuration

It's also possible to provide these options via the configuration:

public void ConfigureServices(IServiceCollection services)
{
    ...
    services.AddServiceRegistryAgent(options => Configuration.Bind("ServiceRegistry", options));
}
{
    "ServiceRegistry": {
        "Registry": "https://myserviceregistry.mycompany.com",
        "ServiceIdentifier": "Api1",
        "ServiceDisplayName": "My Api",
        "PublicUrls": ["https://api1.mycompany.com"]
    }
}

Service urls

The url, the service is available on and which will be registered in the ServiceRegistry, will be detected automatically. You can manually provide the service urls via the ServiceEndpoints property (or configuration key).