Scalaz backend
The Scalaz backend is asynchronous. Sending a request is a non-blocking, lazily-evaluated operation and results in a response wrapped in a scalaz.concurrent.Task
. There’s a transitive dependency on scalaz-concurrent
.
Using Armeria
To use, add the following dependency to your project:
"com.softwaremill.sttp.client3" %% "armeria-backend-scalaz" % "3.10.2"
add imports:
import sttp.client3.armeria.scalaz.ArmeriaScalazBackend
create client:
val backend = ArmeriaScalazBackend()
// You can use the default client which reuses the connection pool of ClientFactory.ofDefault()
ArmeriaScalazBackend.usingDefaultClient()
or, if you’d like to instantiate the WebClient yourself:
import com.linecorp.armeria.client.circuitbreaker._
import com.linecorp.armeria.client.WebClient
// Fluently build Armeria WebClient with built-in decorators
val client = WebClient.builder("https://my-service.com")
// Open circuit on 5xx server error status
.decorator(CircuitBreakerClient.newDecorator(CircuitBreaker.ofDefaultName(),
CircuitBreakerRule.onServerErrorStatus()))
.build()
val backend = ArmeriaScalazBackend.usingClient(client)
Note
A WebClient could fail to follow redirects if the WebClient is created with a base URI and a redirect location is a different URI.
This backend is build on top of Armeria. Armeria’s ClientFactory manages connections and protocol-specific properties. Please visit the official documentation to learn how to configure it.
Streaming
This backend doesn’t support non-blocking streaming.
Websockets
The backend doesn’t support websockets.