-
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.
Enable ETag caching with Facia API requests
With guardian/facia-scala-client#287, the Facia client has been updated so that it can take advantage of ETag-caching, using the https://github.com/guardian/etag-caching library already used in Frontend since August 2023 with #26338. As some changes were necessary to the `etag-caching` library to facilitate this, we need to update the version of `etag-caching` used by Frontend to v7.0.0. This does involve switching to AWS SDK v2 - not everywhere in Frontend, just for where we use the Facia client!
- Loading branch information
Showing
5 changed files
with
56 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
package services.fronts | ||
|
||
import com.amazonaws.services.s3.{AmazonS3, AmazonS3Client} | ||
import com.gu.facia.client.{AmazonSdkS3Client, ApiClient} | ||
import com.gu.etagcaching.aws.sdkv2.s3.S3ObjectFetching | ||
import com.gu.facia.client.{ApiClient, Environment} | ||
import conf.Configuration | ||
import software.amazon.awssdk.services.s3.S3AsyncClient | ||
import utils.AWSv2 | ||
|
||
import scala.concurrent.ExecutionContext | ||
|
||
object FrontsApi { | ||
|
||
def crossAccountClient(implicit ec: ExecutionContext): ApiClient = { | ||
val client: AmazonS3 = AmazonS3Client.builder | ||
.withCredentials(Configuration.faciatool.crossAccountMandatoryCredentials) | ||
.withRegion(conf.Configuration.aws.region) | ||
val amazonS3Client = S3AsyncClient.builder | ||
.credentialsProvider(Configuration.faciatool.crossAccountMandatoryCredentials) | ||
.region(AWSv2.region) | ||
.build() | ||
ApiClient( | ||
|
||
ApiClient.withCaching( | ||
Configuration.faciatool.crossAccountSourceBucket, | ||
Configuration.facia.stage.toUpperCase, | ||
AmazonSdkS3Client(client), | ||
Environment(Configuration.facia.stage.toUpperCase), | ||
S3ObjectFetching.byteArraysWith(amazonS3Client), | ||
) | ||
} | ||
} |
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