s3_website_monadic 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 486eca634309564e0eee312970f5b65e0886f848
|
4
|
+
data.tar.gz: 828bc8f2c6a316b7ec10b5987e5dd0138ecdd00b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 824b5b8cf528ee55fe3e525c185344691918314766d25f6f6534dd27be57a00fd59d0ccf417b4c02a3d961f7c6764e71ada6150e3bf38dbe3c2c75562b6c1c7f
|
7
|
+
data.tar.gz: 603f6e64ed8d5a8764e137df3d66154e0f9445eafc7cf3709babab4477579ac0afebf29fc35bdc3a47c412256adcad6018ac489dc6d600552e144eb5ab3f1568
|
data/s3_website.gemspec
CHANGED
@@ -1,14 +1,7 @@
|
|
1
1
|
package s3.website.model
|
2
2
|
|
3
|
-
import com.amazonaws.AmazonServiceException
|
4
|
-
import com.amazonaws.AmazonServiceException.ErrorType.Client
|
5
3
|
import s3.website.ErrorReport
|
6
4
|
|
7
|
-
object Error {
|
8
|
-
def isClientError(error: Throwable) =
|
9
|
-
error.isInstanceOf[AmazonServiceException] && error.asInstanceOf[AmazonServiceException].getErrorType == Client
|
10
|
-
}
|
11
|
-
|
12
5
|
case class ClientError(reportMessage: String) extends ErrorReport
|
13
6
|
|
14
7
|
case class IOError(exception: Throwable) extends ErrorReport {
|
@@ -1,11 +1,12 @@
|
|
1
1
|
package s3
|
2
2
|
|
3
3
|
import scala.concurrent.{ExecutionContextExecutor, Future}
|
4
|
-
import s3.website.model.Error._
|
5
4
|
import s3.website.Logger._
|
6
5
|
import scala.concurrent.duration.{TimeUnit, Duration}
|
7
6
|
import s3.website.Utils._
|
8
7
|
import s3.website.S3.{PushSuccessReport, PushFailureReport}
|
8
|
+
import com.amazonaws.services.s3.model.AmazonS3Exception
|
9
|
+
import com.amazonaws.AmazonServiceException
|
9
10
|
|
10
11
|
package object website {
|
11
12
|
trait Report {
|
@@ -29,7 +30,7 @@ package object website {
|
|
29
30
|
(createFailureReport: (Throwable) => L, retryAction: (Attempt) => Future[Either[L, R]])
|
30
31
|
(implicit retrySettings: RetrySettings, ec: ExecutionContextExecutor):
|
31
32
|
PartialFunction[Throwable, Future[Either[L, R]]] = {
|
32
|
-
case error: Throwable if attempt == 6 ||
|
33
|
+
case error: Throwable if attempt == 6 || isIrrecoverable(error) =>
|
33
34
|
val failureReport = createFailureReport(error)
|
34
35
|
fail(failureReport.reportMessage)
|
35
36
|
Future(Left(failureReport))
|
@@ -40,4 +41,13 @@ package object website {
|
|
40
41
|
Thread.sleep(sleepDuration.toMillis)
|
41
42
|
retryAction(attempt + 1)
|
42
43
|
}
|
44
|
+
|
45
|
+
def isIrrecoverable(error: Throwable) = {
|
46
|
+
val httpStatusCode =
|
47
|
+
error match {
|
48
|
+
case exception: AmazonServiceException => Some(exception.getStatusCode)
|
49
|
+
case _ => None
|
50
|
+
}
|
51
|
+
httpStatusCode.exists(c => c >= 400 && c < 500)
|
52
|
+
}
|
43
53
|
}
|
@@ -104,11 +104,11 @@ class S3WebsiteSpec extends Specification {
|
|
104
104
|
verify(amazonS3Client, times(6)).putObject(Matchers.any(classOf[PutObjectRequest]))
|
105
105
|
}
|
106
106
|
|
107
|
-
"not try again if the upload fails on because of
|
107
|
+
"not try again if the upload fails on because of invalid credentials" in new SiteDirectory with MockAWS {
|
108
108
|
implicit val site = siteWithFilesAndContent(localFilesWithContent = ("index.html", "<h1>hello</h1>") :: Nil)
|
109
109
|
when(amazonS3Client.putObject(Matchers.any(classOf[PutObjectRequest]))).thenThrow {
|
110
110
|
val e = new AmazonServiceException("your credentials are incorrect")
|
111
|
-
e.
|
111
|
+
e.setStatusCode(403)
|
112
112
|
e
|
113
113
|
}
|
114
114
|
Push.pushSite
|