Beispiel #1
0
        public static void AddServiceCollection(this IServiceCollection services)
        {
            var dnsPublishAddress    = EnvSettings.Instance().ConsulDnsPublishAddress;
            var baseDomain           = EnvSettings.Instance().ConsulDnsBaseDomain;
            var websignalServiceName = EnvSettings.Instance().WebSignalRServiceName;

            var baseDns = new BaseDnsDiscovery(baseDomain);

            if (!Regex.IsMatch(dnsPublishAddress, @"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b"))
            {
                var address = Dns.GetHostAddresses(dnsPublishAddress).LastOrDefault();
                if (address != null)
                {
                    dnsPublishAddress = address.ToString();
                }
            }
            var endpointDiscovery = new EndpointDiscovery
                                        (new LookupClient(IPAddress.Parse(dnsPublishAddress),
                                                          EnvSettings.Instance().ConsulDnsPort)
            {
                UseTcpOnly = true
            }, baseDns);

            services.AddSingleton <EndpointDiscovery>(_ => endpointDiscovery);


            services.AddTransient <IMemberRepository, MockMemberRepository>();

            services.AddSingleton <IBatchPublisher>(_ => new BatchPublisher(new Uri(EnvSettings.Instance().BatchUrl)));

            services.AddSingleton <IStockDiscussionPublisher>(_ => new StockDiscussionPublisher(websignalServiceName, endpointDiscovery));
        }
Beispiel #2
0
        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));
        }