in elastic_transport/_transport.py [0:0]
def warn_if_varying_node_config_options(node_configs: List[NodeConfig]) -> None:
"""Function which detects situations when sniffing may produce incorrect configs"""
exempt_attrs = {"host", "port", "connections_per_node", "_extras", "ssl_context"}
match_attr_dict = None
for node_config in node_configs:
attr_dict = {
field.name: getattr(node_config, field.name)
for field in dataclasses.fields(node_config)
if field.name not in exempt_attrs
}
if match_attr_dict is None:
match_attr_dict = attr_dict
# Detected two nodes that have different config, warn the user.
elif match_attr_dict != attr_dict:
warnings.warn(
"Detected NodeConfig instances with different options. "
"It's recommended to keep all options except for "
"'host' and 'port' the same for sniffing to work reliably.",
category=TransportWarning,
stacklevel=warn_stacklevel(),
)