public LinkChannel(LinkConfiguration configuration, ILinkConnection connection) { if (configuration == null) throw new ArgumentNullException(nameof(configuration)); if (connection == null) throw new ArgumentNullException(nameof(connection)); _configuration = configuration; _logger = _configuration.LoggerFactory.CreateLogger($"{GetType().Name}({Id:D})"); if (_logger == null) throw new ArgumentException("Cannot create logger", nameof(configuration.LoggerFactory)); _disposedCancellationSource = new CancellationTokenSource(); _disposedCancellation = _disposedCancellationSource.Token; Connection = connection; Connection.Disposed += ConnectionOnDisposed; Connection.Connected += ConnectionOnConnected; _logger.Debug($"Created(connectionId: {Connection.Id:D})"); ScheduleReopen(false); }
public LinkChannel(ILinkConnection connection, LinkStateHandler <LinkChannelState> stateHandler, TimeSpan recoveryInterval) : base(LinkChannelState.Init) { _connection = connection ?? throw new ArgumentNullException(nameof(connection)); _logger = connection.Configuration.LoggerFactory.CreateLogger($"{GetType().Name}({Id:D})") ?? throw new ArgumentException("Cannot create logger", nameof(connection.Configuration.LoggerFactory)); if (recoveryInterval <= TimeSpan.Zero) { throw new ArgumentOutOfRangeException(nameof(recoveryInterval), "Must be greater than zero"); } _stateHandler = stateHandler ?? throw new ArgumentNullException(nameof(stateHandler)); _recoveryInterval = recoveryInterval; _disposeCts = new CancellationTokenSource(); _disposeCancellation = _disposeCts.Token; _connection.Disposed += ConnectionOnDisposed; _logger.Debug($"Created(connectionId: {_connection.Id:D})"); }
public static void Debug(this ILinkLogger logger, string message) { if (logger == null) { throw new ArgumentNullException(nameof(logger)); } logger.Write(LinkLoggerLevel.Debug, message); }
/// <summary> /// Creates new instance of <see cref="BufferedLinkLogger" /> /// </summary> /// <param name="undelyingLogger">Underlying logger to write messages</param> /// <param name="maxMessages">Maximum number of messages in buffer, after buffer overflow it will blocks next writes</param> public BufferedLinkLogger(ILinkLogger undelyingLogger, int? maxMessages = 1000) { if (undelyingLogger == null) throw new ArgumentNullException(nameof(undelyingLogger)); if (maxMessages <= 0) throw new ArgumentException("Must be greater than zero", nameof(maxMessages)); UnderlyingLogger = undelyingLogger; _eventLoop = maxMessages == null ? new EventLoop(EventLoop.DisposingStrategy.Wait) : new EventLoop(maxMessages.Value, EventLoop.DisposingStrategy.Wait); }
public LinkConsumer( LinkConsumerConfiguration configuration, ILinkChannel channel ) : base(LinkConsumerState.Init) { _configuration = configuration; _channel = channel ?? throw new ArgumentNullException(nameof(channel)); _logger = _channel.Connection.Configuration.LoggerFactory.CreateLogger($"{GetType().Name}({Id:D})") ?? throw new InvalidOperationException("Cannot create logger"); _topologyRunner = new LinkTopologyRunner <ILinkQueue>(_logger, configuration.TopologyHandler.Configure); _appId = _channel.Connection.Configuration.AppId; _channel.Disposed += ChannelOnDisposed; _channel.Initialize(this); }
public LinkTopology(ILinkChannel channel, LinkTopologyConfiguration configuration) : base(LinkTopologyState.Init) { _channel = channel ?? throw new ArgumentNullException(nameof(channel)); _configuration = configuration; _logger = _channel.Connection.Configuration.LoggerFactory.CreateLogger($"{GetType().Name}({Id:D})") ?? throw new InvalidOperationException("Cannot create logger"); _topologyRunner = new LinkTopologyRunner <object>(_logger, async cfg => { await _configuration.TopologyHandler.Configure(cfg) .ConfigureAwait(false); return(null); }); _channel.Disposed += ChannelOnDisposed; _logger.Debug($"Created(channelId: {_channel.Id})"); _channel.Initialize(this); }
public LinkConnection(LinkConfiguration configuration) : base(LinkConnectionState.Init) { _configuration = configuration; _logger = _configuration.LoggerFactory.CreateLogger($"{GetType().Name}({Id:D})") ?? throw new ArgumentException("Cannot create logger", nameof(configuration.LoggerFactory)); _connectionFactory = new LinkConnectionFactory( _configuration.ConnectionName, _configuration.AppId, _configuration.ConnectionString, _configuration.Timeout, _configuration.UseBackgroundThreadsForConnection ); _disposeCts = new CancellationTokenSource(); _disposeCancellation = _disposeCts.Token; _logger.Debug($"Created ( name: {_configuration.ConnectionName})"); if (_configuration.AutoStart) { Initialize(); } }
public LinkTopologyConfig(ILinkLogger logger, IActionInvoker <IModel> invoker) { _invoker = invoker ?? throw new ArgumentNullException(nameof(invoker)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public LinkTopologyRunner(ILinkLogger logger, Func <ILinkTopologyConfig, Task <T> > configureFunc) { _configureFunc = configureFunc; _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public LinkLoggerHandler(IMemberDirectory directory, ILinkLogger linkLogger) { _linkLogger = linkLogger; _directory = directory; _regEx = new Regex(URL_PATTERN, RegexOptions.IgnoreCase); }
/// <summary> /// Ctor /// </summary> /// <param name="communicator"></param> /// <param name="directory"></param> /// <param name="linkLogger"></param> public LinksCommand(ICommunicator communicator, IMemberDirectory directory, ILinkLogger linkLogger) { _communicator = communicator; _directory = directory; _linkLogger = linkLogger; }