public static ServiceConfig GetServiceConfig(this IConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } var serviceConfig = new ServiceConfig { ServiceDiscoveryAddress = configuration.GetValue <Uri>("ServiceConfig:serviceDiscoveryAddress"), ServiceAddress = configuration.GetValue <Uri>("ServiceConfig:serviceAddress"), ServiceName = configuration.GetValue <string>("ServiceConfig:serviceName"), ServiceId = configuration.GetValue <string>("ServiceConfig:serviceId") }; return(serviceConfig); }
private static ConsulClient CreateConsulClient(ServiceConfig serviceConfig) { return new ConsulClient(config => { config.Address = serviceConfig.ServiceDiscoveryAddress; }); }
public ServiceDiscoveryHostedService(IConsulClient client, ServiceConfig config) { _client = client; _config = config; }