Search...::Sniff(3pm)

πŸ“¦
version 8.12 Β· 5 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Search::Elasticsearch::Role::CxnPool::Sniff πŸ’–

okay bestie so this is a role from the User Contributed Perl Documentation corner of the world, and it's literally the CxnPool role that lets you connect to a local cluster with a dynamic node list. sniff sniff, we're detecting nodes out here πŸ¦‹


✨ VERSION ✨

version 8.12 β€” periodt, that's the one.


πŸŽ€ CONFIGURATION πŸŽ€

🌸 sniff_interval

How often are we gonna do a lil sniff to clock whether new nodes have joined the cluster? Defaults to 300 seconds. So every five minutes we're peeking πŸ‘€

🌸 sniff_max_content_length

Should we set max_content_length dynamically while sniffing, yes or yes? Defaults to true, unless a fixed max_content_length was specified β€” then we respect that, no cap.


πŸ‘‘ METHODS πŸ‘‘

πŸ’… schedule_check()

$cxn_pool->schedule_check

Schedules a sniff before the next request gets processed. So the vibe check happens before we go anywhere, iconic behaviour fr fr.

πŸ’… parse_sniff()

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

This one parses the response from a sniff request and pulls out the hostname/ip of every single listed node, filtered through should_accept_node(). If any live nodes show up, they get passed along to set_cxns() in Search::Elasticsearch::Role::CxnPool. Oh and the max_content_length is also detected if sniff_max_content_length is true. multi-tasking queen πŸ’–

πŸ’… should_accept_node()

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

This method is a hook β€” meaning you, yes YOU, can override it. When a sniff happens, this gets called with the host (eg 192.168.5.100:9200), the node_id (the ID Elasticsearch assigned to that node) and the node_data, which holds all the info about the node that Elasticsearch sent back, eg:

{
    "transport_address" => "inet[192.168.5.100/192.168.5.100:9300]",
    "http" : {
       "publish_address"    => "inet[/192.168.5.100:9200]",
       "max_content_length" => "100mb",
       "bound_address"      => "inet[/0:0:0:0:0:0:0:0:9200]",
       "max_content_length_in_bytes" : 104857600
    },
    "version"       => "0.90.4",
    "name"          => "Silver Sable",
    "hostname"      => "search1.domain.com",
    "http_address"  => "inet[/192.168.5.100:9200]"
}

If the node should be accepted (aka used to serve data, main character energy), then return the host value you wanna use. By default? nodes are always accepted. generous queen 🫢


πŸ’œ AUTHOR πŸ’œ

Enrico Zimuel <enrico.zimuel@elastic.co>


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

This is free software, licensed under:

The Apache License, Version 2.0, January 2004

and that's the whole page bestie, no crumbs left behind πŸ’…

kisses, this was brought to you by perl v5.38.2, dated 2024-02-04 β€” Search...::Sniff(3pm) signing off, mwah πŸŽ€βœ¨

πŸ“¦ where this page comes from