internal static ElasticsearchResponse <T> WatcherAckWatchDispatch <T>(this IElasticsearchClient client, ElasticsearchPathInfo <AcknowledgeWatchRequestParameters> elasticsearchPathInfo, string watchId = null, string actionId = null, Metric metric = Metric.All) { var pathInfo = elasticsearchPathInfo.ToWatcherPathInfo(watchId, actionId, metric); switch (pathInfo.HttpMethod) { case PathInfoHttpMethod.PUT: //PUT /_watcher/watch/{watch_id}/{action_id}/_ack if (!pathInfo.WatchId.IsNullOrEmpty() && !pathInfo.ActionId.IsNullOrEmpty()) { return(client.WatcherAckWatch <T>(pathInfo.WatchId, pathInfo.ActionId, u => pathInfo.RequestParameters)); } //PUT /_watcher/watch/{watch_id}/_ack if (!pathInfo.WatchId.IsNullOrEmpty()) { return(client.WatcherAckWatch <T>(pathInfo.WatchId, u => pathInfo.RequestParameters)); } break; case PathInfoHttpMethod.POST: //POST /_watcher/watch/{watch_id}/{action_id}/_ack if (!pathInfo.WatchId.IsNullOrEmpty() && !pathInfo.ActionId.IsNullOrEmpty()) { return(client.WatcherAckWatchPost <T>(pathInfo.WatchId, pathInfo.ActionId, u => pathInfo.RequestParameters)); } //POST /_watcher/watch/{watch_id}/_ack if (!pathInfo.WatchId.IsNullOrEmpty()) { return(client.WatcherAckWatchPost <T>(pathInfo.WatchId, u => pathInfo.RequestParameters)); } break; } throw new DispatchException("Could not dispatch IElasticClient.WatcherAckWatch() into any of the following paths: \r\n - /_watcher/watch/{watch_id}/_ack\r\n - /_watcher/watch/{watch_id}/{action_id}/_ack"); }
public void PrepareConfiguration(IElasticsearchClient client) { _jsonFilter = new JsonFilter { FlattenJson = FlattenXml, SourceKey = SourceKey, Separator = Separator }; _jsonFilter.PrepareConfiguration(client); }
public static Task <ElasticsearchResponse <T> > IndicesExistsTypeAsync <T>( this IElasticsearchClient client, string index, string type, IndicesExistsTypeSelector requestParameters) { var selector = Obsolete.UpCastSelector <IndicesExistsTypeRequestParameters, TypeExistsRequestParameters>(requestParameters); return(client.IndicesExistsTypeAsync <T>(index, type, selector)); }
public void SetUp() { _client = new ElasticsearchClient(); _calls = new List <ElasticsearchProjectionHandlerCall>(); var handler1 = new ElasticsearchProjectionHandler( typeof(MatchMessage1), (client, msg, token) => { _calls.Add(new ElasticsearchProjectionHandlerCall(client, msg, token)); return(Task.FromResult(false)); }); var handler2 = new ElasticsearchProjectionHandler( typeof(MatchMessage2), (client, msg, token) => { _calls.Add(new ElasticsearchProjectionHandlerCall(client, msg, token)); return(Task.FromResult(false)); }); var handler3 = new ElasticsearchProjectionHandler( typeof(MatchMessage1), (client, msg, token) => { _calls.Add(new ElasticsearchProjectionHandlerCall(client, msg, token)); return(Task.FromResult(false)); }); var handler4 = new ElasticsearchProjectionHandler( typeof(MatchMessage2), (client, msg, token) => { _calls.Add(new ElasticsearchProjectionHandlerCall(client, msg, token)); return(Task.FromResult(false)); }); _sut = SutFactory(new[] { handler1, handler2, handler3, handler4 }); }
public static ElasticsearchResponse <T> IndicesExistsAlias <T>( this IElasticsearchClient client, string index, IndicesExistsAliasSelector requestParameters) { var selector = Obsolete.UpCastSelector <IndicesExistsAliasRequestParameters, AliasExistsRequestParameters>(requestParameters); return(client.IndicesExistsAlias <T>(index, selector)); }
public ElasticSearchClientTests() { var elasticSettingsOptionsMock = new Mock <IOptions <ElasticsearchSettings> >(); elasticSettingsOptionsMock .SetupGet(m => m.Value) .Returns(() => new ElasticsearchSettings() { Url = "http://localhost:9200" }); _elasticClientWrapperMock = new Mock <IElasticClientWrapper>(); _searchResponseMock = new Mock <ISearchResponse <SearchableQuestion> >(); _searchResponseMock.Setup(x => x.Documents) .Returns(new List <SearchableQuestion> { new SearchableQuestion { Text = Text, Id = Guid.NewGuid().ToString() } }); _searchResponseMock.SetupGet(x => x.ApiCall.HttpStatusCode) .Returns((int)HttpStatusCode.OK); _elasticClientWrapperMock.Setup(x => x.SearchAsync( It.IsAny <Func <SearchDescriptor <SearchableQuestion>, ISearchRequest> >())) .ReturnsAsync(_searchResponseMock.Object); _client = new ElasticsearchClient(_elasticClientWrapperMock.Object); }
public static Task <ElasticsearchResponse <DynamicDictionary> > IndicesExistsAliasAsync( this IElasticsearchClient client, string index, IndicesExistsAliasSelector requestParameters) { var selector = Obsolete.UpCastSelector <IndicesExistsAliasRequestParameters, AliasExistsRequestParameters>(requestParameters); return(client.IndicesExistsAliasAsync(index, selector)); }
public static ElasticsearchResponse <DynamicDictionary> IndicesExistsType( this IElasticsearchClient client, string index, string type, IndicesExistsTypeSelector requestParameters) { var selector = Obsolete.UpCastSelector <IndicesExistsTypeRequestParameters, TypeExistsRequestParameters>(requestParameters); return(client.IndicesExistsType(index, type, selector)); }
/// <summary> /// Projects the specified messages asynchronously. /// </summary> /// <param name="client">The Elasticsearch client used during projection.</param> /// <param name="messages">The messages to project.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// A <see cref="Task" />. /// </returns> /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="client"/> or <paramref name="messages"/> are <c>null</c>.</exception> public async Task ProjectAsync(IElasticsearchClient client, IEnumerable <object> messages, CancellationToken cancellationToken) { if (client == null) { throw new ArgumentNullException("client"); } if (messages == null) { throw new ArgumentNullException("messages"); } foreach (var message in messages) { ElasticsearchProjectionHandler[] handlers; if (!_handlers.TryGetValue(message.GetType(), out handlers)) { continue; } foreach (var handler in handlers) { await handler.Handler(client, message, cancellationToken); } } }
internal static ElasticsearchResponse <T> WatcherExecuteWatchDispatch <T>(this IElasticsearchClient client, ElasticsearchPathInfo <ExecuteWatchRequestParameters> elasticsearchPathInfo, object body, string watchId = null, string actionId = null, Metric metric = Metric.All) { var pathInfo = elasticsearchPathInfo.ToWatcherPathInfo(watchId, actionId, metric); switch (pathInfo.HttpMethod) { case PathInfoHttpMethod.PUT: //PUT /_watcher/watch/{id}/_execute if (!pathInfo.Id.IsNullOrEmpty() && body != null) { return(client.WatcherExecuteWatch <T>(pathInfo.Id, body, u => pathInfo.RequestParameters)); } //PUT /_watcher/watch/_execute if (body != null) { return(client.WatcherExecuteWatch <T>(body, u => pathInfo.RequestParameters)); } break; case PathInfoHttpMethod.POST: //POST /_watcher/watch/{id}/_execute if (!pathInfo.Id.IsNullOrEmpty() && body != null) { return(client.WatcherExecuteWatchPost <T>(pathInfo.Id, body, u => pathInfo.RequestParameters)); } //POST /_watcher/watch/_execute if (body != null) { return(client.WatcherExecuteWatchPost <T>(body, u => pathInfo.RequestParameters)); } break; } throw new DispatchException("Could not dispatch IElasticClient.WatcherExecuteWatch() into any of the following paths: \r\n - /_watcher/watch/{id}/_execute\r\n - /_watcher/watch/_execute"); }
public void PrepareConfiguration(IElasticsearchClient client) { foreach (var filter in _filters) { ValidateFilterProperties(filter); filter.PrepareConfiguration(client); } }
public WeatherForecastController(ILogger <WeatherForecastController> logger, IElasticsearchClient elasticsearchClient, IOptions <ApplicationSettings> options) { _logger = logger; _elasticsearchClient = elasticsearchClient; _appSettings = options.Value; }
protected TestBase(ITestOutputHelper output) { Output = output; Client = new ElasticsearchClient(new ElasticsearchConfigProvider(new ElasticsearchConfig { Urls = "http://10.186.132.138:9200" })); }
public ElasticNetConnection( IElasticsearchClient client, Uri endpoint, string index = null, TimeSpan? timeout = null, ElasticConnectionOptions options = null) : base(endpoint, index, timeout, options) { this.client = client; }
protected override void InitializeTarget() { base.InitializeTarget(); var uri = GetConnectionString(ConnectionStringName) ?? Uri; var nodes = uri.Split(',').Select(url => new Uri(url)); var connectionPool = new StaticConnectionPool(nodes); var config = new ConnectionConfiguration(connectionPool); _client = new ElasticsearchClient(config, serializer:ElasticsearchSerializer); }
/// <summary> /// Create a new ElasticNetConnection with the given parameters defining its properties. /// </summary> /// <param name="client">The ElasticsearchClient to use in order to contact elasticsearch.</param> /// <param name="timeout">TimeSpan to wait for network responses before failing (optional, defaults to 10 seconds).</param> /// <param name="index">Name of the index to use on the server (optional).</param> /// <param name="options">Additional options that specify how this connection should behave.</param> public ElasticNetConnection( IElasticsearchClient client, string index = null, TimeSpan? timeout = null, ElasticConnectionOptions options = null) : base(index, timeout, options) { if (client == null) throw new ArgumentNullException("client"); this.client = client; }
public ElasticClient(ITransport <IConnectionSettingsValues> transport) { transport.ThrowIfNull(nameof(transport)); transport.Settings.ThrowIfNull(nameof(transport.Settings)); transport.Settings.Serializer.ThrowIfNull(nameof(transport.Settings.Serializer)); transport.Settings.Inferrer.ThrowIfNull(nameof(transport.Settings.Inferrer)); this.Transport = transport; this.Raw = new ElasticsearchClient(this.Transport); this.LowLevelDispatch = new LowLevelDispatch(this.Raw); }
public MongoIndexingForElasticJob( ISearchableTextService searchableTextService, IElasticsearchClient elasticsearchClient, IApplicationPropertyDao applicationPropertyDao, ILogger <MongoIndexingForElasticJob> logger) { _searchableTextService = searchableTextService; _elasticsearchClient = elasticsearchClient; _applicationPropertyDao = applicationPropertyDao; _logger = logger; }
public void PrepareConfiguration(IElasticsearchClient client) { var valueRxString = "(?:\"([^\"]+)\"" + "|'([^']+)'" + "|\\(([^\\)]+)\\)" + "|\\[([^\\]]+)\\]" + "|([^" + FieldSplit + "]+))"; _kvRegex = new Regex( string.Format("([^{0}{1}]+)\\s*[{1}]\\s*{2}", FieldSplit, ValueSplit, valueRxString) , RegexOptions.Compiled | RegexOptions.Multiline); }
public MasterScheduler(IEventQueueOperator eventQueueOperator, IConfigurationValueProvider configurationValueProvider, ISourceConfiguration sourceConfiguration, IElasticsearchClient elasticsearchClient, IServiceLocator locator) { _sourceConfiguration = sourceConfiguration; _locator = locator; _elasticsearchClient = elasticsearchClient; _configurationValueProvider = configurationValueProvider; _eventQueueOperator = eventQueueOperator; }
public MasterScheduler(IEventQueueOperator eventQueueOperator, IConfigurationValueProvider configurationValueProvider, ISourceConfiguration sourceConfiguration, IElasticsearchClient elasticsearchClient, IServiceLocator locator) { _sourceConfiguration = sourceConfiguration; _locator = locator; _elasticsearchClient = elasticsearchClient; _configurationValueProvider = configurationValueProvider; _eventQueueOperator = eventQueueOperator; }
static YamlTestsBase() { var host = "localhost"; if (Process.GetProcessesByName("fiddler").Any()) host = "ipv4.fiddler"; var uri = new Uri("http://"+host+":9200/"); var settings = new ElasticsearchConnectionSettings(uri).UsePrettyResponses(); _client = new ElasticsearchClient(settings); var infoResponse = _client.Info(); dynamic info = infoResponse.Response; _versionNumber = new Version(info.version.number); }
public void PrepareConfiguration(IElasticsearchClient client) { var valueRxString = "(?:\"([^\"]+)\"" + "|'([^']+)'" + "|\\(([^\\)]+)\\)" + "|\\[([^\\]]+)\\]" + "|([^" + FieldSplit + "]+))"; _kvRegex = new Regex( string.Format("([^{0}{1}]+)\\s*[{1}]\\s*{2}", FieldSplit, ValueSplit, valueRxString) , RegexOptions.Compiled | RegexOptions.Multiline); }
public ConfluenceJob(IConfluenceHttpClient confluenceHttpClient, IElasticsearchClient elasticsearchClient, IApplicationPropertyDao applicationPropertyDao, IOptions <ConfluenceSettings> settings, ILogger <ConfluenceJob> logger) { _confluenceHttpClient = confluenceHttpClient; _elasticsearchClient = elasticsearchClient; _applicationPropertyDao = applicationPropertyDao; _settings = settings; _logger = logger; }
internal static ElasticsearchResponse <T> WatcherStopDispatch <T>(this IElasticsearchClient client, ElasticsearchPathInfo <StopWatcherRequestParameters> elasticsearchPathInfo, string watchId = null, string actionId = null, Metric metric = Metric.All) { var pathInfo = elasticsearchPathInfo.ToWatcherPathInfo(watchId, actionId, metric); switch (pathInfo.HttpMethod) { case PathInfoHttpMethod.PUT: //PUT /_watcher/_stop return(client.WatcherStop <T>(u => pathInfo.RequestParameters)); } throw new DispatchException("Could not dispatch IElasticClient.WatcherStop() into any of the following paths: \r\n - /_watcher/_stop"); }
protected override void InitializeTarget() { base.InitializeTarget(); var uri = GetConnectionString(ConnectionStringName) ?? Uri; var nodes = uri.Split(',').Select(url => new Uri(url)); var connectionPool = new StaticConnectionPool(nodes); var config = new ConnectionConfiguration(connectionPool); _client = new ElasticsearchClient(config, serializer:ElasticsearchSerializer); if (!String.IsNullOrEmpty(ExcludedProperties)) _excludedProperties = new List<string>(ExcludedProperties.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries)); }
public JiraJob( ILogger <JiraJob> logger, IElasticsearchClient elasticsearchClient, IApplicationPropertyDao applicationPropertyDao, IJiraClient jiraClient, IOptions <JiraSettings> settings) { _logger = logger; _elasticsearchClient = elasticsearchClient; _applicationPropertyDao = applicationPropertyDao; _jiraClient = jiraClient; _settings = settings; }
public override void ActivateOptions() { _client = new WebElasticClient(Server, Port); if (Template != null && Template.IsValid) { _client.PutTemplateRaw(Template.Name, File.ReadAllText(Template.FileName)); } ElasticFilters.PrepareConfiguration(_client); RestartTimer(); }
public override void ActivateOptions() { _client = new WebElasticClient(Server, Port, Ssl, AllowSelfSignedServerCert, BasicAuthUsername, BasicAuthPassword); if (Template != null && Template.IsValid) { _client.PutTemplateRaw(Template.Name, File.ReadAllText(Template.FileName)); } ElasticFilters.PrepareConfiguration(_client); RestartTimer(); }
/// <summary> /// Create a new ElasticNetConnection with the given parameters defining its properties. /// </summary> /// <param name="client">The ElasticsearchClient to use in order to contact elasticsearch.</param> /// <param name="timeout">TimeSpan to wait for network responses before failing (optional, defaults to 10 seconds).</param> /// <param name="index">Name of the index to use on the server (optional).</param> /// <param name="options">Additional options that specify how this connection should behave.</param> public ElasticNetConnection( IElasticsearchClient client, string index = null, TimeSpan?timeout = null, ElasticConnectionOptions options = null) : base(index, timeout, options) { if (client == null) { throw new ArgumentNullException(nameof(client)); } this.client = client; }
protected override void InitializeTarget() { base.InitializeTarget(); ConnectionStringSettings connectionStringSettings = null; if (!string.IsNullOrEmpty(ConnectionStringName)) connectionStringSettings = ConfigurationManager.ConnectionStrings[ConnectionStringName]; var uri = connectionStringSettings == null ? Uri : connectionStringSettings.ConnectionString; var nodes = uri.Split(',').Select(url => new Uri(url)); var connectionPool = new StaticConnectionPool(nodes); var config = new ConnectionConfiguration(connectionPool); _client = new ElasticsearchClient(config, serializer:ElasticsearchSerializer); }
/// <summary> /// Projects the specified message asynchronously. /// </summary> /// <param name="client">The Elasticsearch client used during projection.</param> /// <param name="message">The message to project.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// A <see cref="Task" />. /// </returns> /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="client"/> or <paramref name="message"/> is <c>null</c>.</exception> public async Task ProjectAsync(IElasticsearchClient client, object message, CancellationToken cancellationToken) { if (client == null) throw new ArgumentNullException("client"); if (message == null) throw new ArgumentNullException("message"); ElasticsearchProjectionHandler[] handlers; if (_handlers.TryGetValue(message.GetType(), out handlers) && handlers.Length > 0) { foreach (var handler in handlers) { await handler.Handler(client, message, cancellationToken); } } }
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); }
public override void ActivateOptions() { _client = new WebElasticClient(Server, Port, Ssl, AllowSelfSignedServerCert, BasicAuthUsername, BasicAuthPassword); LogEventFactory.Configure(this); if (Template != null && Template.IsValid) { _client.PutTemplateRaw(Template.Name, File.ReadAllText(Template.FileName)); } ElasticFilters.PrepareConfiguration(_client); RestartTimer(); }
protected override void InitializeTarget() { base.InitializeTarget(); var uri = GetConnectionString(ConnectionStringName) ?? Uri; var nodes = uri.Split(',').Select(url => new Uri(url)); var connectionPool = new StaticConnectionPool(nodes); var config = new ConnectionConfiguration(connectionPool); _client = new ElasticsearchClient(config, serializer: ElasticsearchSerializer); if (!String.IsNullOrEmpty(ExcludedProperties)) { _excludedProperties = new List <string>(ExcludedProperties.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries)); } }
internal static ElasticsearchResponse <T> WatcherDeleteWatchDispatch <T>(this IElasticsearchClient client, ElasticsearchPathInfo <DeleteWatchRequestParameters> elasticsearchPathInfo, string watchId = null, string actionId = null, Metric metric = Metric.All) { var pathInfo = elasticsearchPathInfo.ToWatcherPathInfo(watchId, actionId, metric); switch (pathInfo.HttpMethod) { case PathInfoHttpMethod.DELETE: //DELETE /_watcher/watch/{id} if (!pathInfo.Id.IsNullOrEmpty()) { return(client.WatcherDeleteWatch <T>(pathInfo.Id, u => pathInfo.RequestParameters)); } break; } throw new DispatchException("Could not dispatch IElasticClient.WatcherDeleteWatch() into any of the following paths: \r\n - /_watcher/watch/{id}"); }
public override void ActivateOptions() { _client = new WebElasticClient(Server, Port, Ssl, AllowSelfSignedServerCert, BasicAuthUsername, BasicAuthPassword, UseAWS4Signer, AWS4SignerRegion, AWS4SignerAccessKey, AWS4SignerSecretKey, ElasticSearchTimeout); LogEventFactory.Configure(this); if (Template != null && Template.IsValid) { _client.PutTemplateRaw(Template.Name, File.ReadAllText(Template.FileName)); } ElasticFilters.PrepareConfiguration(_client); RestartTimer(); }
public override void ActivateOptions() { AddOptionalServer(); _client = new WebElasticClient(Servers, ElasticSearchTimeout, Ssl, AllowSelfSignedServerCert, AuthenticationMethod); LogEventFactory.Configure(this); if (Template != null && Template.IsValid) { _client.PutTemplateRaw(Template.Name, File.ReadAllText(Template.FileName)); } ElasticFilters.PrepareConfiguration(_client); RestartTimer(); }
internal static ElasticsearchResponse <T> WatcherStatsDispatch <T>(this IElasticsearchClient client, ElasticsearchPathInfo <WatcherStatsRequestParameters> elasticsearchPathInfo, string watchId = null, string actionId = null, Metric metric = Metric.All) { var pathInfo = elasticsearchPathInfo.ToWatcherPathInfo(watchId, actionId, metric); switch (pathInfo.HttpMethod) { case PathInfoHttpMethod.GET: //GET /_watcher/stats/{metric} if (pathInfo.Metric != null) { return(client.WatcherStats <T>(pathInfo.Metric, u => pathInfo.RequestParameters)); } //GET /_watcher/stats return(client.WatcherStats <T>(u => pathInfo.RequestParameters)); } throw new DispatchException("Could not dispatch IElasticClient.WatcherStats() into any of the following paths: \r\n - /_watcher/stats\r\n - /_watcher/stats/{metric}"); }
protected override void InitializeTarget() { base.InitializeTarget(); ConnectionStringSettings connectionStringSettings = null; if (!string.IsNullOrEmpty(ConnectionName)) { connectionStringSettings = ConfigurationManager.ConnectionStrings[ConnectionName]; } var nodes = connectionStringSettings != null?connectionStringSettings.ConnectionString.Split(',').Select(url => new Uri(url)) : new[] { new Uri(string.Format("http://{0}:{1}", Host, Port)) }; var connectionPool = new StaticConnectionPool(nodes); var config = new ConnectionConfiguration(connectionPool); _client = new ElasticsearchClient(config, serializer: new NewtonsoftJsonSerializer()); }
public ElasticsearchProjectionHandlerCall(IElasticsearchClient client, object message, CancellationToken token) { Client = client; Message = message; Token = token; }
public ElasticClient(IElasticsearchClient elasticsearchClient) { _elasticsearchClient = elasticsearchClient; }
/// <summary> /// Projects the specified message asynchronously. /// </summary> /// <param name="client">The Elasticsearch client used during projection.</param> /// <param name="message">The message to project.</param> /// <returns> /// A <see cref="Task" />. /// </returns> /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="client"/> or <paramref name="message"/> is <c>null</c>.</exception> public Task ProjectAsync(IElasticsearchClient client, object message) { return ProjectAsync(client, message, CancellationToken.None); }
public LowLevelDispatch(IElasticsearchClient rawElasticClient) { this._lowLevel = rawElasticClient; }
private void StartupElasticSearch(){ var settings = new ConnectionSettings(hostElastic); //clientElastic = new ElasticsearchClient(); clientElasticNest = new ElasticClient(settings); clientElastic = clientElasticNest.Raw; }
/// <summary> /// Projects the specified messages asynchronously. /// </summary> /// <param name="client">The Elasticsearch client used during projection.</param> /// <param name="messages">The messages to project.</param> /// <returns> /// A <see cref="Task" />. /// </returns> /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="client"/> or <paramref name="messages"/> are <c>null</c>.</exception> public Task ProjectAsync(IElasticsearchClient client, IEnumerable<object> messages) { return ProjectAsync(client, messages, CancellationToken.None); }
public void SetUp() { _client = new ElasticsearchClient(); _calls = new List<ElasticsearchProjectionHandlerCall>(); var handler1 = new ElasticsearchProjectionHandler( typeof(MatchMessage1), (client, msg, token) => { _calls.Add(new ElasticsearchProjectionHandlerCall(client, msg, token)); return Task.FromResult(false); }); var handler2 = new ElasticsearchProjectionHandler( typeof(MatchMessage2), (client, msg, token) => { _calls.Add(new ElasticsearchProjectionHandlerCall(client, msg, token)); return Task.FromResult(false); }); var handler3 = new ElasticsearchProjectionHandler( typeof(MatchMessage1), (client, msg, token) => { _calls.Add(new ElasticsearchProjectionHandlerCall(client, msg, token)); return Task.FromResult(false); }); var handler4 = new ElasticsearchProjectionHandler( typeof(MatchMessage2), (client, msg, token) => { _calls.Add(new ElasticsearchProjectionHandlerCall(client, msg, token)); return Task.FromResult(false); }); _sut = SutFactory(new[] { handler1, handler2, handler3, handler4 }); }
public void PrepareConfiguration(IElasticsearchClient client) { }
/// <summary> /// Projects the specified messages asynchronously. /// </summary> /// <param name="client">The Elasticsearch client used during projection.</param> /// <param name="messages">The messages to project.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// A <see cref="Task" />. /// </returns> /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="client"/> or <paramref name="messages"/> are <c>null</c>.</exception> public async Task ProjectAsync(IElasticsearchClient client, IEnumerable<object> messages, CancellationToken cancellationToken) { if (client == null) throw new ArgumentNullException("client"); if (messages == null) throw new ArgumentNullException("messages"); foreach (var message in messages) { ElasticsearchProjectionHandler[] handlers; if (!_handlers.TryGetValue(message.GetType(), out handlers)) continue; foreach (var handler in handlers) { await handler.Handler(client, message, cancellationToken); } } }
public RawDispatch(IElasticsearchClient rawElasticClient) { this.Raw = rawElasticClient; }
public void SetUp() { _client = new ElasticsearchClient(); }