-
Notifications
You must be signed in to change notification settings - Fork 4
Clean up HTTP feature support #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This looks good.
hosts: t.Optional[_TYPE_HOSTS] = None, | ||
host: t.Optional[_TYPE_HOST] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hosts
is so pervasive today that I would still allow it to avoid needlessly breaking users trying out serverless by changing from elasticsearch import ...
to from elasticsearch_serverless import ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get that. I'm going back and forth on it because it seems important to emphasize that, in Serverless, there is always a one-to-one relationship between the host and the instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can support both and only actively document host
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That could work, but it could be more confusing than helpful. If someone provides a hosts
list, does the client pick the first host in the list and log a warning that it's ignoring the rest? Or does it iterate until it finds a host that is healthy? The latter seems more logical (otherwise why support a list at all?), but since it doesn't work just like hosts
on the stack client, it may confuse people migrating over who expect it to work the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I had missed that hosts could be a single string. But believe it or not, many users (including past me) indeed pass a list with a single element: the first page of https://github.com/search?q=Elasticsearch+hosts+language%3APython+&type=code currently shows three such cases.
My proposal is to raise an exception when host
and hosts
are both passed, and when hosts
is a list and contains more than one element. It indeed does not make sense to target multiple hosts in serverless, this is purely for backwards compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be clear it does not have to block this pull request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My proposal is to raise an exception when
host
andhosts
are both passed, and whenhosts
is a list and contains more than one element. It indeed does not make sense to target multiple hosts in serverless, this is purely for backwards compatibility.
I like this. 👍 I'll make a change in this PR before merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 455f9fc
With clarification that those features are only necessary if connecting to serverless via an external proxy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for iterating!
docs/guide/connecting.asciidoc
Outdated
[source,python] | ||
---- | ||
from elasticsearch_serverless import Elasticsearch | ||
|
||
# Adds the HTTP header 'Authorization: ApiKey <base64 api_key.id:api_key.api_key>' | ||
es = Elasticsearch( | ||
"https://localhost:9200", | ||
ca_certs="/path/to/http_ca.crt", | ||
api_key=("api_key.id", "api_key.api_key") | ||
) | ||
---- | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to remove this example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, it occurred to me that it's effectively identical to the example a few lines up. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But then the sentence above promises an example that never comes: https://github.com/elastic/elasticsearch-serverless-python/pull/9/files#diff-9e9ed95442744720a1642e738f4845c8acbdf8b7fde0b964b3119c71c643b6b5R45
We should remove "API keys can be provided to the client constructor or via the per-request .options()
method:" or add an .options()
example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Fixed in 1af86b2
But only one host in hosts list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! LGTM.
Drop support for several HTTP/connection features related to multi-node support:
Also renames
connections_per_node
toconnections
for clarity, enables HTTP compression by default, updates the version number with date metadata, and cleans up the docs to remove references to unsupported HTTP functionality.