public static void AddServiceCollection(this IServiceCollection services) { var dnsAddress = EnvSettings.Instance().ConsulDnsPublishAddress; var baseDomain = Environment.GetEnvironmentVariable("CONSUL_DNS_BASEDOMAIN"); var onlineServiceName = Environment.GetEnvironmentVariable("TIK_ONLINE_SERVICENAME"); var identityServiceName = Environment.GetEnvironmentVariable("TIK_IDENTITY_SERVICENAME"); var baseDns = new BaseDnsDiscovery(baseDomain); if (!Regex.IsMatch(dnsAddress, @"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b")) { var address = Dns.GetHostAddresses(dnsAddress).LastOrDefault(); if (address != null) { dnsAddress = address.ToString(); } } var endpointDiscovery = new EndpointDiscovery (new LookupClient(IPAddress.Parse(dnsAddress), EnvSettings.Instance().ConsulDnsPort) { UseTcpOnly = true }, baseDns); services.AddSingleton <EndpointDiscovery>(_ => endpointDiscovery); services.AddTransient <IIdentityTokenPublisher>(_ => new IdentityTokenPublisher(identityServiceName, endpointDiscovery)); services.AddTransient <IEodPublisher>(_ => new EodPublisher(onlineServiceName, endpointDiscovery)); services.AddTransient <ICommonStockPublisher>(_ => new CommonStockPublisher(onlineServiceName, endpointDiscovery)); }
public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .UseKestrel(options => { options.Listen(EnvSettings.Instance().IP, EnvSettings.Instance().Port); }) .UseStartup <Startup>() .Build();