[S3MetaDataEnricher] Extract as trait
This commit is contained in:
parent
326fd7d4cc
commit
9d3c124b6e
2 changed files with 20 additions and 7 deletions
19
src/main/scala/net/kemitix/s3thorp/S3MetaDataEnricher.scala
Normal file
19
src/main/scala/net/kemitix/s3thorp/S3MetaDataEnricher.scala
Normal file
|
@ -0,0 +1,19 @@
|
|||
package net.kemitix.s3thorp
|
||||
|
||||
import java.nio.file.Path
|
||||
import java.time.Instant
|
||||
import fs2.Stream
|
||||
import cats.effect.IO
|
||||
import net.kemitix.s3thorp.Sync.S3MetaData
|
||||
import Main.putStrLn
|
||||
|
||||
trait S3MetaDataEnricher {
|
||||
|
||||
def enrichWithS3MetaData: Path => Stream[IO, S3MetaData] =
|
||||
path => Stream.eval(for {
|
||||
_ <- putStrLn(s"enrich: $path")
|
||||
// HEAD(bucket, prefix, relative(path))
|
||||
// create blank S3MetaData records (sealed trait?)
|
||||
} yield S3MetaData(path, "", "", Instant.now()))
|
||||
|
||||
}
|
|
@ -10,7 +10,7 @@ import net.kemitix.s3thorp.Main.putStrLn
|
|||
import scala.collection.JavaConverters._
|
||||
import scala.concurrent.Promise
|
||||
|
||||
object Sync extends LocalFileStream {
|
||||
object Sync extends LocalFileStream with S3MetaDataEnricher {
|
||||
def apply(c: Config): IO[Unit] = for {
|
||||
_ <- putStrLn(s"Bucket: ${c.bucket}, Prefix: ${c.prefix}, Source: ${c.source}")
|
||||
_ <- {
|
||||
|
@ -31,12 +31,6 @@ object Sync extends LocalFileStream {
|
|||
remoteHash: Hash,
|
||||
remoteLastModified: LastModified)
|
||||
|
||||
private def enrichWithS3MetaData: Path => Stream[IO, S3MetaData] = path => Stream.eval(for {
|
||||
_ <- putStrLn(s"enrich: $path")
|
||||
// HEAD(bucket, prefix, relative(path))
|
||||
// create blank S3MetaData records (sealed trait?)
|
||||
} yield S3MetaData(path, "", "", Instant.now()))
|
||||
|
||||
private def uploadRequiredFilter: S3MetaData => Stream[IO, Path] = s3Metadata => Stream.eval(for {
|
||||
_ <- putStrLn(s"upload required: ${s3Metadata.localPath}")
|
||||
//md5File(localFile)
|
||||
|
|
Loading…
Reference in a new issue