Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name := "facia-api-client"

description := "Scala client for The Guardian's Facia JSON API"

ThisBuild / scalaVersion := "2.13.15"
ThisBuild / scalaVersion := "2.13.16"

val sonatypeReleaseSettings = Seq(
releaseVersion := fromAggregatedAssessedCompatibilityWithLatestRelease().value,
Expand All @@ -26,8 +26,7 @@ val sonatypeReleaseSettings = Seq(
def artifactProducingSettings(supportScala3: Boolean) = Seq(
organization := "com.gu",
licenses := Seq(License.Apache2),
resolvers ++= Resolver.sonatypeOssRepos("releases"),
crossScalaVersions := Seq(scalaVersion.value) ++ (if (supportScala3) Seq("3.3.3") else Seq.empty),
crossScalaVersions := Seq(scalaVersion.value) ++ (if (supportScala3) Seq("3.3.6") else Seq.empty),
scalacOptions := Seq(
"-release:8",
"-feature",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.gu.facia.client

import com.gu.etagcaching.FreshnessPolicy.AlwaysWaitForRefreshedValue
import com.gu.etagcaching.aws.s3.{ObjectId, S3ByteArrayFetching}
import com.gu.etagcaching.fetching.Fetching
import com.gu.etagcaching.{ConfigCache, ETagCache}
import com.gu.facia.client.models.{CollectionJson, ConfigJson}
import play.api.libs.json.{Format, Json}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ import scala.util.hashing.MurmurHash3
object FakeS3Fetching extends S3ByteArrayFetching with ResourcesHelper {
private def pretendETagFor(bytes: Array[Byte]): String = MurmurHash3.bytesHash(bytes).toHexString

override def fetch(objectId: ObjectId)(implicit ec: ExecutionContext): Future[MissingOrETagged[Array[Byte]]] = Future {
override def fetch(objectId: ObjectId): Future[MissingOrETagged[Array[Byte]]] = Future.successful {
slurpBytes(objectId.key).fold(Missing: MissingOrETagged[Array[Byte]]) { bytes =>
ETaggedData(pretendETagFor(bytes), bytes)
}
}

override def fetchOnlyIfETagChanged(objectId: ObjectId, oldETag: String)(implicit ec: ExecutionContext): Future[Option[MissingOrETagged[Array[Byte]]]] = {
override def fetchOnlyIfETagChanged(objectId: ObjectId, oldETag: String): Future[Option[MissingOrETagged[Array[Byte]]]] = {
fetch(objectId).map {
case taggedData: ETaggedData[_] =>
case taggedData: ETaggedData[Array[Byte]] =>
Option.unless(oldETag == taggedData.eTag)(taggedData) // simulate a Not-Modified response, if there's no change in ETag
case x => Some(x)
}
}(ExecutionContext.parasitic)
}
}

Expand Down
2 changes: 1 addition & 1 deletion project/dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import sbt._

object Dependencies {
val capiVersion = "35.0.0"
val eTagCachingVersion = "7.0.0"
val eTagCachingVersion = "11.0.0-PREVIEW.rearrange-executioncontexts.2025-09-04T1417.81632f48"

val awsS3SdkV1 = "com.amazonaws" % "aws-java-sdk-s3" % "1.12.765"
val eTagCachingS3Base = "com.gu.etag-caching" %% "aws-s3-base" % eTagCachingVersion
Expand Down
Loading