Skip to content

Commit

Permalink
Fixed EC2 client, added AWS context default
Browse files Browse the repository at this point in the history
  • Loading branch information
orbang committed Jul 26, 2023
1 parent f9c1fac commit 9e18977
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ name := "scase"
ThisBuild / organization := "io.jobial"
ThisBuild / scalaVersion := "2.13.8"
ThisBuild / crossScalaVersions := Seq("2.11.12", "2.12.15", "2.13.8")
ThisBuild / version := "1.3.1"
ThisBuild / version := "1.3.2"
ThisBuild / scalacOptions += "-target:jvm-1.8"
ThisBuild / javacOptions ++= Seq("-source", "11", "-target", "11")
ThisBuild / Test / packageBin / publishArtifact := true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
package io.jobial.scase.aws.client

import cats.effect.Concurrent
import cats.effect.IO
import com.amazonaws.auth.AWSCredentials
import io.jobial.scase.core.impl.blockerContext
Expand All @@ -36,4 +37,6 @@ case class AwsContext(
lazy val stsClient = StsClient[IO]

lazy val s3Client = S3Client[IO]
}

lazy val ec2Client = EC2Client[IO]
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ import java.util.concurrent.Executors

object EC2Client {

val client = AmazonEC2AsyncClientBuilder.standard().withExecutorFactory(new ExecutorFactory {
lazy val client = AmazonEC2AsyncClientBuilder.standard().withExecutorFactory(new ExecutorFactory {
def newExecutor = Executors.newCachedThreadPool(new DaemonThreadFactory)
}).build

def apply[F[_] : Concurrent : Timer : Parallel](implicit context: AwsContext) =
new S3Client[F] {
def apply[F[_] : Concurrent : Timer : Parallel](implicit context: AwsContext = AwsContext()) =
new EC2Client[F] {
def awsContext = context

val concurrent = Concurrent[F]
Expand All @@ -45,7 +45,7 @@ object EC2Client {

trait EC2Client[F[_]] extends AwsClient[F] with CatsUtils[F] {

def ec2Client = buildAwsAsyncClient[AmazonEC2AsyncClientBuilder, AmazonEC2Async](AmazonEC2AsyncClientBuilder.standard)
val ec2Client = buildAwsAsyncClient[AmazonEC2AsyncClientBuilder, AmazonEC2Async](AmazonEC2AsyncClientBuilder.standard)

def getInstanceState(id: String) =
for {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ trait LambdaClient[F[_]] extends AwsClient[F] {

object LambdaClient {

def apply[F[_] : Concurrent : Timer](implicit context: AwsContext) =
def apply[F[_] : Concurrent : Timer](implicit context: AwsContext = AwsContext()) =
new LambdaClient[F] {
def awsContext = context

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ trait S3Client[F[_]] extends AwsClient[F] {

object S3Client {

def apply[F[_] : Concurrent : Timer](implicit context: AwsContext) =
def apply[F[_] : Concurrent : Timer](implicit context: AwsContext = AwsContext()) =
new S3Client[F] {
def awsContext = context

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ trait SqsClient[F[_]] extends S3Client[F] {

object SqsClient {

def apply[F[_] : Timer : Concurrent](implicit context: AwsContext) = {
def apply[F[_] : Timer : Concurrent](implicit context: AwsContext = AwsContext()) = {
new SqsClient[F] {
val awsContext = context

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ trait StsClient[F[_]] extends AwsClient[F] {

object StsClient {

def apply[F[_] : Concurrent : Timer](implicit context: AwsContext) =
def apply[F[_] : Concurrent : Timer](implicit context: AwsContext = AwsContext()) =
new StsClient[F] {
def awsContext = context

Expand Down

0 comments on commit 9e18977

Please sign in to comment.