petercheon commented on code in PR #66065:
URL: https://github.com/apache/airflow/pull/66065#discussion_r3222886948
##########
providers/elasticsearch/src/airflow/providers/elasticsearch/hooks/elasticsearch.py:
##########
@@ -135,9 +136,9 @@ def __init__(
netloc = f"{host}:{port}"
self.url = parse.urlunparse((scheme, netloc, "/", None, None, None))
if user and password:
- self.es = Elasticsearch(self.url, basic_auth=(user, password),
**kwargs)
+ self.es = apply_compat_with(Elasticsearch(self.url,
basic_auth=(user, password), **kwargs))
Review Comment:
> Small nit you are constructing the Elasticsearch client twice which
creates two transports and extra side effects. Construct a single instance and
pass it to apply_compat_with so the wrapper is applied to the actual client and
you avoid unnecessary work. Example: self.es =
apply_compat_with(Elasticsearch(self.url, basic_auth=(user, password),
**kwargs))
The quoted snippet is the current code —
apply_compat_with(Elasticsearch(self.url, basic_auth=(user, password),
**kwargs)) constructs one client and wraps it in place. If you spotted a
double-construction elsewhere, happy to fix; otherwise I think this one is
already in the shape you're after.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]