Skip to content

Update Java version to 24 in CI configurations and refactor response … #161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
java-version: '21'
java-version: '24'
distribution: 'temurin'
cache: 'sbt'
- uses: sbt/setup-sbt@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scala.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '21'
java-version: '24'
distribution: 'temurin'
cache: 'sbt'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import cats.implicits.*
import com.google.protobuf.ByteString
import com.google.protobuf.any.Any
import connectrpc.conformance.v1.*
import connectrpc.conformance.v1.UnaryResponseDefinition.Response
import io.grpc.internal.GrpcUtil
import io.grpc.{Metadata, Status}
import io.grpc.{Metadata, Status, StatusRuntimeException}
import org.ivovk.connect_rpc_scala.conformance.util.ConformanceHeadersConv
import org.ivovk.connect_rpc_scala.syntax.all.*
import scalapb.GeneratedMessage

import java.util.concurrent.TimeUnit
import scala.concurrent.duration.Duration
import scala.concurrent.duration.*

case class UnaryHandlerResponse(payload: ConformancePayload, trailers: Metadata)

Expand Down Expand Up @@ -65,30 +65,23 @@ class ConformanceServiceImpl[F[_]: Async] extends ConformanceServiceFs2GrpcTrail
)

val responseData = responseDefinition.response match {
case UnaryResponseDefinition.Response.ResponseData(byteString) =>
byteString
case UnaryResponseDefinition.Response.Empty =>
ByteString.EMPTY
case UnaryResponseDefinition.Response.Error(Error(code, message, _)) =>
throw Status.fromCodeValue(code.value)
.withDescription(message.orNull)
.asRuntimeException(trailers)
.withDetails(requestInfo)
}
case Response.ResponseData(byteString) => byteString
case Response.Empty => ByteString.EMPTY
case Response.Error(error) =>
val status = Status.fromCodeValue(error.code.value)
.withDescription(error.message.orNull)

val sleep = Duration(responseDefinition.responseDelayMs, TimeUnit.MILLISECONDS)
throw new StatusRuntimeException(status, trailers).withDetails(requestInfo)
}

Async[F].delayBy(
Async[F].sleep(responseDefinition.responseDelayMs.millis) *>
UnaryHandlerResponse(
ConformancePayload(
responseData,
requestInfo.some,
),
trailers,
).pure[F],
sleep,
)

).pure[F]
}

private def extractTimeoutMs(metadata: Metadata): Option[Long] =
Expand Down