Exemplo n.º 1
0
 public override void Shutdown()
 {
     if (consulHelper != null)
     {
         AsyncHelper.RunSync(async() => await consulHelper.DeregisterAsync());
     }
 }
Exemplo n.º 2
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);
 }