Esempio n. 1
0
        public static IMicropartBuilder UseLogOfNLog(this IMicropartBuilder app)
        {
            var microServiceStatusManager = app.ApplicationServices.GetService <IMicropartStatusManager>();
            var micropartInfoOfNLog       = microServiceStatusManager.UpdateStatus <MicropartInfoOfNLog>(MicropartType.Log);

            if (micropartInfoOfNLog.IsEnabled)
            {
                var microserviceTraceInfoManager = app.ApplicationServices.GetService <IMicroserviceTraceInfoManager>();
                TraceInfoLayoutRender.GetTraceInfo = () => microserviceTraceInfoManager.GetCurrentTraceInfo();

                var loggerFactory = app.ApplicationServices.GetService <ILoggerFactory>();
                loggerFactory.AddNLog(new NLogProviderOptions
                {
                    CaptureMessageTemplates  = true,
                    CaptureMessageProperties = true
                });

                ConfigurationItemFactory
                .Default
                .LayoutRenderers
                .RegisterDefinition("traceInfo", typeof(TraceInfoLayoutRender));

                loggerFactory.ConfigureNLog("nlog.config");
            }

            return(app);
        }
Esempio n. 2
0
 public static IMicropartBuilder UseServiceCenterOfConsul(
     this IMicropartBuilder micropartBuilder,
     Action <MicropartOfServiceCenterAConsulBuilder> innerBuilderAction
     )
 {
     innerBuilderAction(new MicropartOfServiceCenterAConsulBuilder(micropartBuilder));
     return(micropartBuilder);
 }
Esempio n. 3
0
        public static IMicropartBuilder UseRabbitMqAsEventBus(this IMicropartBuilder app)
        {
            var micropartOfEventBusStartup = app.ApplicationServices.GetService <IMicropartOfEventBusStartup>();

            var lifetime = app.ApplicationServices.GetService <IAppLifetime>();

            lifetime.ApplicationStarted.Register(() => micropartOfEventBusStartup.Start());
            lifetime.ApplicationStopped.Register(micropartOfEventBusStartup.Stop);
            return(app);
        }
Esempio n. 4
0
        public static IMicropartBuilder UseCallTraceOfZipkin(this IMicropartBuilder app)
        {
            var appConfigurationManager = app.ApplicationServices.GetService <IAppConfigurationManager>();

            appConfigurationManager.MonitorConfig <AppConfigOfZipkin>();

            var micropartOfCallTreeStartup = app.ApplicationServices.GetService <IMicropartOfCallTreeStartup>();

            var lifetime = app.ApplicationServices.GetService <IAppLifetime>();

            lifetime.ApplicationStarted.Register(() => micropartOfCallTreeStartup.Start());
            lifetime.ApplicationStopped.Register(micropartOfCallTreeStartup.Stop);
            return(app);
        }
Esempio n. 5
0
        public static IMicropartBuilder UseHttpHealthCheckOfAspNetCore(this IMicropartBuilder micropartBuilder, IApplicationBuilder app)
        {
            var httpHealtheCheck = new HttpHealthCheck();

            app.Map(httpHealtheCheck.HealthCheckUrl,
                    builder => builder.Run(async context =>
            {
                await context.Response.WriteAsync("OK1");
            }));
            app.ApplicationServices.GetService <IMicropartOfServiceCenter>().RegisterService();
            var httpRequestFilter = app.ApplicationServices.GetService <IMicroserviceFilterManager <HttpRequestFilter, HttpRequest> >();

            httpRequestFilter.AddFilter(new HttpRequestFilterOfHealthCheck());
            return(micropartBuilder);
        }
Esempio n. 6
0
 public static IMicropartBuilder UseCallTraceOfZipkin(this IMicropartBuilder micropartBuilder, Action <MicropartOfCallChainAsZipkinBuilder> micropartOfCallChainAsZipkinBuilder)
 {
     micropartBuilder.UseCallTraceOfZipkin();
     micropartOfCallChainAsZipkinBuilder(new MicropartOfCallChainAsZipkinBuilder());
     return(micropartBuilder);
 }
Esempio n. 7
0
 public MicropartOfServiceCenterAConsulBuilder(IMicropartBuilder micropartBuilder)
 {
     _micropartBuilder = micropartBuilder;
 }
Esempio n. 8
0
 public static IMicropartBuilder UseServiceCenterOfConsul(this IMicropartBuilder micropartBuilder)
 {
     return(micropartBuilder);
 }
Esempio n. 9
0
 public static void UseConfigurationCenterOfConsul(this IMicropartBuilder app)
 {
 }