Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* clean up flows a little * turn on tests * fix tests * start to publish to topic * Apply auto-formatting rules * send sns notifiction [wip] * Apply auto-formatting rules * Apply auto-formatting rules * cleaning up a bit * asserting publish to topic * passing notiication test * topic config * update sns publish policy * simplify tests and update queue permissions * fmt * Apply auto-formatting rules * allow dupe messages with set uniqueness
- Loading branch information
Showing
33 changed files
with
682 additions
and
308 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
archive/archiver/src/main/scala/uk/ac/wellcome/platform/archiver/flow/ArchiveBagFlow.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package uk.ac.wellcome.platform.archiver.flow | ||
|
||
import java.util.zip.ZipFile | ||
|
||
import akka.stream.ActorMaterializer | ||
import akka.stream.alpakka.s3.scaladsl.S3Client | ||
import akka.stream.scaladsl.Source | ||
import uk.ac.wellcome.platform.archiver.models.BagItConfig | ||
import uk.ac.wellcome.storage.ObjectLocation | ||
|
||
object ArchiveBagFlow { | ||
|
||
def apply(zipFile: ZipFile, bagLocation: BagLocation, config: BagItConfig)( | ||
implicit | ||
materializer: ActorMaterializer, | ||
s3Client: S3Client | ||
) = { | ||
|
||
val bagDigestItemFlow = BagDigestItemFlow(config.digestDelimiterRegexp) | ||
val archiveItemFlow = ArchiveItemFlow() | ||
val digestLocations = digestNames(bagLocation.bagName, config.digestNames) | ||
|
||
Source | ||
.fromIterator(() => digestLocations) | ||
.log("digest location") | ||
.map((_, bagLocation.bagName, zipFile)) | ||
.via(bagDigestItemFlow) | ||
.log("bag digest item") | ||
.map((bagLocation, _, zipFile)) | ||
.via(archiveItemFlow) | ||
} | ||
|
||
private def digestNames(bagName: BagName, digestNames: List[String]) = | ||
digestNames | ||
.map(digestName => { | ||
ObjectLocation(bagName.value, digestName) | ||
}) | ||
.toIterator | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...chiver/src/main/scala/uk/ac/wellcome/platform/archiver/flow/BagArchiverCompleteFlow.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package uk.ac.wellcome.platform.archiver.flow | ||
|
||
import akka.stream.alpakka.sns.scaladsl.SnsPublisher | ||
import akka.stream.scaladsl.Flow | ||
import com.amazonaws.services.sns.AmazonSNSAsync | ||
import uk.ac.wellcome.json.JsonUtil._ | ||
|
||
import scala.util.{Failure, Success} | ||
|
||
object BagArchiveCompleteFlow { | ||
def apply(topicArn: String)(implicit snsClient: AmazonSNSAsync) = | ||
Flow[BagLocation] | ||
.map(createNotification) | ||
.log("created notification") | ||
.map(toJson(_)) | ||
.map { | ||
case Success(json) => json | ||
case Failure(e) => throw e | ||
} | ||
.log("notification serialised") | ||
.via(SnsPublisher.flow(topicArn)) | ||
.log("published notification") | ||
|
||
def createNotification(bagLocation: BagLocation) = | ||
BagArchiveCompleteNotification(bagLocation) | ||
|
||
} | ||
|
||
case class BagArchiveCompleteNotification( | ||
bagLocation: BagLocation | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
...rc/main/scala/uk/ac/wellcome/platform/archiver/flow/BagLocationFromNotificationFlow.scala
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
archive/archiver/src/main/scala/uk/ac/wellcome/platform/archiver/flow/BagNameFlow.scala
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.