// 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) { MqConstant MqConstant = new MqConstant(Configuration); services.AddMetroBus(x => x.AddConsumer <TestActionConsumer>()); services.AddSingleton <IBusControl>(provider => MetroBusInitializer.Instance .UseRabbitMq(MqConstant.RabbitMQUri, MqConstant.RabbitMQUserName, MqConstant.RabbitMQPassword) .RegisterConsumer <TestActionConsumer>("user.activation.queue", provider) .Build()); services.AddHostedService <BusService>(); services.AddScoped <ITestService, TestService>(); }
// 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.Latest); services.AddMvcCore() .AddApiExplorer(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" }); }); services.AddScoped <ITestService, TestService>(); MqConstant MqConstant = new MqConstant(Configuration); services.AddSingleton(MetroBusInitializer.Instance.UseRabbitMq(MqConstant.RabbitMQUri, MqConstant.RabbitMQUserName, MqConstant.RabbitMQPassword).Build()); // services.AddSingleton<ITracer>(serviceProvider => // { // Environment.SetEnvironmentVariable("JAEGER_SERVICE_NAME", "User.API"); // Environment.SetEnvironmentVariable("JAEGER_AGENT_HOST", "localhost"); // Environment.SetEnvironmentVariable("JAEGER_AGENT_PORT", "6831"); // Environment.SetEnvironmentVariable("JAEGER_SAMPLER_TYPE", "const"); // // var loggerFactory = new LoggerFactory(); // //// var config = Jaeger.Configuration.FromEnv(loggerFactory); //// var tracer = config.GetTracer(); // // // GlobalTracer.Register(tracer); // // return tracer; // }); services.AddHealthChecks(); }