Exemplo n.º 1
0
        public AccountManagerActorShould()
        {
            ApiDependencyResolverSystem.Start();
            var resolver = new SimpleInjectorDependencyResolver(ApiDependencyResolverSystem.GetContainer(), Sys);

            _accountManagerActorRef = Sys.ActorOf(Sys.DI().Props <AccountManagerActor>(), nameof(AccountManagerActor));
        }
Exemplo n.º 2
0
        public void Configuration(IAppBuilder app)
        {
            var listener =
                (OwinHttpListener)app.Properties["Microsoft.Owin.Host.HttpListener.OwinHttpListener"];
            var maxAccepts  = Convert.ToInt32(ConfigReader.Settings["Owin.MaxAccepts"]);
            var maxRequests = Convert.ToInt32(ConfigReader.Settings["Owin.MaxRequests"]);

            listener.SetRequestProcessingLimits(maxAccepts,
                                                maxRequests);
            listener.SetRequestQueueLimit(int.Parse(ConfigReader.Settings["Owin.RequestQueueLimit"]));
            app.Properties["Microsoft.Owin.Host.HttpListener.OwinHttpListener"] = listener;

            // HttpConfiguration instance
            var config = new HttpConfiguration();

            EnableSwagger(config);
            config.MapHttpAttributeRoutes();
            config.Routes.MapHttpRoute(
                name: "api_ui_shortcut",
                routeTemplate: "api",
                defaults: null,
                constraints: null,
                handler: new RedirectHandler(SwaggerDocsConfig.DefaultRootUrlResolver, "api/ui/index"));
            config.Filters.Add(new NotNullModelAttribute());
            config.Filters.Add(new ModelStateValidationAttribute());
            config.MessageHandlers.Add(new HttpLogHandler());
            config.Services.Replace(typeof(IExceptionHandler), new OopsExceptionHandler());

            config.Formatters.Clear();
            config.Formatters.Add(new JsonMediaTypeFormatter());
            config.Formatters.JsonFormatter.SerializerSettings.ContractResolver =
                new CamelCasePropertyNamesContractResolver();
            config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;

            config.EnsureInitialized();
            ApiDependencyResolverSystem.Start();
            config.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(ApiDependencyResolverSystem.GetContainer());

            var cors = new EnableCorsAttribute("*",
                                               "*",
                                               "*");

            config.EnableCors(cors);
            app.UseCors(CorsOptions.AllowAll);

            app.Use <PublicApiAuthMiddleware>();

            app.UseWebApi(config);
            var properties = new AppProperties(app.Properties);
            var token      = properties.OnAppDisposing;

            if (token != CancellationToken.None)
            {
                token.Register(() =>
                               CommonLogger.Info <Startup>(
                                   "Http Listener successfully shut down :("));
            }
        }
Exemplo n.º 3
0
        public CreditHandlerActorShould()
        {
            var conf = new IgniteConfiguration
            {
                IgniteInstanceName = "Billingware.Cache.Tests." + Guid.NewGuid().ToString("N"),
                Logger             = new CustomIgniteSerilogLogger(),
                ClientMode         = false,
                // ConsistentId = Guid.NewGuid().ToString("N"),
                WorkDirectory       = AppDomain.CurrentDomain.BaseDirectory,
                MetricsLogFrequency = TimeSpan.Zero,
                // MetricsUpdateFrequency = TimeSpan.Zero,
                Localhost    = "0.0.0.0",
                DiscoverySpi = new TcpDiscoverySpi
                {
                    IpFinder = new TcpDiscoveryStaticIpFinder()
                    {
                        Endpoints = new[]
                        {
                            "localhost"
                        }
                    },
                    LocalPort      = 48500,
                    LocalPortRange = 10,
                },
                CommunicationSpi = new TcpCommunicationSpi
                {
                    LocalPort = 48100
                }
            };

            CommonIgniterService.Start(conf, true);
            ApiDependencyResolverSystem.Start();
            var resolver = new SimpleInjectorDependencyResolver(ApiDependencyResolverSystem.GetContainer(), Sys);

            _creditActorRef = Sys.ActorOf(Sys.DI().Props <CreditRequestActor>(), nameof(CreditRequestActor));
            var accountingActorRef = Sys.ActorOf(Sys.DI().Props <AccountingActor>(), nameof(AccountingActor));

            Sys.EventStream.Subscribe(accountingActorRef, typeof(DebitAccount));
            Sys.EventStream.Subscribe(accountingActorRef, typeof(CreditAccount));
            Sys.EventStream.Subscribe(accountingActorRef, typeof(PersistTransaction));
        }
Exemplo n.º 4
0
        /// <summary>
        /// This method starts the Core ActorSystem
        /// </summary>
        public static void Start()
        {
            var conf = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "\\core-remote-server.conf");

            _actorSystem = ActorSystem.Create(nameof(CoreActorSystem), ConfigurationFactory.ParseString(conf));

            ApiDependencyResolverSystem.Start();

            _resolver = new SimpleInjectorDependencyResolver(ApiDependencyResolverSystem.GetContainer(), _actorSystem);



            TopLevelActors.DebitHandlerActor = _actorSystem.ActorOf(_actorSystem.DI()
                                                                    .Props <DebitRequestActor>()
                                                                    .WithSupervisorStrategy(GetDefaultSupervisorStrategy)
                                                                    .WithRouter(FromConfig.Instance),
                                                                    nameof(DebitRequestActor));

            TopLevelActors.CreditsHandlerActor = _actorSystem.ActorOf(_actorSystem.DI()
                                                                      .Props <CreditRequestActor>()
                                                                      .WithSupervisorStrategy(GetDefaultSupervisorStrategy)
                                                                      .WithRouter(FromConfig.Instance),
                                                                      nameof(CreditRequestActor));

            TopLevelActors.AccountingActor = _actorSystem.ActorOf(_actorSystem.DI()
                                                                  .Props <AccountingActor>()
                                                                  .WithSupervisorStrategy(GetDefaultSupervisorStrategy)
                                                                  .WithRouter(FromConfig.Instance),
                                                                  nameof(AccountingActor));



            _actorSystem.EventStream.Subscribe(TopLevelActors.AccountingActor, typeof(DebitAccount));
            _actorSystem.EventStream.Subscribe(TopLevelActors.AccountingActor, typeof(CreditAccount));
            _actorSystem.EventStream.Subscribe(TopLevelActors.AccountingActor, typeof(PersistTransaction));
        }