diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aedb030b..e9c45ae9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,10 +13,9 @@ jobs: - uses: actions/checkout@v4 - id: set-scala-versions run: | - scala212=$(grep "scala2.12" project/Dependencies.scala | sed -E 's/.*= //') scala213=$(grep "scala2.13" project/Dependencies.scala | sed -E 's/.*= //') scala3=$(grep "scala3" project/Dependencies.scala | sed -E 's/.*= //') - echo "versions={\"scala\": [${scala212}, ${scala213}, ${scala3}]}" >> $GITHUB_OUTPUT + echo "versions={\"scala\": [${scala213}, ${scala3}]}" >> $GITHUB_OUTPUT build: needs: - setup diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d2391037..c427d4a6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,12 +8,13 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - uses: actions/setup-java@v4 with: - java-version: '11' - distribution: 'temurin' - cache: 'sbt' - - run: git fetch --unshallow + java-version: "11" + distribution: "temurin" + cache: "sbt" - run: sbt ci-release env: PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} diff --git a/build.sbt b/build.sbt index de6dbff4..2997925f 100644 --- a/build.sbt +++ b/build.sbt @@ -17,13 +17,11 @@ lazy val fluflu = project ) ), scalaVersion := Ver.scala3, - crossScalaVersions := Seq(Ver.`scala2.12`, Ver.`scala2.13`, Ver.scala3), + crossScalaVersions := Seq(Ver.`scala2.13`, Ver.scala3), scalacOptions ++= { CrossVersion.partialVersion(scalaVersion.value) match { - case Some((3, _)) => Nil - case Some((2, n)) if n >= 13 => compilerOptions ++ warnCompilerOptions - case _ => - compilerOptions ++ warnCompilerOptions ++ Seq("-Xfuture", "-Ypartial-unification", "-Yno-adapted-args") + case Some((3, _)) => Nil + case _ => compilerOptions ++ warnCompilerOptions } }, fork := true, diff --git a/modules/core/src/main/scala/fluflu/Client.scala b/modules/core/src/main/scala/fluflu/Client.scala index 8fac62d8..b1b76bb8 100644 --- a/modules/core/src/main/scala/fluflu/Client.scala +++ b/modules/core/src/main/scala/fluflu/Client.scala @@ -42,15 +42,15 @@ object Client { PA: Unpacker[Option[Ack]] ): Client = new Client with LazyLogging { - @volatile private[this] var closed = false + @volatile private var closed = false private def scheduler(name: String) = Executors.newScheduledThreadPool(1, Utils.namedThreadFactory(name)) - private[this] val running = new AtomicBoolean() - private[this] val queue = new ConcurrentLinkedQueue[(String, MessageBufferPacker => Unit)] - private[this] val consumer = new ForwardConsumer(maximumPulls, connection, queue, packerConfig) - private[this] val worker = scheduler("fluflu-scheduler") + private val running = new AtomicBoolean() + private val queue = new ConcurrentLinkedQueue[(String, MessageBufferPacker => Unit)] + private val consumer = new ForwardConsumer(maximumPulls, connection, queue, packerConfig) + private val worker = scheduler("fluflu-scheduler") private object Worker extends Runnable { def start(): Either[Exception, Unit] = diff --git a/modules/core/src/main/scala/fluflu/Connection.scala b/modules/core/src/main/scala/fluflu/Connection.scala index f02954e0..d2150fa0 100644 --- a/modules/core/src/main/scala/fluflu/Connection.scala +++ b/modules/core/src/main/scala/fluflu/Connection.scala @@ -62,9 +62,9 @@ object Connection { with LazyLogging { import StandardSocketOptions._ - @volatile private[this] var closed: Boolean = false + @volatile private var closed: Boolean = false - @volatile private[this] var channel: SocketChannel = + @volatile private var channel: SocketChannel = doConnect(channelOpen, 0, Sleeper(settings.connectionBackof, settings.connectionTimeout, clock)).get protected def channelOpen: SocketChannel = { @@ -159,7 +159,7 @@ object Connection { } } - private[this] val ackBuffer = ByteBuffer.allocate(256) + private val ackBuffer = ByteBuffer.allocate(256) def writeAndRead(message: ByteBuffer): Try[ByteBuffer] = for { diff --git a/modules/core/src/main/scala/fluflu/Consumer.scala b/modules/core/src/main/scala/fluflu/Consumer.scala index 98fd5a91..449b3eaf 100644 --- a/modules/core/src/main/scala/fluflu/Consumer.scala +++ b/modules/core/src/main/scala/fluflu/Consumer.scala @@ -41,13 +41,13 @@ final class ForwardConsumer private[fluflu] ( UA: Unpacker[Option[Ack]] ) extends Consumer with LazyLogging { - private[this] val errorQueue: util.Queue[(String, ByteBuffer)] = new ConcurrentLinkedQueue[(String, ByteBuffer)]() + private val errorQueue: util.Queue[(String, ByteBuffer)] = new ConcurrentLinkedQueue[(String, ByteBuffer)]() - private[this] val mPacker = new ThreadLocal[MessageBufferPacker] { + private val mPacker = new ThreadLocal[MessageBufferPacker] { override def initialValue(): MessageBufferPacker = packerConfig.newBufferPacker() } - private[this] val b64e = Base64.getEncoder + private val b64e = Base64.getEncoder type E = (String, MessageBufferPacker => Unit) @@ -80,7 +80,7 @@ final class ForwardConsumer private[fluflu] ( } def makeMessages(m: Map[String, ListBuffer[MessageBufferPacker => Unit]]): Iterator[(String, ByteBuffer)] = - m.iterator.map((makeMessage _).tupled).collect { case Some(v) => v } + m.iterator.map { case (a, b) => makeMessage(a, b) }.collect { case Some(v) => v } private def send(chunk: String, msg: ByteBuffer): Unit = connection.writeAndRead(msg) match { @@ -110,7 +110,7 @@ final class ForwardConsumer private[fluflu] ( def consume(): Unit = if (msgQueue.isEmpty && errorQueue.isEmpty) () else { - retrieveErrors().foreach((send _).tupled) - makeMessages(retrieveElements()).foreach((send _).tupled) + retrieveErrors().foreach { case (a, b) => send(a, b) } + makeMessages(retrieveElements()).foreach { case (a, b) => send(a, b) } } } diff --git a/modules/core/src/main/scala/fluflu/Sleeper.scala b/modules/core/src/main/scala/fluflu/Sleeper.scala index 372af335..a460a03b 100644 --- a/modules/core/src/main/scala/fluflu/Sleeper.scala +++ b/modules/core/src/main/scala/fluflu/Sleeper.scala @@ -14,7 +14,7 @@ trait Sleeper { object Sleeper { def apply(backoff: Backoff, timeout: FiniteDuration, clock: Clock): Sleeper = new Sleeper { - private[this] val start = Instant.now(clock) + private val start = Instant.now(clock) def giveUp: Boolean = Instant.now(clock).minusNanos(timeout.toNanos).compareTo(start) > 0 diff --git a/modules/msgpack-mess/src/main/scala/fluflu/msgpack/instances/MessPackerInstances.scala b/modules/msgpack-mess/src/main/scala/fluflu/msgpack/instances/MessPackerInstances.scala index 2d448dab..fd74402f 100644 --- a/modules/msgpack-mess/src/main/scala/fluflu/msgpack/instances/MessPackerInstances.scala +++ b/modules/msgpack-mess/src/main/scala/fluflu/msgpack/instances/MessPackerInstances.scala @@ -20,16 +20,16 @@ private[instances] trait MessPackerInstances { encodeA(a).pack(packer) } - private[this] val encodeMOption: Encoder[MOption] = derivedEncoder[MOption] + private val encodeMOption: Encoder[MOption] = derivedEncoder[MOption] implicit val packMOptionByMess: Packer[MOption] = new Packer[MOption] { def apply(a: MOption, packer: MessagePacker): Unit = encodeMOption(a).pack(packer) } - private[this] val unpackerConfig = new MessagePack.UnpackerConfig().withBufferSize(124) + private val unpackerConfig = new MessagePack.UnpackerConfig().withBufferSize(124) - implicit private[this] val decodeOptionAck: Decoder[Option[Ack]] = derivedDecoder[Ack].map(Option.apply) + implicit private val decodeOptionAck: Decoder[Option[Ack]] = derivedDecoder[Ack].map(Option.apply) implicit val unpackAckByMess: Unpacker[Option[Ack]] = new Unpacker[Option[Ack]] { def apply(bytes: ByteBuffer): Either[Throwable, Option[Ack]] = diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 4d16d037..4807c8c4 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -2,7 +2,6 @@ import sbt._ object Dependencies { val Ver = new { - val `scala2.12` = "2.12.19" val `scala2.13` = "2.13.14" val scala3 = "3.4.2" @@ -18,11 +17,6 @@ object Dependencies { } } - def is2_13(v: String): Boolean = CrossVersion.partialVersion(v) match { - case Some((2, 13)) => true - case _ => false - } - val Pkg = new { lazy val msgpackJava = "org.msgpack" % "msgpack-core" % Ver.msgpackJava lazy val mess = "com.github.tkrs" %% "mess-core" % Ver.mess