-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip wip wip
- Loading branch information
Showing
25 changed files
with
412 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
http { | ||
host = "0.0.0.0" | ||
port = 8081 | ||
host = "127.0.0.1" | ||
port = 8084 | ||
} | ||
|
||
pg { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
modules/api/src/main/scala/io/ergolabs/cardano/explorer/api/configs/ClientTimeouts.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.ergolabs.cardano.explorer.api.configs | ||
|
||
import derevo.derive | ||
import derevo.pureconfig.pureconfigReader | ||
import tofu.logging.derivation.loggable | ||
|
||
import scala.concurrent.duration.FiniteDuration | ||
|
||
@derive(pureconfigReader, loggable) | ||
final case class ClientTimeouts(connectTimeout: FiniteDuration, timeout: FiniteDuration) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
modules/api/src/main/scala/io/ergolabs/cardano/explorer/api/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.ergolabs.cardano.explorer | ||
|
||
import cats.{~>, Applicative, Defer} | ||
import cats.effect.{Concurrent, ContextShift, Resource} | ||
import io.ergolabs.cardano.explorer.api.configs.ClientTimeouts | ||
import monix.eval.Task | ||
import org.asynchttpclient.DefaultAsyncHttpClientConfig | ||
import sttp.capabilities.WebSockets | ||
import sttp.client3._ | ||
import sttp.client3.SttpBackend | ||
import sttp.client3.asynchttpclient.monix.AsyncHttpClientMonixBackend | ||
import sttp.client3.impl.cats.implicits._ | ||
import sttp.client3.logging.slf4j.Slf4jLoggingBackend | ||
import tofu.WithRun | ||
|
||
package object api { | ||
|
||
def makeSttpBackend[I[_]: Defer: Applicative, F[_]: Concurrent: ContextShift]( | ||
ctx: AppContext, | ||
httpClientTimeouts: Option[ClientTimeouts] = None | ||
)(implicit | ||
WR: WithRun[F, I, AppContext], | ||
fromTaskI: Task ~> I, | ||
fromTaskF: Task ~> F, | ||
toTaskF: F ~> Task | ||
): Resource[I, SttpBackend[F, WebSockets]] = | ||
AsyncHttpClientMonixBackend.resource().mapK(fromTaskI).map(_.mapK(fromTaskF, toTaskF)) | ||
|
||
def setupTimeouts(builder: DefaultAsyncHttpClientConfig.Builder, config: ClientTimeouts) = { | ||
import config._ | ||
builder | ||
.setConnectTimeout(connectTimeout.toMillis.toInt) | ||
.setReadTimeout(timeout.toMillis.toInt) | ||
.setRequestTimeout( | ||
timeout.toMillis.toInt + connectTimeout.toMillis.toInt * 2 | ||
) | ||
} | ||
|
||
def wrapWithLogs[F[_], S](delegate: SttpBackend[F, S]): SttpBackend[F, S] = | ||
Slf4jLoggingBackend(delegate, logRequestBody = true, logResponseBody = true) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
modules/core/src/main/scala/io/ergolabs/cardano/explorer/core/gateway/GatewayError.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.ergolabs.cardano.explorer.core.gateway | ||
|
||
sealed trait GatewayError extends Throwable | ||
|
||
object GatewayError { | ||
final case class UnexpectedError(description: String) extends GatewayError | ||
final case class GatewayResponseDecodingFailure(description: String) extends GatewayError | ||
} |
Oops, something went wrong.