Пример #1
0
 /// <summary>
 /// Use RabbitMQ.
 /// Pass IApplicationLifetime.ApplicationStopping to this method.
 /// </summary>
 /// <param name="app"></param>
 /// <returns></returns>
 public static IApplicationBuilder UseConsul(this IApplicationBuilder app,
                                             CancellationToken applicationStopping)
 {
     _serviceDiscoveryHelper = _serviceDiscoveryHelper ?? app.ApplicationServices.GetRequiredService <IServiceDiscoveryHelper>();
     _serviceDiscoveryHelper.RegisterAsync().GetAwaiter().GetResult();
     applicationStopping.Register(() =>
     {
         try
         {
             _serviceDiscoveryHelper.DeregisterAsync().GetAwaiter().GetResult();
         }
         catch
         {
             // No action.
         }
     });
     return(app);
 }
Пример #2
0
 public override void PostInitialize()
 {
     consulHelper = IocManager.Resolve <IServiceDiscoveryHelper>();
     AsyncHelper.RunSync(async() => await consulHelper.RegisterAsync());
 }