Skip to content
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

Make hostname and credentials customisable per request #161

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

codemedic
Copy link

Most part of the change is to reduce global state, while keeping the API as close to original as possible. Please note that there are breaking changes, but I hope you will find them OK to live with.

I have also taken the liberty of adding a license file to match what is mentioned in composer.json and S3.php, and I have also added my employer to the list of copyrights, considering the amount of changes and the time spent doing them.

There are some tweaks to make examples work better with composer's autoloading. Also changes to those examples to make it load values through environment variables rather than having to edit the files.

I have tested these as much as I can against S3 and an in house implementation of S3 like storage access layer.

codemedic and others added 15 commits October 1, 2019 16:51
This makes it possible to customise the endpoint / hostname per request, rather than having the static / global state.

NOTES:
1. A great level of effort has been put in to make sure backward compatibility changes to be minimal, but there are cases that couldn't have been avoided. Sorry peeps!

2. Also some custom business logic for bucket region deduction has been removed, and has been replaced with a callback.

Other changes
* Reduce global / static state in S3 class
* Various efficiency tweaks
* Various formatting tweaks
* Removed the region deducer callback; RTFM for me!
* Added workaround to avoid 307 redirects by always talking to the correct regional-service-endpoint. This also improves performance overall as it requires less network magic in AWS.
* Fixed examples such that no code need to be modified in order to run them; takes parameters from environment.
* Tweaks to composer.json to fix autoloading and to specify extension requirements.
* Added export-ignore git attributes to remove dev artifacts from composer install when included into other projects.
Turned ON via an env variable SIGNATURE_DEBUG=ON
@codemedic
Copy link
Author

codemedic commented Oct 4, 2019

@tpyo forgot to mention that there is also an optimisation to make the examples work against S3 regions that redirects using 307 Temporary Redirect, where we would have had to re-authenticate on receiving the response code. The 307 redirects were particularly a headache as we (rightly) create buckets within the test, and it takes 24Hrs to work without the 307 redirect (for the newly created bucket, if we go to <bucket>.s3.amazonaws.com).

I have changed according to the workaround suggested in AWS docs; rather than always going to [<bucket>.]s3.amazonaws.com the request is sent to a region specific service endpoint. This generally makes things faster as less DNS magic is involved to hit the right endpoint within AWS.

Hostname / endpoint is formulated using the pattern described here

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.

1 participant