Skip to content

Commit

Permalink
Merge pull request #547 from tkrs/drop-2.12
Browse files Browse the repository at this point in the history
Drop 2.12
  • Loading branch information
tkrs authored Aug 11, 2024
2 parents c9040c8 + b666e82 commit cfc4535
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 35 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
8 changes: 3 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions modules/core/src/main/scala/fluflu/Client.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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] =
Expand Down
6 changes: 3 additions & 3 deletions modules/core/src/main/scala/fluflu/Connection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions modules/core/src/main/scala/fluflu/Consumer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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) }
}
}
2 changes: 1 addition & 1 deletion modules/core/src/main/scala/fluflu/Sleeper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]] =
Expand Down
6 changes: 0 additions & 6 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
Expand Down

0 comments on commit cfc4535

Please sign in to comment.