Skip to content

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

Merged
merged 16 commits into from
Sep 6, 2023
Merged

Clean up HTTP feature support #9

merged 16 commits into from
Sep 6, 2023

Conversation

JoshMock
Copy link
Member

@JoshMock JoshMock commented Aug 29, 2023

Drop support for several HTTP/connection features related to multi-node support:

  • configuring multiple nodes
  • node selection algorithms (random, round-robin, etc.)
  • sniffing

Also renames connections_per_node to connections 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.

@JoshMock JoshMock marked this pull request as ready for review August 29, 2023 21:36
Copy link
Member

@pquentin pquentin left a 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.

Comment on lines -130 to +123
hosts: t.Optional[_TYPE_HOSTS] = None,
host: t.Optional[_TYPE_HOST] = None,
Copy link
Member

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 ...

Copy link
Member Author

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.

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member Author

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 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.

I like this. 👍 I'll make a change in this PR before merging.

Copy link
Member Author

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.
@JoshMock JoshMock requested a review from pquentin August 30, 2023 16:51
Copy link
Member

@pquentin pquentin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for iterating!

Comment on lines 47 to 58
[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")
)
----

Copy link
Member

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?

Copy link
Member Author

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. 😄

Copy link
Member

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.

Copy link
Member Author

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

@JoshMock JoshMock requested a review from pquentin August 31, 2023 20:00
Copy link
Member

@pquentin pquentin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM.

@JoshMock JoshMock merged commit 7bb2816 into main Sep 6, 2023
@JoshMock JoshMock deleted the drop-http-strategies branch September 6, 2023 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants