From 3eddc09a20c07f2b31b00a20c97daa6df192c834 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 9 May 2019 21:11:46 +0100 Subject: [PATCH] [catsios3client] Extract as trait --- .../net/kemitix/s3thorp/awssdk/CatsIOS3Client.scala | 12 ++++++++++++ .../kemitix/s3thorp/awssdk/ReactiveS3Client.scala | 9 +++------ 2 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 src/main/scala/net/kemitix/s3thorp/awssdk/CatsIOS3Client.scala diff --git a/src/main/scala/net/kemitix/s3thorp/awssdk/CatsIOS3Client.scala b/src/main/scala/net/kemitix/s3thorp/awssdk/CatsIOS3Client.scala new file mode 100644 index 0000000..953401a --- /dev/null +++ b/src/main/scala/net/kemitix/s3thorp/awssdk/CatsIOS3Client.scala @@ -0,0 +1,12 @@ +package net.kemitix.s3thorp.awssdk + +import com.github.j5ik2o.reactive.aws.s3.S3AsyncClient +import com.github.j5ik2o.reactive.aws.s3.cats.S3CatsIOClient +import software.amazon.awssdk.services.s3.{S3AsyncClient => JavaS3AsyncClient} + +trait CatsIOS3Client { + + def s3Client = S3CatsIOClient(S3AsyncClient(JavaS3AsyncClient.create)) + + +} diff --git a/src/main/scala/net/kemitix/s3thorp/awssdk/ReactiveS3Client.scala b/src/main/scala/net/kemitix/s3thorp/awssdk/ReactiveS3Client.scala index b19a0b5..6c4be9d 100644 --- a/src/main/scala/net/kemitix/s3thorp/awssdk/ReactiveS3Client.scala +++ b/src/main/scala/net/kemitix/s3thorp/awssdk/ReactiveS3Client.scala @@ -1,17 +1,14 @@ package net.kemitix.s3thorp.awssdk import cats.effect.IO -import com.github.j5ik2o.reactive.aws.s3.S3AsyncClient -import com.github.j5ik2o.reactive.aws.s3.cats.S3CatsIOClient import net.kemitix.s3thorp.Main.putStrLn import net.kemitix.s3thorp.Sync.{Bucket, LocalFile, RemoteKey} import software.amazon.awssdk.core.async.AsyncRequestBody import software.amazon.awssdk.services.s3.model.{HeadObjectRequest, NoSuchKeyException, PutObjectRequest} -import software.amazon.awssdk.services.s3.{S3AsyncClient => JavaS3AsyncClient} -private class ReactiveS3Client extends S3Client { - - private val s3Client = S3CatsIOClient(S3AsyncClient(JavaS3AsyncClient.create)) +private class ReactiveS3Client + extends S3Client + with CatsIOS3Client { override def objectHead(bucket: Bucket, remoteKey: RemoteKey) = { val request = HeadObjectRequest.builder()