zio / zio-sqs

ZIO-powered client for AWS SQS
https://zio.dev/zio-sqs
Apache License 2.0
82 stars 27 forks source link

Scala3 Support using 2.13 ElasticMq #676

Closed rstradling closed 1 year ago

rstradling commented 1 year ago

author Ryan Stradling ryanstradling@gmail.com 1673316256 -0500 committer Ryan Stradling ryanstradling@gmail.com 1673454984 -0500

Fixes #632 but in a slightly different way than that ticket was leaning towards

Approach

The major issue with Scala3 compilation and this code base are the tests and dependency on elasticMq which does not have a Scala3 version of its code (assuming that is due to the Akka dependency). The one approach would be to update ElasticMq to do a cross-compile to Scala3 but to achieve that Akka would most likely need to be replaced with another http service. This should probably be done but may take a while.

The other way to approach this is to use 2.13 libraries in Scala3 by using the library dependency sbt sugar of cross CrossVersion.for3Use2_13.

Details

In the build.sbt file we are using a 2.13 ElasticMq library for tests only for Scala3. I cannot guarantee that is a binary compatible scenario but things seem to run and given it is for tests am not too worried about it. Also in the build.sbt I removed a compiler plugin that did not seem to be used and there is no Scala3 equivalent for and moved the kind-projector compiler plugin only for 2.12 and 2.13. I also updated the default build to scala 3.2.1 but am happy to change it back to 2.13

case class StubSqsService(api: SqsAsyncClient = null) was done because it used to have a lazy val api which in Scala3 cannot override a non-lazy val and seems to me like not a great thing. I tried changing it to be a non-lazy val but had issues when running the tests. withFastClock interpreted in Scala 3 as ZIO[Live, Any, Long]. I do not know the history of this difference but it seems to work on all versions just fine. And again these are tests.

ghostdogpr commented 1 year ago

Looks great! Can you also add scala 3 to the CI matrix here: https://github.com/zio/zio-sqs/blob/db4ad65df2f1793d8ff4f5cb497707b9dfdba14e/.github/workflows/ci.yml#L34 so that CI runs on Scala 3 too?

rstradling commented 1 year ago

done and all looks green. lmk if anything else is needed.

ghostdogpr commented 1 year ago

Thanks!