-
Notifications
You must be signed in to change notification settings - Fork 58
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
Psr interfaces #233
base: main
Are you sure you want to change the base?
Psr interfaces #233
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.
I love this change, thank you! Let's iterate till we get this to green. I think it's a lot simpler than #228, what do you think @shyim?
- Sign DCO,
git commit -s --amend
for existing commits, force push. - Add to CHANGELOG.
- Let's add an UPGRADING.md like https://github.com/opensearch-project/opensearch-py/blob/main/UPGRADING.md with details on migrating to this version.
- Should we keep a
OpenSearch\ClientBuilder
even with different parameters for easier migration?
82721bd
to
2f4661d
Compare
I noticed you tried to fix DCO?
Something is not adding up between your settings and the commit signature. |
16b664e
to
f14e9a2
Compare
I think I fixed that now? Let me know if it's still not rigt. I've updated the ClientBuilder and refactored the endpoints callable into it's own factory class. I think this makes it easier to understand, and also allows clients to swap out an implementation or use a dependency injection container if they want. I updated the client and namespace templates also. I regenerated afterwards and it looks like there are a lot of new API methods added. Should I use something other than https://github.com/opensearch-project/opensearch-api-specification/releases/download/main-latest/opensearch-openapi.yaml ? |
I think setHandler are not working anymore right? So aws sig v4 needs to be adjusted? |
Yes, I think we'd need to rewrite the guzzle middleware/handler without the ring dependency to make it easier for people who use AWS OpenSearch service to use signed requests. |
Yep looks good.
👍
Let's work on merging #223 separately from this not to mix in the PSR changes. It needs some attention to tests. If nobody picks it up here I can do it soon. |
be04c45
to
df01728
Compare
Thinking about this more, returning HTTP Response might not be the best DX. We should introduce a The Promise would also return this too. Thoughts? |
@kimpepper In other clients we return a strongly typed object that derives from a base class that also gives access to the underlying raw HTTP response from the network library "as is" along with some helper methods like status code or raw body. Note that OpenSearch returns more than JSON, too. |
I fixed what was broken in #223 and merged, rebase. |
I think the strongly typed object would require a lot of work on the generator side and might be out of scope for this issue? Not sure whether it's worth a simple wrapper around the PSR Response and HTTP Promise that gets returned? |
From my understanding the response content types can be one of:
but I couldn't find the docs to back that up. |
100%
I would if we think it makes it easier to extend it later in a common way across multiple transports (it feels like it would). |
We cover the range in https://github.com/opensearch-project/opensearch-api-specification, see https://github.com/opensearch-project/opensearch-api-specification/blob/07e329e8d01fd0576de6a0a3c35412fd5a9163db/tools/src/tester/MimeTypes.ts#L10. OpenSearch returns plain text, JSON, nd-json, CBOR, SMILE, and YAML, most from cat APIs. Did you see XML somewhere? That may be a miss in API specs :) |
df01728
to
ec11701
Compare
I created a separate PR #236 to deal with the bulk change to |
Split out #237 for the endpoint factory changes here. |
Thanks @kimpepper! Let's work through those. |
@kimpepper rebase let's see what this looks like? |
I think there is a fair bit to do if we are dropping async support in this PR. |
Signed-off-by: Kim Pepper <kim@pepper.id.au>
ec11701
to
ce60d42
Compare
I did a basic rebase off Should we split off removing the async client? |
Thinking about this a bit further, we can keep the existing Still need to figure out how to handle BC for the return types. |
This one is a major upgrade that is definitely worth it, so I would introduce this as a breaking change. This is also the right time to change what these APIs return and really try to pack all the breakages in one major upgrade. |
This PR seems to remove all support for sigv4. Shouldn't it provide a PSR client decorator implementing the sigv4 logic, as all other opensearch clients are shipping support for sigv4 to support the AWS managed opensearch service ? |
Yes, we definitely do not want to lose Sigv4 functionality. Breaking change is OK, but we need all the existing features. |
In the other issues we are trying to keep a BC layer for the 2.x branch. Are we saying this PR would go straight into a 3.x branch without any deprecations in 2.x? If we try to get this in 2.x and provide BC this PR will:
This seems like quite a lot. Do you agree with the approach? Do you think we can split any of this out to sub-tasks or follow-ups? |
All breaking changes must go to main which will be the next major version of the client (3.0.0).
If it's really not working and never worked, it's not a feature, and we can take a delete in 2.x before this to trim the code. Only breaking changes warrant a 3.0. If the sum of these can be done in a way of being deprecated -> added then we can continue doing it incrementally. I think you know best @kimpepper :) |
Yes, the intention is to provide deprecations in 2.x to allow users to upgrade to the Psr approach before 3.x is released. |
I've pushed new code to implement the concepts above I haven't looked at tests yet. |
Signed-off-by: Kim Pepper <kim@pepper.id.au>
faf6f5c
to
03f5549
Compare
@dblock async requests are working in the existing codebase for the method allowing to do a raw request ( |
$this->transport = $transport; | ||
$this->httpTransport = new LegacyTransportWrapper($transport); | ||
} else { | ||
$this->httpTransport = $transport; |
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.
This technically changes the type of the public $transport
property to Transport|null
as it does not assign a transport.
Got it. I would remove it and see if anyone complains, but technically it's a breaking change. I will 🙈 if it gets removed. |
Signed-off-by: Kim Pepper <kim@pepper.id.au>
2d83a39
to
225edda
Compare
Signed-off-by: Kim Pepper <kim@pepper.id.au>
db86f11
to
f9b7f1a
Compare
Signed-off-by: Kim Pepper <kim@pepper.id.au>
Fixes #199
Description
This PR removes the dependency on a specific HTTP client implementation and introduces PSR-7, PSR-17 and PSR-18 interfaces.
Issues Resolved
It greatly simplifies the volume and complexity of the library codebase and removes the need to manage:
Users of this library can choose from a number of synchronous and asynchronous HTTP clients including:
It greatly simplifies the volume and complexity of the library codebase. Specifically, it:
ezimuel/ringphp
which is not longer getting updatesBreaking changes
\Psr\Http\Message\StreamInterface
to decode the response in a memory efficient wayTasks:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.