public void TestSetup()
        {
            eventsWriter = Substitute.For <IEventsWriter>();

            eventsWriterProvider = Substitute.For <IEventsWriterProvider>();
            eventsWriterProvider.ObtainWriterAsync(Arg.Any <CancellationToken>()).Returns(Task.FromResult(eventsWriter));

            writerProviderFactory = Substitute.For <IEventsWriterProviderFactory>();
            writerProviderFactory.CreateProvider(Arg.Any <FilePath>(), Arg.Any <Func <FileLogSettings> >()).Returns(eventsWriterProvider);

            muxer = new SynchronousSingleFileMuxer(writerProviderFactory, new FileLogSettings());
        }
Exemplo n.º 2
0
        public void TestSetup()
        {
            writer = Substitute.For <IEventsWriter>();

            writerProvider = Substitute.For <IEventsWriterProvider>();
            writerProvider.ObtainWriterAsync(Arg.Any <CancellationToken>()).Returns(writer);

            worker = new SingleFileWorker();

            events     = new ConcurrentBoundedQueue <LogEventInfo>(2);
            buffer     = new LogEventInfo[1];
            eventsLost = new AtomicLong(0);
        }
Exemplo n.º 3
0
        public void TestSetup()
        {
            eventsWriter = Substitute.For <IEventsWriter>();

            eventsWriterProvider = Substitute.For <IEventsWriterProvider>();
            eventsWriterProvider.ObtainWriterAsync(Arg.Any <CancellationToken>()).Returns(Task.FromResult(eventsWriter));

            writerProviderFactory = Substitute.For <IEventsWriterProviderFactory>();
            writerProviderFactory.CreateProvider(Arg.Any <FilePath>(), Arg.Do <Func <FileLogSettings> >(x => settingsInsideMuxer = x)).Returns(eventsWriterProvider);

            singleFileWorker = Substitute.For <ISingleFileWorker>();
            singleFileWorker.WritePendingEventsAsync(
                Arg.Any <IEventsWriterProvider>(),
                Arg.Any <ConcurrentBoundedQueue <LogEventInfo> >(),
                Arg.Any <LogEventInfo[]>(),
                Arg.Any <AtomicLong>(),
                Arg.Any <AtomicLong>(),
                Arg.Any <CancellationToken>())
            .Returns(Task.FromResult(true));

            muxer = new SingleFileMuxer(writerProviderFactory, singleFileWorker, new FileLogSettings());
        }
Exemplo n.º 4
0
        /// <summary>
        /// Конструктор реализации буфера хранилища событий.
        /// Создаёт новый экземпляр класса <see cref="EventsBufferEngine"/>.
        /// </summary>
        public EventsBufferEngine(
            IOptions <EngineOptions> engineOptions,
            IEventsWriter eventsWriter,
            ILogger <EventsBufferEngine> logger)
        {
            if (engineOptions == null)
            {
                throw new ArgumentNullException(nameof(engineOptions), $"{nameof(engineOptions)} is null.");
            }
            if (engineOptions.Value == null)
            {
                throw new ArgumentNullException(nameof(engineOptions.Value), $"{nameof(engineOptions.Value)} is null.");
            }

            _engineOptions = engineOptions.Value;
            _eventsWriter  = eventsWriter;
            _logger        = logger;

            _flushTimer = new Timer(async obj => await FlushTimerDelegate(obj), null,
                                    _engineOptions.EventsFlushPeriodSec * 1000,
                                    _engineOptions.EventsFlushPeriodSec * 1000);
        }
Exemplo n.º 5
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="MongoTarget" /> class.
 /// </summary>
 public MongoTarget([NotNull] IConnectionStringRetriever connectionStringRetriever,
                    [NotNull] IEventsWriter eventsWriter,
                    [NotNull] IInternalLogger internalLogger)
 {
     if (connectionStringRetriever == null)
     {
         throw new ArgumentNullException(nameof(connectionStringRetriever));
     }
     if (eventsWriter == null)
     {
         throw new ArgumentNullException(nameof(eventsWriter));
     }
     if (internalLogger == null)
     {
         throw new ArgumentNullException(nameof(internalLogger));
     }
     Fields                     = new List <MongoField>();
     Properties                 = new List <MongoField>();
     IncludeDefaults            = true;
     _connectionStringRetriever = connectionStringRetriever;
     _eventsWriter              = eventsWriter;
     _internalLogger            = internalLogger;
 }
Exemplo n.º 6
0
        public void TestSetup()
        {
            strategy = Substitute.For <IRollingStrategy>();
            strategy.GetCurrentFile(Arg.Any <FilePath>()).Returns("log");
            strategy.DiscoverExistingFiles(Arg.Any <FilePath>()).Returns(new FilePath[] { "log1", "log-2" });

            strategyProvider = Substitute.For <IRollingStrategyProvider>();
            strategyProvider.ObtainStrategy().Returns(strategy);

            eventsWriter = Substitute.For <IEventsWriter>();

            eventsWriterFactory = Substitute.For <IEventsWriterFactory>();
            eventsWriterFactory.TryCreateWriter(Arg.Any <FilePath>(), Arg.Any <FileLogSettings>()).Returns(eventsWriter);

            garbageCollector = Substitute.For <IRollingGarbageCollector>();

            cooldownController = Substitute.For <ICooldownController>();
            cooldownController.IsCool.Returns(true);
            cooldownController.WaitForCooldownAsync().Returns(Task.CompletedTask);

            provider = new EventsWriterProvider("log", eventsWriterFactory, strategyProvider, garbageCollector, cooldownController, () => settings);

            settings = new FileLogSettings();
        }
 public void TestSetup()
 {
     eventsWriter = Substitute.For <IEventsWriter>();
     muxer        = new ConsoleLogMuxer(eventsWriter, 1, 1);
 }
Exemplo n.º 8
0
 public ConsoleLogMuxer(IEventsWriter eventsWriter, int eventsQueueCapacity, int temporaryBufferCapacity)
 {
     this.eventsWriter = eventsWriter;
     temporaryBuffer   = new LogEventInfo[temporaryBufferCapacity];
     events            = new ConcurrentBoundedQueue <LogEventInfo>(eventsQueueCapacity);
 }
Exemplo n.º 9
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="MongoTarget" /> class.
 /// </summary>
 public TestTarget([NotNull] IConnectionStringRetriever connectionStringRetriever,
                   [NotNull] IEventsWriter eventsWriter,
                   [NotNull] IInternalLogger internalLogger) : base(connectionStringRetriever, eventsWriter, internalLogger)
 {
 }