Skip to content

Commit

Permalink
Merge pull request #32 from sergkh/scala2_13
Browse files Browse the repository at this point in the history
Libraray updates and scala 2.13 support
  • Loading branch information
sergkh authored Apr 17, 2020
2 parents 8c9d999 + 7514a9f commit c1352da
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 20 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist: trusty
language: scala
scala:
- 2.12.4
Expand Down
15 changes: 8 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ organization := "com.impactua"

version := sys.env.getOrElse("TRAVIS_TAG", "1.4.0-SNAPSHOT")

scalaVersion := "2.12.4"
scalaVersion := "2.12.11"

crossScalaVersions := Seq("2.11.8", "2.12.0")
crossScalaVersions := Seq("2.11.8", "2.12.11", "2.13.1")

licenses += ("MIT", url("http://opensource.org/licenses/MIT"))

Expand All @@ -21,11 +21,12 @@ bintrayPackageLabels := Seq("scala", "redis", "netty")

concurrentRestrictions in Global += Tags.limit(Tags.Test, 1)

val nettyVersion = "4.1.20.Final"
val nettyVersion = "4.1.48.Final"

libraryDependencies ++= Seq(
"io.netty" % "netty-handler" % nettyVersion,
"io.netty" % "netty-transport-native-epoll" % nettyVersion classifier "linux-x86_64",
"org.scalatest" %% "scalatest" % "3.0.4" % Test,
"com.storm-enroute" %% "scalameter" % "0.8.2" % Test
"io.netty" % "netty-handler" % nettyVersion,
"io.netty" % "netty-transport-native-epoll" % nettyVersion classifier "linux-x86_64",
"io.netty" % "netty-transport-native-kqueue" % nettyVersion classifier "osx-x86_64",
"org.scalatest" %% "scalatest" % "3.1.1" % Test,
"com.storm-enroute" %% "scalameter" % "0.19" % Test
)
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.1.0
sbt.version=1.3.9
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.1")
addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.4")
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import java.util.concurrent.{ConcurrentHashMap, Executors}
import com.fotolog.redis.utils.SortedSetOptions.ZaddOptions.{NX, XX, NO}
import com.fotolog.redis.{KeyType, RedisException}

import scala.collection.JavaConversions._
import scala.collection.JavaConverters._
import scala.collection.mutable.ListBuffer
import scala.compat.Platform
import scala.concurrent.{ExecutionContext, Future}
Expand Down Expand Up @@ -269,6 +269,7 @@ class InMemoryRedisConnection(dbName: String) extends RedisConnection {
case Keys(pattern) =>
MultiBulkDataResult(
map.keys()
.asScala
.filter(_.matches(pattern.replace("*", ".*?").replace("?", ".?")))
.map(k => BulkDataResult(Some(k.getBytes))).toSeq
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import io.netty.bootstrap.Bootstrap
import io.netty.buffer.Unpooled
import io.netty.channel._
import io.netty.channel.epoll.{EpollEventLoopGroup, EpollSocketChannel}
import io.netty.channel.kqueue.{KQueueEventLoopGroup, KQueueSocketChannel}
import io.netty.channel.nio.NioEventLoopGroup
import io.netty.channel.socket.SocketChannel
import io.netty.channel.socket.nio.NioSocketChannel
Expand All @@ -20,7 +21,7 @@ import scala.util.Try

object Netty4RedisConnection {

private[redis] val cmdQueue = new ArrayBlockingQueue[(Netty4RedisConnection, ResultFuture)](2048)
private[redis] val cmdQueue = new ArrayBlockingQueue[(Netty4RedisConnection, ResultFuture)](4096)
private[redis] val commandEncoder = new RedisCommandEncoder()

private[redis] val queueProcessor = new Runnable {
Expand Down Expand Up @@ -60,10 +61,13 @@ class Netty4RedisConnection(val host: String, val port: Int) extends RedisConnec
val osName = Option(System.getProperties.getProperty("os.name")).map(_.toLowerCase)
val isUnix = osName.exists(os => os.contains("nix") || os.contains("nux") || os.contains("aix"))

if (isUnix) {
new EpollEventLoopGroup() -> classOf[EpollSocketChannel]
} else {
new NioEventLoopGroup() -> classOf[NioSocketChannel]
osName match {
case Some(linux) if linux.contains("nux") =>
new EpollEventLoopGroup() -> classOf[EpollSocketChannel]
case Some(osx) if osx.contains("mac") =>
new KQueueEventLoopGroup() -> classOf[KQueueSocketChannel]
case _ =>
new NioEventLoopGroup() -> classOf[NioSocketChannel]
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/com/fotolog/redis/connections/Results.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private[redis] case class ComplexResultFuture(complexCmd: Cmd, parts: Int) exten
responses += result

if (responses.length == parts) {
promise.success(MultiBulkDataResult(responses))
promise.success(MultiBulkDataResult(responses.toSeq))
true
} else {
false
Expand Down
6 changes: 3 additions & 3 deletions src/test/scala/com/fotolog/redis/ClientBenchmark.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ object ClientBenchmark extends Bench.LocalTime {
val future = Future.traverse(1 to i) { i =>
client.pingAsync
}
Await.result(future, 30 seconds)
Await.result(future, 30.seconds)
}
}

Expand All @@ -69,7 +69,7 @@ object ClientBenchmark extends Bench.LocalTime {
val future = Future.traverse(1 to i) { i =>
client.getAsync[String]("foo")
}
Await.result(future, 30 seconds)
Await.result(future, 30.seconds)
}
}

Expand All @@ -88,7 +88,7 @@ object ClientBenchmark extends Bench.LocalTime {
val future = Future.traverse(1 to i) { i =>
client.setAsync("foo", "bar")
}
Await.result(future, 30 seconds)
Await.result(future, 30.seconds)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/com/fotolog/redis/InMemoryClientSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class InMemoryClientSpec extends FlatSpec with Matchers with TestClient {

assert(client.hexists("hash_zoo-key", "vaz"), "Key 'vaz' should exist in map `zoo-key`")
assert(4 === client.hlen("hash_zoo-key"), "Length of map elements should be 2")
client.hkeys("hash_zoo-key") shouldBe Seq("wry", "vaz", "baz", "foo")
client.hkeys("hash_zoo-key").toSet shouldBe Set("wry", "vaz", "baz", "foo")
client.hkeys("hash_nonexistent-key") shouldBe Nil
}

Expand Down

0 comments on commit c1352da

Please sign in to comment.