Ejemplo n.º 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            var envName    = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
            var akkaConfig = AkkaLoad.Load(envName, Configuration);

            actorSystem = ActorSystem.Create("AkkaDotBootSystem", akkaConfig);
            services.AddAkka(actorSystem);

            services.AddRazorPages();
            services.AddServerSideBlazor();
            services.AddSingleton <WeatherForecastService>();
        }
Ejemplo n.º 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
            services.AddControllers();

            services.AddSingleton(Configuration.GetSection("AppSettings").Get <AppSettings>());// * AppSettings

            // 액터에 DI적용시 사용
            services.AddSingleton <KafkaService>();
            services.AddScoped <TonerActor>();
            services.AddScoped <PrinterActor>();

            // Swagger
            services.AddSwaggerGen(options =>
            {
                options.SwaggerDoc("v1", new OpenApiInfo
                {
                    Version        = "v1",
                    Title          = AppName,
                    Description    = $"{AppName} ASP.NET Core Web API",
                    TermsOfService = new Uri("http://wiki.webnori.com/display/codesniper/TermsOfService"),
                    Contact        = new OpenApiContact
                    {
                        Name  = Company,
                        Email = Email,
                        Url   = new Uri(CompanyUrl),
                    },
                    License = new OpenApiLicense
                    {
                        Name = $"Document",
                        Url  = new Uri(DocUrl),
                    }
                });

                // Set the comments path for the Swagger JSON and UI.
                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                options.IncludeXmlComments(xmlPath);
            });

            // *** Akka Service Setting
            var envName     = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
            var akkaConfig  = AkkaLoad.Load(envName, Configuration);
            var actorSystem = ActorSystem.Create(SystemNameForCluster, akkaConfig);
            var provider    = services.BuildServiceProvider();

            actorSystem.UseServiceProvider(provider);
            services.AddAkka(actorSystem);

            // API주소룰 소문자로...
            //services.AddRouting(options => options.LowercaseUrls = true);
        }
Ejemplo n.º 3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            services.AddSingleton(Configuration.GetSection("AppSettings").Get <AppSettings>());// * AppSettings

            services.AddSingleton <ConsumerSystem>();
            services.AddSingleton <ProducerSystem>();

            services.AddDbContext <UserRepository>();

            // Akka 설정
            // 참고 :  https://getakka.net/articles/concepts/configuration.html
            // AKKASYSTEM : http://wiki.webnori.com/display/AKKA/AKKASYSTEM
            // Akka 셋팅
            var envName    = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
            var akkaConfig = AkkaLoad.Load(envName, Configuration);

            actorSystem = ActorSystem.Create("AkkaDotBootSystem", akkaConfig);

            services.AddAkka(actorSystem);

            //모니터링추가
            var statsdConfig = new StatsdConfig
            {
                StatsdServerName = "127.0.0.1"
            };

            //ActorMonitoringExtension.RegisterMonitor(actorSystem, new ActorDatadogMonitor(statsdConfig));


            // Signal R 셋팅
            services
            .AddSingleton(new ConnectionSourceSettings(102400, OverflowStrategy.DropBuffer))
            .AddSignalRAkkaStream()
            .AddSignalR();

            // Swagger
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Version        = "v1",
                    Title          = AppName,
                    Description    = $"{AppName} ASP.NET Core Web API",
                    TermsOfService = new Uri(CompanyUrl),
                    Contact        = new OpenApiContact
                    {
                        Name  = Company,
                        Email = "*****@*****.**",
                        Url   = new Uri(CompanyUrl),
                    },
                    License = new OpenApiLicense
                    {
                        Name = $"Document",
                        Url  = new Uri(DocUrl),
                    }
                });

                c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
                {
                    Name         = "Authorization",
                    Type         = SecuritySchemeType.ApiKey,
                    Scheme       = "Bearer",
                    BearerFormat = "JWT",
                    In           = ParameterLocation.Header,
                    Description  = "JWT Authorization header using the Bearer scheme."
                });

                c.AddSecurityRequirement(new OpenApiSecurityRequirement
                {
                    {
                        new OpenApiSecurityScheme
                        {
                            Reference = new OpenApiReference
                            {
                                Type = ReferenceType.SecurityScheme,
                                Id   = "Bearer"
                            }
                        },
                        new string[] {}
                    }
                });

                // Set the comments path for the Swagger JSON and UI.
                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                c.IncludeXmlComments(xmlPath);
            });
        }