src/main/scala/s3/website/CloudFront.scala in s3_website-2.4.0 vs src/main/scala/s3/website/CloudFront.scala in s3_website-2.5.0
- old
+ new
@@ -12,24 +12,24 @@
import scala.concurrent.{ExecutionContextExecutor, Future}
import s3.website.model.Config.awsCredentials
object CloudFront {
def invalidate(invalidationBatch: InvalidationBatch, distributionId: String, attempt: Attempt = 1)
- (implicit ec: ExecutionContextExecutor, cloudFrontSettings: CloudFrontSetting, config: Config, logger: Logger, pushMode: PushMode): InvalidationResult =
+ (implicit ec: ExecutionContextExecutor, cloudFrontSettings: CloudFrontSetting, config: Config, logger: Logger, pushOptions: PushOptions): InvalidationResult =
Future {
- if (!pushMode.dryRun) cloudFront createInvalidation new CreateInvalidationRequest(distributionId, invalidationBatch)
+ if (!pushOptions.dryRun) cloudFront createInvalidation new CreateInvalidationRequest(distributionId, invalidationBatch)
val result = SuccessfulInvalidation(invalidationBatch.getPaths.getItems.size())
logger.debug(invalidationBatch.getPaths.getItems.map(item => s"${Invalidated.renderVerb} $item") mkString "\n")
logger.info(result)
Right(result)
} recoverWith (tooManyInvalidationsRetry(invalidationBatch, distributionId, attempt) orElse retry(attempt)(
createFailureReport = error => FailedInvalidation(error),
retryAction = nextAttempt => invalidate(invalidationBatch, distributionId, nextAttempt)
))
def tooManyInvalidationsRetry(invalidationBatch: InvalidationBatch, distributionId: String, attempt: Attempt)
- (implicit ec: ExecutionContextExecutor, logger: Logger, cloudFrontSettings: CloudFrontSetting, config: Config, pushMode: PushMode):
+ (implicit ec: ExecutionContextExecutor, logger: Logger, cloudFrontSettings: CloudFrontSetting, config: Config, pushOptions: PushOptions):
PartialFunction[Throwable, InvalidationResult] = {
case e: TooManyInvalidationsInProgressException =>
val duration: Duration = Duration(
(fibs drop attempt).head min 15, /* CloudFront invalidations complete within 15 minutes */
cloudFrontSettings.retryTimeUnit
@@ -55,10 +55,10 @@
type InvalidationResult = Future[Either[FailedInvalidation, SuccessfulInvalidation]]
type CloudFrontClientProvider = (Config) => AmazonCloudFront
- case class SuccessfulInvalidation(invalidatedItemsCount: Int)(implicit pushMode: PushMode) extends SuccessReport {
+ case class SuccessfulInvalidation(invalidatedItemsCount: Int)(implicit pushOptions: PushOptions) extends SuccessReport {
def reportMessage = s"${Invalidated.renderVerb} ${invalidatedItemsCount ofType "item"} on CloudFront"
}
case class FailedInvalidation(error: Throwable)(implicit logger: Logger) extends ErrorReport {
def reportMessage = errorMessage(s"Failed to invalidate the CloudFront distribution", error)