8000 Middleware restructure by adam-fowler · Pull Request #570 · soto-project/soto-core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Middleware restructure #570

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 14 commits into from
Aug 2, 2023
Merged

Middleware restructure #570

merged 14 commits into from
Aug 2, 2023

Conversation

adam-fowler
Copy link
Member
  • Rewrite middleware to pass request onto next middleware instead of just editing request/response and returning it. eg
struct MyMiddleware: AWSMiddlewareProtocol {
    public func handle(
        _ request: AWSHTTPRequest, 
        context: AWSMiddlewareContext, 
        next: (AWSHTTPRequest, AWSMiddlewareContext) async throws -> AWSHTTPResponse
    ) async throws -> AWSHTTPResponse {
        let request = doStuffToRequest(request)
        let response = try await next(request, context)
        return doStuffToResponse(response)
    }
}
  • Use result builder AWSMiddlewareStack to build middleware stack
  • Convert each stage of the Soto execute chain to a middleware eg signing, retry, error handling, endpoint discovery
  • execute is now
    • create request,
    • run middleware on request, passing final request to http client
    • process response returned from middleware to create output object

@adam-fowler adam-fowler marked this pull request as draft July 24, 2023 14:43
@adam-fowler adam-fowler force-pushed the merge-request-response branch from ccaf8e8 to 80cd46b Compare July 24, 2023 16:23
@adam-fowler adam-fowler force-pushed the middleware-restructure branch from a4905b0 to 668a13d Compare July 24, 2023 16:24
Base automatically changed from merge-request-response to 7.x.x July 28, 2023 14:39
@adam-fowler adam-fowler marked this pull request as ready for review July 28, 2023 14:44
@adam-fowler adam-fowler force-pushed the middleware-restructure branch 2 times, most recently from 032751c to a04b984 Compare July 29, 2023 07:54
@codecov
Copy link
codecov bot commented Jul 29, 2023

Codecov Report

Merging #570 (74a4123) into 7.x.x (74a4123) will not change coverage.
The diff coverage is n/a.

❗ Current head 74a4123 differs from pull request most recent head be1c747. Consider uploading reports for the commit be1c747 to get more accurate results

@@           Coverage Diff           @@
##            7.x.x     #570   +/-   ##
=======================================
  Coverage   78.86%   78.86%           
=======================================
  Files          73       73           
  Lines        6467     6467           
=======================================
  Hits         5100     5100           
  Misses       1367     1367           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member
@0xTim 0xTim left a comment

Choose a reason for hiding this comment

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

Some minor documentation nits but LGTM

@adam-fowler adam-fowler force-pushed the middleware-restructure branch from cba57f6 to b17f6fa Compare August 2, 2023 06:45
@adam-fowler adam-fowler force-pushed the middleware-restructure branch from 5f21940 to be1c747 Compare August 2, 2023 06:54
@adam-fowler adam-fowler merged commit 3d5720c into 7.x.x Aug 2, 2023
@adam-fowler adam-fowler deleted the middleware-restructure branch August 2, 2023 07:02
adam-fowler added a commit that referenced this pull request Aug 12, 2023
* Re-org request and response middleware

So these are applied in same function

* MiddlewareStack

* Multiple AWSClient inits

* Add Error handling middleware

* Add retry middleware

* Add fix up for S3 notFound errors

* Add endpoint discovery middleware

* Endpoint middleware fixes

* Add streaming parameter to stop collation of body

* Add fixup for getBucketLocation

* @preconcurrency import struct Foundation.CharacterSet

* formatting

* Update Sources/SotoCore/AWSClient.swift

Co-authored-by
A002
: Tim Condon <0xTim@users.noreply.github.com>

* comments

---------

Co-authored-by: Tim Condon <0xTim@users.noreply.github.com>
adam-fowler added a commit that referenced this pull request Dec 24, 2023
* Re-org request and response middleware

So these are applied in same function

* MiddlewareStack

* Multiple AWSClient inits

* Add Error handling middleware

* Add retry middleware

* Add fix up for S3 notFound errors

* Add endpoint discovery middleware

* Endpoint middleware fixes

* Add streaming parameter to stop collation of body

* Add fixup for getBucketLocation

* @preconcurrency import struct Foundation.CharacterSet

* formatting

* Update Sources/SotoCore/AWSClient.swift

Co-authored-by: Tim Condon <0xTim@users.noreply.github.com>

* comments

---------

Co-authored-by: Tim Condon <0xTim@users.noreply.github.com>
adam-fowler added a commit that referenced this pull request Apr 5, 2024
* Re-org request and response middleware

So these are applied in same function

* MiddlewareStack

* Multiple AWSClient inits

* Add Error handling middleware

* Add retry middleware

* Add fix up for S3 notFound errors

* Add endpoint discovery middleware

* Endpoint middleware fixes

* Add streaming parameter to stop collation of body

* Add fixup for getBucketLocation

* @preconcurrency import struct Foundation.CharacterSet

* formatting

* Update Sources/SotoCore/AWSClient.swift

Co-authored-by: Tim Condon <0xTim@users.noreply.github.com>

* comments

---------

Co-authored-by: Tim Condon <0xTim@users.noreply.github.com>
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.

2 participants
0