NAME

Search::Elasticsearch::CxnPool::Async::Sniff - An async CxnPool for connecting to a local cluster with a dynamic node list

VERSION

version 7.717

SYNOPSIS

$e = Search::Elasticsearch::Async->new(
    cxn_pool => 'Async::Sniff',
    nodes    => [
        'search1:9200',
        'search2:9200'
    ],
);

DESCRIPTION

The Async::Sniff connection pool should be used when you do have direct access to the Elasticsearch cluster, eg when your web servers and Elasticsearch servers are on the same network. The nodes that you specify are used to discover the cluster, which is then sniffed to find the current list of live nodes that the cluster knows about.

This sniff process is repeated regularly, or whenever a node fails, to update the list of healthy nodes. So if you add more nodes to your cluster, they will be auto-discovered during a sniff.

If all sniffed nodes fail, then it falls back to sniffing the original seed nodes that you specified in new().

For HTTP Cxn classes, this module will also dynamically detect the max_content_length which the nodes in the cluster will accept.

This class does Search::Elasticsearch::Role::CxnPool::Sniff and Search::Elasticsearch::Role::Is_Async.

CONFIGURATION

nodes

The list of nodes to use to discover the cluster. Can accept a single node, multiple nodes, and defaults to localhost:9200 if no nodes are specified. See "node" in Search::Elasticsearch::Role::Cxn for details of the node specification.

concurrent_sniff

By default, this module will issue up to 4 concurrent sniff requests in parallel, depending on how many nodes are known. The first successful response is used to set the new list of live nodes. Set concurrent_sniff to change the maximum number of concurrent sniff requests.

See also

Inherited configuration

From Search::Elasticsearch::Role::CxnPool::Sniff

From Search::Elasticsearch::Role::CxnPool

METHODS

next_cxn()

$cxn_pool->next_cxn
         -> then( sub { my $cxn = shift })

Returns the next available live node (in round robin fashion), or throws a NoNodes error if no nodes can be sniffed from the cluster.

sniff()

$cxn_pool->sniff->then(
    sub { "ok"     },
    sub { "not_ok" }
);

Sniffs the cluster and returns a promise which is resolved on success, or rejected on failure.

Inherited methods

From Search::Elasticsearch::Role::CxnPool::Sniff

From Search::Elasticsearch::Role::CxnPool

AUTHOR

Enrico Zimuel <enrico.zimuel@elastic.co>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2022 by Elasticsearch BV.

This is free software, licensed under:

The Apache License, Version 2.0, January 2004