protected override void OnStateChange(LinkProducerState newState) { _logger.Debug($"State change {State} -> {newState}"); try { _configuration.StateHandler(State, newState); } catch (Exception ex) { _logger.Warning($"Exception in state handler: {ex}"); } base.OnStateChange(newState); }
private async Task <LinkTopologyState> OnConfigureAsync(IModel model, bool retry, CancellationToken cancellation) { if (retry) { try { _logger.Debug($"Retrying in {_configuration.RecoveryInterval.TotalSeconds:0.###}s"); await Task.Delay(_configuration.RecoveryInterval, cancellation) .ConfigureAwait(false); } catch { return(LinkTopologyState.Reconfiguring); } } _logger.Debug("Configuring topology"); try { await _topologyRunner .RunAsync(model, cancellation) .ConfigureAwait(false); } catch (Exception ex) { _logger.Warning($"Exception on configuration: {ex}"); try { await _configuration.TopologyHandler.ConfigurationError(ex) .ConfigureAwait(false); } catch (Exception handlerException) { _logger.Error($"Error in error handler: {handlerException}"); } return(LinkTopologyState.Reconfiguring); } try { await _configuration.TopologyHandler.Ready() .ConfigureAwait(false); } catch (Exception ex) { _logger.Error($"Error in ready handler: {ex}"); } _logger.Debug("Topology configured"); return(LinkTopologyState.Ready); }