Exemple #1
0
        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);
        }