Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jobs:
strategy:
fail-fast: false
matrix:
java: ['adopt@1.11']
scala: ['2.12.20', '2.13.16', '3.3.5']
java: ['openjdk@1.17']
scala: ['2.12.21', '2.13.18', '3.3.7']
steps:
- name: Checkout current branch
uses: actions/checkout@v4
Expand All @@ -58,7 +58,7 @@ jobs:
- name: Setup Scala and Java
uses: olafurpg/setup-scala@v10
with:
java-version: adopt@1.11
java-version: openjdk@1.17
- name: Cache scala dependencies
uses: coursier/cache-action@v6
- name: Release artifacts
Expand Down
26 changes: 13 additions & 13 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
val scala212 = "2.12.20"
val scala213 = "2.13.16"
val scala3 = "3.3.5"
val scala212 = "2.12.21"
val scala213 = "2.13.18"
val scala3 = "3.3.7"
val allScala = Seq(scala212, scala213, scala3)

val zioVersion = "2.1.16"
val zioVersion = "2.1.24"
val zioGrpcVersion = "0.6.3"
val grpcNettyVersion = "1.71.0"
val zioK8sVersion = "3.1.0"
val zioCacheVersion = "0.2.4"
val zioCatsInteropVersion = "23.1.0.5"
val sttpVersion = "3.10.3"
val calibanVersion = "2.10.0"
val sttpVersion = "4.0.13"
val calibanVersion = "3.0.0"
val redis4catsVersion = "2.0.1"
val redissonVersion = "3.45.1"
val scalaKryoVersion = "1.3.0"
val testContainersVersion = "0.43.0"
val testContainersVersion = "0.44.1"
val scalaCompatVersion = "2.13.0"

inThisBuild(
Expand Down Expand Up @@ -95,8 +95,8 @@ lazy val entities = project
.settings(
libraryDependencies ++=
Seq(
"com.github.ghostdogpr" %% "caliban-client" % calibanVersion,
"com.softwaremill.sttp.client3" %% "async-http-client-backend-zio" % sttpVersion
"com.github.ghostdogpr" %% "caliban-client" % calibanVersion,
"com.softwaremill.sttp.client4" %% "zio" % sttpVersion
)
)

Expand All @@ -108,10 +108,10 @@ lazy val healthK8s = project
.settings(
libraryDependencies ++=
Seq(
"com.coralogix" %% "zio-k8s-client" % zioK8sVersion,
"dev.zio" %% "zio-cache" % zioCacheVersion,
"com.softwaremill.sttp.client3" %% "async-http-client-backend-zio" % sttpVersion,
"com.softwaremill.sttp.client3" %% "slf4j-backend" % sttpVersion
"com.coralogix" %% "zio-k8s-client" % zioK8sVersion,
"dev.zio" %% "zio-cache" % zioCacheVersion,
"com.softwaremill.sttp.client4" %% "zio" % sttpVersion,
"com.softwaremill.sttp.client4" %% "slf4j-backend" % sttpVersion
)
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.devsisters.shardcake

import sttp.client3.UriContext
import sttp.client4.UriContext
import sttp.model.Uri
import zio._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import caliban.client.Operations.IsOperation
import caliban.client.SelectionBuilder
import com.devsisters.shardcake.internal.GraphQLClient
import com.devsisters.shardcake.internal.GraphQLClient.PodAddressInput
import sttp.client3.SttpBackend
import sttp.client3.asynchttpclient.zio.AsyncHttpClientZioBackend
import sttp.client4.Backend
import sttp.client4.httpclient.zio.HttpClientZioBackend
import zio.{ Config => _, _ }

/**
Expand All @@ -24,10 +24,10 @@ object ShardManagerClient {
* A layer that returns a client for the Shard Manager API.
* It requires an sttp backend. If you don't want to use your own backend, simply use `liveWithSttp`.
*/
val live: ZLayer[Config with SttpBackend[Task, Any], Nothing, ShardManagerClientLive] =
val live: ZLayer[Config with Backend[Task], Nothing, ShardManagerClientLive] =
ZLayer {
for {
sttpClient <- ZIO.service[SttpBackend[Task, Any]]
sttpClient <- ZIO.service[Backend[Task]]
config <- ZIO.service[Config]
} yield new ShardManagerClientLive(sttpClient, config)
}
Expand All @@ -37,7 +37,7 @@ object ShardManagerClient {
* It contains its own sttp backend so you don't need to provide one.
*/
val liveWithSttp: ZLayer[Config, Throwable, ShardManagerClient] =
AsyncHttpClientZioBackend.layer() >>> live
HttpClientZioBackend.layer() >>> live

/**
* A layer that mocks the Shard Manager, useful for testing with a single pod.
Expand All @@ -56,7 +56,7 @@ object ShardManagerClient {
}
}

class ShardManagerClientLive(sttp: SttpBackend[Task, Any], config: Config) extends ShardManagerClient {
class ShardManagerClientLive(sttp: Backend[Task], config: Config) extends ShardManagerClient {
private def send[Origin: IsOperation, A](query: SelectionBuilder[Origin, A]): Task[A] =
sttp.send(query.toRequest(config.shardManagerUri)).map(_.body).absolve

Expand Down
2 changes: 1 addition & 1 deletion examples/src/test/scala/example/EndToEndSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import dev.profunktor.redis4cats.pubsub.PubSub
import example.simple.GuildBehavior
import example.simple.GuildBehavior.Guild
import example.simple.GuildBehavior.GuildMessage.{ Join, Stream, Timeout }
import sttp.client3.UriContext
import sttp.client4.UriContext
import zio.{ Config => _, _ }
import zio.Clock.ClockLive
import zio.interop.catz._
Expand Down
19 changes: 12 additions & 7 deletions examples/src/test/scala/example/ShardManagerAuthExampleSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package example

import com.devsisters.shardcake.{ Config, ManagerConfig, Server, ShardManager, ShardManagerClient }
import com.devsisters.shardcake.interfaces.{ Pods, PodsHealth, Storage }
import sttp.client3.SttpBackend
import sttp.client3.asynchttpclient.zio.AsyncHttpClientZioBackend
import sttp.client3.httpclient.zio.ZioWebSocketsStreams
import sttp.client4.Backend
import sttp.client4.httpclient.zio._
import zio.Clock.ClockLive
import zio.http.{ Header, Middleware }
import zio.test._
import zio.{ Config => _, _ }
import java.net.http.HttpRequest

object ShardManagerAuthExampleSpec extends ZIOSpecDefault {

Expand All @@ -27,12 +27,17 @@ object ShardManagerAuthExampleSpec extends ZIOSpecDefault {
PodsHealth.noop
)

def sttpBackendWithAuthTokenLayer(token: String): ZLayer[Scope, Throwable, SttpBackend[Task, ZioWebSocketsStreams]] =
def sttpBackendWithAuthTokenLayer(token: String): ZLayer[Scope, Throwable, Backend[Task]] =
ZLayer {
val authHeader = Header.Authorization.Bearer(token)
AsyncHttpClientZioBackend.scoped(customizeRequest =
builder => builder.addHeader(authHeader.headerName, authHeader.renderedValue)
)
HttpClientZioBackend.scoped(customizeRequest = req => {
val builder =
HttpRequest
.newBuilder(req.uri())
.method(req.method(), req.bodyPublisher().orElse(HttpRequest.BodyPublishers.noBody()))
req.headers().map().forEach((k, vs) => vs.forEach(v => builder.header(k, v)))
builder.header(authHeader.headerName, authHeader.renderedValue).build()
})
}

def spec: Spec[TestEnvironment, Any] =
Expand Down