s3_website_monadic 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/s3_website.gemspec +1 -1
- data/src/main/scala/s3/website/Push.scala +5 -10
- data/src/main/scala/s3/website/S3.scala +11 -10
- data/src/main/scala/s3/website/Utils.scala +13 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f36d81a978b21bdb205386ffe7b805d2ac3c0ae
|
4
|
+
data.tar.gz: 022c4ed32cbe3a433d32e43a5b1c71344885aad7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32c75ffe6fc5976b59b437a8c65eac3a9be89ffb8f59f1f0c19bb599087eac5674ddbe81e651eb71c4aa1cd2807ac78fb47da1089b1a4dc5b07623fb245d30e4
|
7
|
+
data.tar.gz: 2ac550438e430c5361ddf005dda7a07d4d099d4fb6bada1dafc88e8cf51252d1cbe8910458d86acbf0dcd650b0efefe05e7415312f335a852a04c128ff2f2952
|
data/README.md
CHANGED
@@ -17,8 +17,9 @@
|
|
17
17
|
|
18
18
|
gem install s3_website
|
19
19
|
|
20
|
-
`s3_website` requires Ruby. Here is documentation on installing Ruby:
|
21
|
-
<http://www.ruby-lang.org/en/downloads/>.
|
20
|
+
`s3_website` requires Ruby and Java. Here is documentation on installing Ruby:
|
21
|
+
<http://www.ruby-lang.org/en/downloads/>. and here is documentation for Java:
|
22
|
+
<http://www.oracle.com/technetwork/java/javase/downloads/index.html>.
|
22
23
|
|
23
24
|
## Usage
|
24
25
|
|
data/s3_website.gemspec
CHANGED
@@ -2,8 +2,6 @@ package s3.website
|
|
2
2
|
|
3
3
|
import s3.website.model.Site._
|
4
4
|
import scala.concurrent.{ExecutionContextExecutor, Future, Await}
|
5
|
-
import scala.collection.parallel.ForkJoinTaskSupport
|
6
|
-
import scala.concurrent.forkjoin.ForkJoinPool
|
7
5
|
import scala.concurrent.duration._
|
8
6
|
import com.lexicalscope.jewel.cli.CliFactory
|
9
7
|
import scala.language.postfixOps
|
@@ -20,7 +18,7 @@ import s3.website.model.Update
|
|
20
18
|
import s3.website.model.NewFile
|
21
19
|
import s3.website.S3.PushSuccessReport
|
22
20
|
import scala.collection.mutable.ArrayBuffer
|
23
|
-
import s3.website.CloudFront.{
|
21
|
+
import s3.website.CloudFront.{CloudFrontClientProvider, toInvalidationBatches}
|
24
22
|
import s3.website.S3.SuccessfulDelete
|
25
23
|
import s3.website.CloudFront.SuccessfulInvalidation
|
26
24
|
import s3.website.S3.SuccessfulUpload
|
@@ -36,21 +34,18 @@ object Push {
|
|
36
34
|
cloudFrontSleepTimeUnit: TimeUnit = MINUTES
|
37
35
|
): ExitCode = {
|
38
36
|
println(s"Deploying ${site.rootDirectory}/* to ${site.config.s3_bucket}")
|
37
|
+
val utils: Utils = new Utils
|
39
38
|
|
40
39
|
val errorsOrReports = for {
|
41
40
|
s3Files <- resolveS3Files.right
|
42
41
|
localFiles <- resolveLocalFiles.right
|
43
42
|
} yield {
|
44
43
|
val redirects = Redirect.resolveRedirects
|
45
|
-
val deleteReports: PushReports = resolveDeletes(localFiles, s3Files, redirects)
|
44
|
+
val deleteReports: PushReports = utils toParSeq resolveDeletes(localFiles, s3Files, redirects)
|
46
45
|
.map { s3File => new S3() delete s3File.s3Key }
|
47
|
-
.map { Right(_)
|
48
|
-
|
49
|
-
deleteReports.tasksupport_=(new ForkJoinTaskSupport(new ForkJoinPool(site.config.concurrency_level)))
|
50
|
-
val uploadReports: PushReports = (redirects.toStream.map(Right(_)) ++ resolveUploads(localFiles, s3Files))
|
46
|
+
.map { Right(_) } // To make delete reports type-compatible with upload reports
|
47
|
+
val uploadReports: PushReports = utils toParSeq (redirects.toStream.map(Right(_)) ++ resolveUploads(localFiles, s3Files))
|
51
48
|
.map { errorOrUpload => errorOrUpload.right.map(new S3() upload ) }
|
52
|
-
.par
|
53
|
-
uploadReports.tasksupport_=(new ForkJoinTaskSupport(new ForkJoinPool(site.config.concurrency_level)))
|
54
49
|
uploadReports ++ deleteReports
|
55
50
|
}
|
56
51
|
val errorsOrFinishedPushOps: Either[Error, FinishedPushOperations] = errorsOrReports.right map {
|
@@ -26,11 +26,8 @@ class S3(implicit s3Client: S3ClientProvider) {
|
|
26
26
|
val report = SuccessfulUpload(upload)
|
27
27
|
println(report.reportMessage)
|
28
28
|
Right(report)
|
29
|
-
} recover {
|
30
|
-
|
31
|
-
val report = FailedUpload(upload.s3Key, error)
|
32
|
-
println(report.reportMessage)
|
33
|
-
Left(report)
|
29
|
+
} recover usingErrorHandler { error =>
|
30
|
+
FailedUpload(upload.s3Key, error)
|
34
31
|
}
|
35
32
|
|
36
33
|
def delete(s3Key: String)(implicit config: Config, executor: ExecutionContextExecutor): Future[Either[FailedDelete, SuccessfulDelete]] =
|
@@ -39,13 +36,17 @@ class S3(implicit s3Client: S3ClientProvider) {
|
|
39
36
|
val report = SuccessfulDelete(s3Key)
|
40
37
|
println(report.reportMessage)
|
41
38
|
Right(report)
|
42
|
-
} recover {
|
43
|
-
|
44
|
-
val report = FailedDelete(s3Key, error)
|
45
|
-
println(report.reportMessage)
|
46
|
-
Left(report)
|
39
|
+
} recover usingErrorHandler { error =>
|
40
|
+
FailedDelete(s3Key, error)
|
47
41
|
}
|
48
42
|
|
43
|
+
def usingErrorHandler[T <: PushFailureReport, F <: PushFailureReport](f: (Throwable) => T): PartialFunction[Throwable, Either[T, F]] = {
|
44
|
+
case error =>
|
45
|
+
val report = f(error)
|
46
|
+
println(report.reportMessage)
|
47
|
+
Left(report)
|
48
|
+
}
|
49
|
+
|
49
50
|
def toPutObjectRequest(upload: Upload)(implicit config: Config) =
|
50
51
|
upload.essence.fold(
|
51
52
|
redirect => {
|
@@ -0,0 +1,13 @@
|
|
1
|
+
package s3.website
|
2
|
+
|
3
|
+
import s3.website.model.Config
|
4
|
+
import scala.collection.parallel.{ForkJoinTaskSupport, ParSeq}
|
5
|
+
import scala.concurrent.forkjoin.ForkJoinPool
|
6
|
+
|
7
|
+
class Utils(implicit config: Config) {
|
8
|
+
def toParSeq[T](seq: Seq[T]): ParSeq[T] = {
|
9
|
+
val parallelSeq: ParSeq[T] = seq.par
|
10
|
+
parallelSeq.tasksupport_=(new ForkJoinTaskSupport(new ForkJoinPool(config.concurrency_level)))
|
11
|
+
parallelSeq
|
12
|
+
}
|
13
|
+
}
|
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.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lauri Lehmijoki
|
@@ -372,6 +372,7 @@ files:
|
|
372
372
|
- src/main/scala/s3/website/Push.scala
|
373
373
|
- src/main/scala/s3/website/Ruby.scala
|
374
374
|
- src/main/scala/s3/website/S3.scala
|
375
|
+
- src/main/scala/s3/website/Utils.scala
|
375
376
|
- src/main/scala/s3/website/model/Config.scala
|
376
377
|
- src/main/scala/s3/website/model/S3Endpoint.scala
|
377
378
|
- src/main/scala/s3/website/model/Site.scala
|