public async Task <ExecutionResult <EventChannel> > GetChannel(string name) { if (_diagnosticSource.IsEnabled($"{nameof(GetChannel)}")) { _diagnosticSource.Write($"{nameof(GetChannel)}", name); } var stopwatch = new Stopwatch(); stopwatch.Start(); try { return(await _eventChannelRepository.GetChannelAsync(c => c.Name == name)); } catch (Exception ex) { _logger.LogError(ex, $"{nameof(GetChannel)} {name} failed"); throw; } finally { stopwatch.Stop(); _logger.LogTrace($"{nameof(GetChannel)}:Ends in {stopwatch.Elapsed}"); } }
public static EventChannel AddChannel(IEventChannelService channelService, int timeout = 30) { EventChannel channel; //Act var executionGetResult = channelService.GetChannelAsync(x => x.Name == "TestChannel").Result; executionGetResult.Should().NotBeNull(); executionGetResult.IsSuccessful.Should().BeTrue(); if (executionGetResult.Result == null) { var executionResult = channelService.RegisterChannelAsync(new EventChannel { IsFifo = true, Key = Guid.NewGuid().ToString(), Name = "TestChannel", MaxLifeTimeMessage = timeout, MaxLifeTimeSubscriber = timeout }).Result; executionResult.Should().NotBeNull(); executionResult.IsSuccessful.Should().BeTrue(); channel = executionResult.Result; } else { channel = executionGetResult.Result; } channel.Should().NotBeNull(); return(channel); }