-
Notifications
You must be signed in to change notification settings - Fork 556
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to async AWS SDK v2 for Facia JSON download
Context: #26335 In this change: * Use AWS SDK v2 and non-blocking async code to avoid blocking a thread while downloading the Facia JSON data from S3 * Directly transform bytes into JsValue, without constructing a `String` first Note that the work done between the two metrics `FrontDownloadLatency` & `FrontDecodingLatency` has changed slightly - the conversion to the basic JSON model (JsValue) now occurs in `FrontDownloadLatency`, rather than the 'decoding' step. We could get rid of the futureSemaphore and stop using the dedicated blocking-operations pool here, but we'll leave that to another PR. Co-authored-by: Ravi <[email protected]> Co-authored-by: Ioanna Kokkini <[email protected]>
- Loading branch information
Showing
6 changed files
with
116 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package utils | ||
|
||
import software.amazon.awssdk.auth.credentials._ | ||
import software.amazon.awssdk.awscore.client.builder.AwsClientBuilder | ||
import software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient | ||
import software.amazon.awssdk.regions.Region | ||
import software.amazon.awssdk.regions.Region.EU_WEST_1 | ||
import software.amazon.awssdk.services.s3.S3AsyncClient | ||
import software.amazon.awssdk.services.s3.S3AsyncClientBuilder | ||
|
||
object AWSv2 { | ||
val region: Region = EU_WEST_1 | ||
|
||
def credentialsForDevAndProd(devProfile: String, prodCreds: AwsCredentialsProvider): AwsCredentialsProviderChain = | ||
AwsCredentialsProviderChain.of(prodCreds, ProfileCredentialsProvider.builder().profileName(devProfile).build()) | ||
|
||
lazy val credentials: AwsCredentialsProvider = | ||
credentialsForDevAndProd("frontend", InstanceProfileCredentialsProvider.create()) | ||
|
||
def build[T, B <: AwsClientBuilder[B, T]](builder: B): T = | ||
builder.credentialsProvider(credentials).region(region).build() | ||
|
||
val S3Async: S3AsyncClient = build[S3AsyncClient, S3AsyncClientBuilder]( | ||
S3AsyncClient.builder().httpClientBuilder(NettyNioAsyncHttpClient.builder().maxConcurrency(250)), | ||
) | ||
} |