Exemplo n.º 1
0
        public static void AddActorSystem(this IServiceCollection services)
        {
            string host = EnvSettings.Instance().AkkaAddress;

            var huconConfig = Path.Combine(Directory.GetCurrentDirectory(), EnvSettings.Instance().HuconFileName);
            var config      = HoconLoader.FromFile(huconConfig);

            var actorSystem         = ActorSystem.Create(EnvSettings.Instance().ActorSystem, config);
            var memberActorProvider = new MemberActorProvider(actorSystem, host);
            //var backLogsActorProvider = new BackLogsActorProvider(actorSystem, host);
            //var jobsActorProvider = new JobsActorProvider(actorSystem, host);
            var commonStocksProvider     = new CommonStocksProvider(actorSystem, host);
            var eodStocksProvider        = new EodStocksProvider(actorSystem, host);
            var commonStockRouteProvider = new CommonStockRouteProvider(actorSystem, host);

            services.AddSingleton(typeof(ActorSystem), actorSystem);


            services.AddSingleton <MemberActorProvider>(_ => memberActorProvider);
            //services.AddSingleton<BackLogsActorProvider>(_ => backLogsActorProvider);
            //services.AddSingleton<JobsActorProvider>(_ => jobsActorProvider);
            services.AddSingleton <CommonStocksProvider>(_ => commonStocksProvider);
            services.AddSingleton <EodStocksProvider>(_ => eodStocksProvider);
            services.AddSingleton <CommonStockRouteProvider>(_ => commonStockRouteProvider);

            services.AddMemberServices();
            //services.AddJobServices();
            //services.AddBackLogServices();
            services.AddCommonStockServices();
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
0
 public static IWebHost BuildWebHost(string[] args) =>
 WebHost.CreateDefaultBuilder(args)
 .UseKestrel(options =>
 {
     options.Listen(EnvSettings.Instance().IP, EnvSettings.Instance().Port);
 })
 .UseStartup <Startup>()
 .Build();
Exemplo n.º 4
0
 public static IWebHost BuildWebHost(string[] args) =>
 WebHost.CreateDefaultBuilder(args)
 .UseKestrel(options => {
     options.Listen(EnvSettings.Instance().IP, EnvSettings.Instance().Port);
 }).ConfigureLogging((hostingContext, logging) =>
 {
     Log.Logger = new LoggerConfiguration()
                  .MinimumLevel.Verbose()
                  .WriteTo.LiterateConsole()
                  .WriteTo.RollingFile("logs/log-{Date}.txt")
                  .CreateLogger();
 })
 .UseStartup <Startup>()
 .Build();