Skip to content

Commit

Permalink
try this
Browse files Browse the repository at this point in the history
  • Loading branch information
nylonee committed Nov 14, 2023
1 parent a4bd376 commit f856e1c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/main/scala/Server.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ import cats.effect._
import cats.effect.std.Semaphore
import configuration.{Configuration, ConfigurationUtils, SystemPropertyReader}
import org.http4s.ember.client.EmberClientBuilder
import org.typelevel.log4cats.slf4j.Slf4jLogger
import utils.HttpClient

object Server extends IOApp {

private val logger = Slf4jLogger.getLogger[IO]
def run(args: List[String]): IO[ExitCode] = {
val maxConcurrentOutgoingRequests = 1
val maxConcurrentOutgoingRequests = 2

for {
semaphore <- Semaphore[IO](maxConcurrentOutgoingRequests)
configReader = SystemPropertyReader
clientResource = EmberClientBuilder.default[IO].build
clientResource = EmberClientBuilder.default[IO].withLogger(logger).build
httpClient = new HttpClient(clientResource, semaphore)
memoizedConfigIo <- ConfigurationUtils.create(configReader, httpClient).memoize
result <- periodicTask(memoizedConfigIo, httpClient).foreverM.as(ExitCode.Success)
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/utils/HttpClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ class HttpClient(http4sClient: Resource[IO, Client[IO]], semaphore: Semaphore[IO
http4sClient.use(_.expect[Json](requestWithPayload).attempt)
}
}
}
}

0 comments on commit f856e1c

Please sign in to comment.