Exemplo n.º 1
0
 public void Setup()
 {
     _elasticClientFactory = Substitute.For <IElasticClientFactory>();
     _elasticClient        = Substitute.For <IElasticsearchClient>();
     _timer = Substitute.For <IIndexingTimer>();
     _tolerateCallsFactory = Substitute.For <ITolerateCallsFactory>();
     _bulk = Substitute.For <ILogBulkSet>();
     _logEventConverterFactory = Substitute.For <ILogEventConverterFactory>();
     _logEventConverter        = Substitute.For <ILogEventConverter>();
     _elasticFilters           = new ElasticAppenderFilters();
     _fileAccessor             = Substitute.For <IFileAccessor>();
     _eventWriter = Substitute.For <IExternalEventWriter>();
     _elasticClientFactory.CreateClient(null, 0, false, false, null).ReturnsForAnyArgs(_elasticClient);
     _logEventConverterFactory.Create(FixFlags.All, false).ReturnsForAnyArgs(_logEventConverter);
 }
Exemplo n.º 2
0
        public override void ActivateOptions()
        {
            AddOptionalServer();
            _client = _elasticClientFactory.CreateClient(Servers, ElasticSearchTimeout, Ssl, AllowSelfSignedServerCert, AuthenticationMethod);

            _logEventConverter = _logEventConverterFactory.Create(FixedFields, SerializeObjects);

            if (Template != null && Template.IsValid)
            {
                if (IndexAsync)
                {
                    _client.PutTemplateRaw(Template.Name, _fileAccessor.ReadAllText(Template.FileName));
                }
                else
                {
                    _client.PutTemplateRaw(Template.Name, _fileAccessor.ReadAllText(Template.FileName));
                }
            }

            ElasticFilters.PrepareConfiguration(_client);

            _timer.Restart(BulkIdleTimeout);
        }