public async Task RegisterAsync(ConsulRegistration registration) { if (_logger.IsEnabled(LogLevel.Information)) { _logger.LogInformation("Registering service with consul: " + registration.ServiceId); } try { await _client.Agent.ServiceRegister(registration.AgentServiceRegistration); if (_heartbeatOptions.Enable) { _ttlScheduler?.Add(registration.InstanceId); } } catch (Exception e) { if (_consulDiscoveryOptions.FailFast) { _logger.LogError(e, "Error registering service with consul: " + registration.ServiceId); throw; } _logger.LogWarning(e, "Failfast is false. Error registering service with consul: " + registration.ServiceId); } }
public async Task DeregisterAsync(ConsulRegistration registration) { _ttlScheduler?.Remove(registration.InstanceId); if (_logger.IsEnabled(LogLevel.Information)) { _logger.LogInformation("Deregistering service with consul: " + registration.ServiceId); } await _client.Agent.ServiceDeregister(registration.InstanceId); }