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

refactor!: replace default HTTP client engine #554

Merged
merged 5 commits into from
Mar 21, 2022
Merged

refactor!: replace default HTTP client engine #554

merged 5 commits into from
Mar 21, 2022

Conversation

aajtodd
Copy link
Contributor

@aajtodd aajtodd commented Mar 18, 2022

Issue #

sibling: smithy-lang/smithy-kotlin#606

Description of changes

This PR swaps the default client HTTP engine from the CRT one to an opaque KMP compatible engine. The new default is one backed by Ktor/OkHttp. The existing CRT engine can still be used if desired but requires explicitly setting it.

Also in this PR is a modification of some of the e2e tests. The "big list of naughty" strings has been removed from S3 presign tests. These are not particularly representative of real object keys and are not recommended by S3 guidelines on object key naming. I've replaced it with a simpler test. We can add to this as needed. The presign tests now execute against the default and CRT engine to ensure we aren't introducing regressions across the HTTP engines we explicitly support.

Breaking Change

This change is technically not a breaking change in API but may result in a change in behavior or exceptions seen by users. If you wish to continue using the CRT based HTTP engine you can explicitly configure it:

  1. Add the dependency to your project e.g. implementation("aws.smithy.kotlin:http-client-engine-crt:0.7.9")
  2. Explicitly provide the engine when creating a client
val engine = CrtEngine()
val s3 = S3Client {
    ...
    httpClientEngine = engine
}

...

// NOTE: in addition to the service client you are now responsible for the lifetime of the engine as well
s3.close()
engine.close()

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@aajtodd aajtodd requested a review from a team as a code owner March 18, 2022 16:22
@github-actions
Copy link

A new generated diff is ready to view: __generated-main...__generated-default-engine

@aajtodd aajtodd requested a review from ianbotsf March 18, 2022 18:19
/**
* Printable ASCII characters
*/
val PRINTABLE_CHARS = ByteArray(127 - 32) { (it + 32).toByte() }.decodeToString()
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment: Possibly cleaner:

val PRINTABLE_CHARS = (32..127).map(Int::toChar).joinToString("")

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@github-actions
Copy link

A new generated diff is ready to view: __generated-main...__generated-default-engine

@aajtodd aajtodd merged commit d12febb into main Mar 21, 2022
@aajtodd aajtodd deleted the default-engine branch March 21, 2022 14:45
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