s3_website_monadic 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 83042f3d9526d801a4c3ca1b843b8bbf3e03f02e
4
- data.tar.gz: a5e5ac7ae8fcc22d519d8d3503d74734050ac415
3
+ metadata.gz: 486eca634309564e0eee312970f5b65e0886f848
4
+ data.tar.gz: 828bc8f2c6a316b7ec10b5987e5dd0138ecdd00b
5
5
  SHA512:
6
- metadata.gz: 8625012df6b394782179cd5795f512f8dc6c99335eaa9d382b750b564acd0c697f9c4fbb652730499dc79d55fcecbb5be8d94c4f47c6afa9e80415b6bb3b6fda
7
- data.tar.gz: 98d5ac27855f7b212ed644e7df6d2122bd7fba976206643fd398fe8275e157e50f3b44127180ecdfd36d2cb11b74ad5b38357715041e4ab8c24e4f0c61043ccb
6
+ metadata.gz: 824b5b8cf528ee55fe3e525c185344691918314766d25f6f6534dd27be57a00fd59d0ccf417b4c02a3d961f7c6764e71ada6150e3bf38dbe3c2c75562b6c1c7f
7
+ data.tar.gz: 603f6e64ed8d5a8764e137df3d66154e0f9445eafc7cf3709babab4477579ac0afebf29fc35bdc3a47c412256adcad6018ac489dc6d600552e144eb5ab3f1568
data/s3_website.gemspec CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "s3_website_monadic"
6
- s.version = "0.0.11"
6
+ s.version = "0.0.12"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Lauri Lehmijoki"]
9
9
  s.email = ["lauri.lehmijoki@iki.fi"]
@@ -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 || isClientError(error) =>
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 the client" in new SiteDirectory with MockAWS {
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.setErrorType(ErrorType.Client)
111
+ e.setStatusCode(403)
112
112
  e
113
113
  }
114
114
  Push.pushSite
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3_website_monadic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lauri Lehmijoki