NAME

OpenSearch::Client::Role::CxnPool::Sniff - A CxnPool role for connecting to a local cluster with a dynamic node list

VERSION

version 3.007002

CONFIGURATION

sniff_interval

How often should we perform a sniff in order to detect whether new nodes have been added to the cluster. Defaults to `300` seconds.

sniff_max_content_length

Whether we should set the max_content_length dynamically while sniffing. Defaults to true unless a fixed max_content_length was specified.

METHODS

schedule_check()

$cxn_pool->schedule_check

Schedules a sniff before the next request is processed.

parse_sniff()

$bool = $cxn_pool->parse_sniff(\%nodes);

Parses the response from a sniff request and extracts the hostname/ip of all listed nodes, filtered through "should_accept_node()". If any live nodes are found, they are passed to "set_cxns()" in OpenSearch::Client::Role::CxnPool. The max_content_length is also detected if "sniff_max_content_length" is true.

should_accept_node()

$host = $cxn_pool->should_accept_node($host,$node_id,\%node_data)

This method serves as a hook which can be overridden by the user. When a sniff is performed, this method is called with the host (eg 192.168.5.100:9200), the node_id (the ID assigned to the node by OpenSearch) and the node_data which contains the information about the node that OpenSearch has returned, eg:

{
    'transport_address' => '192.168.5.100:9300',
    'http' => {
        'publish_address'   => '192.168.5.100:9200',
        'bound_address'     => [ '[::]:9200' ],
        'max_content_length_in_bytes' => 104857600
    }
    'name'          => 'super-node-100',
    'host'          => '192.168.5.100',
    'ip'            => '192.168.5.100',
    'version'       => '3.7.0',
    'roles'         => [
        'cluster_manager',
        'data',
        'ingest',
        'remote_cluster_client'
    ],
    'attributes'    => {
        'shard_indexing_pressure_enabled' => 'true'
     },
}

If the node should be accepted (ie used to serve data), then it should return the host value to use. By default, nodes are always accepted.

MANUAL

Documentation index OpenSearch::Client::Manual

HISTORY

This distribution is derived from Search::Elasticsearch version 7.714. All subsequent changes are unique to this distribution.

AUTHOR

Mark Dootson <mdootson@cpan.org> ( current maintainer )

CREDITS

OpenSearch::Client is based on Search::Elasticsearch version 7.714 by Enrico Zimuel <enrico.zimuel@elastic.co>.

COPYRIGHT AND LICENSE

Copyright (C) 2026 by Mark Dootson ( this distribution )

Copyright (C) 2021 by Elasticsearch BV ( original distribution )

This is free software, licensed under:

The Apache License, Version 2.0, January 2004