[s3uploader] Extract as trait
This commit is contained in:
parent
7d688954f7
commit
ebec3b1564
2 changed files with 23 additions and 11 deletions
21
src/main/scala/net/kemitix/s3thorp/S3Uploader.scala
Normal file
21
src/main/scala/net/kemitix/s3thorp/S3Uploader.scala
Normal file
|
@ -0,0 +1,21 @@
|
|||
package net.kemitix.s3thorp
|
||||
|
||||
import java.io.File
|
||||
|
||||
import fs2.Stream
|
||||
import cats.effect.IO
|
||||
import net.kemitix.s3thorp.Main.putStrLn
|
||||
import net.kemitix.s3thorp.awssdk.S3Client
|
||||
|
||||
import scala.concurrent.Promise
|
||||
|
||||
trait S3Uploader extends S3Client {
|
||||
|
||||
def performUpload: File => Stream[IO, Promise[Unit]] =
|
||||
file => Stream.eval(for {
|
||||
_ <- putStrLn(s"uploading: $file")
|
||||
// upload
|
||||
p = Promise[Unit]()
|
||||
} yield p)
|
||||
|
||||
}
|
|
@ -4,16 +4,14 @@ import java.io.File
|
|||
import java.time.Instant
|
||||
|
||||
import cats.effect._
|
||||
import fs2.Stream
|
||||
import net.kemitix.s3thorp.Main.putStrLn
|
||||
import net.kemitix.s3thorp.awssdk.S3Client
|
||||
|
||||
import scala.concurrent.Promise
|
||||
|
||||
class Sync(s3Client: S3Client)
|
||||
extends LocalFileStream
|
||||
with S3MetaDataEnricher
|
||||
with UploadSelectionFilter {
|
||||
with UploadSelectionFilter
|
||||
with S3Uploader {
|
||||
|
||||
override def objectHead(bucket: String, key: String)=
|
||||
s3Client.objectHead(bucket, key)
|
||||
|
@ -28,13 +26,6 @@ class Sync(s3Client: S3Client)
|
|||
}
|
||||
} yield ()
|
||||
|
||||
private def performUpload: File => Stream[IO, Promise[Unit]] =
|
||||
file => Stream.eval(for {
|
||||
_ <- putStrLn(s"upload: $file")
|
||||
// upload
|
||||
p = Promise[Unit]()
|
||||
} yield p)
|
||||
|
||||
}
|
||||
|
||||
object Sync {
|
||||
|
|
Loading…
Reference in a new issue