[awssdk] Move AWS SDK wrapper and trait to seperate package
This commit is contained in:
parent
65c1915d53
commit
86a53bf712
6 changed files with 14 additions and 4 deletions
|
@ -4,6 +4,7 @@ import java.nio.file.Paths
|
||||||
|
|
||||||
import cats.effect.ExitCase.{Canceled, Completed, Error}
|
import cats.effect.ExitCase.{Canceled, Completed, Error}
|
||||||
import cats.effect.{ExitCode, IO, IOApp}
|
import cats.effect.{ExitCode, IO, IOApp}
|
||||||
|
import net.kemitix.s3thorp.awssdk.S3Client
|
||||||
|
|
||||||
object Main extends IOApp {
|
object Main extends IOApp {
|
||||||
|
|
||||||
|
@ -12,7 +13,7 @@ object Main extends IOApp {
|
||||||
val defaultConfig: Config =
|
val defaultConfig: Config =
|
||||||
Config("(none)", "", Paths.get(".").toFile)
|
Config("(none)", "", Paths.get(".").toFile)
|
||||||
|
|
||||||
val sync = new Sync(new ReactiveS3Client())
|
val sync = new Sync(S3Client.defaultClient)
|
||||||
|
|
||||||
def program(args: List[String]): IO[ExitCode] =
|
def program(args: List[String]): IO[ExitCode] =
|
||||||
for {
|
for {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.io.File
|
||||||
|
|
||||||
import fs2.Stream
|
import fs2.Stream
|
||||||
import cats.effect.IO
|
import cats.effect.IO
|
||||||
|
import net.kemitix.s3thorp.awssdk.S3Client
|
||||||
|
|
||||||
trait S3MetaDataEnricher extends S3Client {
|
trait S3MetaDataEnricher extends S3Client {
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.time.Instant
|
||||||
import cats.effect._
|
import cats.effect._
|
||||||
import fs2.Stream
|
import fs2.Stream
|
||||||
import net.kemitix.s3thorp.Main.putStrLn
|
import net.kemitix.s3thorp.Main.putStrLn
|
||||||
|
import net.kemitix.s3thorp.awssdk.S3Client
|
||||||
|
|
||||||
import scala.concurrent.Promise
|
import scala.concurrent.Promise
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package net.kemitix.s3thorp
|
package net.kemitix.s3thorp.awssdk
|
||||||
|
|
||||||
import cats.effect.IO
|
import cats.effect.IO
|
||||||
import com.github.j5ik2o.reactive.aws.s3.S3AsyncClient
|
import com.github.j5ik2o.reactive.aws.s3.S3AsyncClient
|
||||||
|
@ -6,7 +6,7 @@ import com.github.j5ik2o.reactive.aws.s3.cats.S3CatsIOClient
|
||||||
import software.amazon.awssdk.services.s3.model.{HeadObjectRequest, NoSuchKeyException}
|
import software.amazon.awssdk.services.s3.model.{HeadObjectRequest, NoSuchKeyException}
|
||||||
import software.amazon.awssdk.services.s3.{S3AsyncClient => JavaS3AsyncClient}
|
import software.amazon.awssdk.services.s3.{S3AsyncClient => JavaS3AsyncClient}
|
||||||
|
|
||||||
class ReactiveS3Client extends S3Client {
|
private class ReactiveS3Client extends S3Client {
|
||||||
|
|
||||||
private val s3Client = S3CatsIOClient(S3AsyncClient(JavaS3AsyncClient.create))
|
private val s3Client = S3CatsIOClient(S3AsyncClient(JavaS3AsyncClient.create))
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package net.kemitix.s3thorp
|
package net.kemitix.s3thorp.awssdk
|
||||||
|
|
||||||
import cats.effect.IO
|
import cats.effect.IO
|
||||||
import net.kemitix.s3thorp.Sync.{Hash, LastModified}
|
import net.kemitix.s3thorp.Sync.{Hash, LastModified}
|
||||||
|
@ -8,3 +8,9 @@ trait S3Client {
|
||||||
def objectHead(bucket: String, key: String): IO[Option[(Hash, LastModified)]]
|
def objectHead(bucket: String, key: String): IO[Option[(Hash, LastModified)]]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object S3Client {
|
||||||
|
|
||||||
|
val defaultClient: S3Client = new ReactiveS3Client
|
||||||
|
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package net.kemitix.s3thorp
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
|
||||||
import cats.effect.IO
|
import cats.effect.IO
|
||||||
|
import net.kemitix.s3thorp.awssdk.S3Client
|
||||||
import org.scalatest.FunSpec
|
import org.scalatest.FunSpec
|
||||||
|
|
||||||
class SyncSuite extends FunSpec {
|
class SyncSuite extends FunSpec {
|
||||||
|
|
Loading…
Reference in a new issue