Skip to content

Commit

Permalink
finagle-redis: Upgrade to 2.13
Browse files Browse the repository at this point in the history
Problem

No cross-build for finagle-redis 2.13

Solution

breakouts eliminated, include 2.13 in finagle-redis cross versions.

Signed-off-by: Jing Yan <[email protected]>

Differential Revision: https://phabricator.twitter.biz/D381107
  • Loading branch information
martijnhoekstra authored and jenkins committed Oct 8, 2019
1 parent e8ffa9c commit d90ae64
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 25 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ New Features

* finagle-{mux,thrift,thrift-mux}: Enables cross-build for 2.13.0. ``PHAB_ID=D373165``

* finagle-redis: Enables cross-build for 2.13.0. ``PHAB_ID=D381107``

* finagle-tunable: Enables cross-build for 2.13.0. ``PHAB_ID=D373170``

* finagle-grpc-context: Enables cross-build for 2.13.0. ``PHAB_ID=D373168``
Expand Down
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,8 @@ lazy val finagleRedis = Project(
id = "finagle-redis",
base = file("finagle-redis")
).settings(
sharedSettings
sharedSettings,
withTwoThirteen
).configs(
IntegrationTest extend(Test)
).settings(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.twitter.finagle.redis.protocol._
import com.twitter.finagle.redis.util.ReplyFormat
import com.twitter.io.Buf
import com.twitter.util.Future
import scala.collection.breakOut

private[redis] trait PubSubCommands { self: BaseClient =>

Expand All @@ -28,10 +27,10 @@ private[redis] trait PubSubCommands { self: BaseClient =>
Future.value(
messages
.grouped(2)
.toSeq
.map({
case List(BulkReply(channel), IntegerReply(num)) => channel -> num
})(breakOut)
})
.toMap
)
case EmptyMBulkReply => Future.value(Map.empty)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private[finagle] class RedisPartitioningService(
case d: Del => d.copy(keys = pKeys)
case s: SInter => s.copy(keys = pKeys)
case m: MGet => m.copy(keys = pKeys)
case m: MSet => m.copy(kv = m.kv.filterKeys(pKeys.toSet))
case m: MSet => m.copy(kv = m.kv.filterKeys(pKeys.toSet).toMap)
case _ => unsupportedCommand(command)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ private[redis] trait SortedSetCommands { self: BaseClient =>
case MBulkReply(messages) => withScoresHelper(withScores)(messages)
case EmptyMBulkReply => withScoresHelper(withScores)(Nil)
}
parse andThen Future.value
parse.andThen(Future.value(_))
}

private[this] def withScoresHelper(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ case class BRange(key: Buf, count: Buf, startField: Option[Buf], endField: Optio
case class BMergeEx(key: Buf, fv: Map[Buf, Buf], milliseconds: Long) extends StrictKeyCommand {
def name: Buf = Command.BMERGEEX
override def body: Seq[Buf] = {
val fvList: Seq[Buf] = fv.flatMap {
case (f, v) =>
f :: v :: Nil
}(collection.breakOut)
val fvList: Seq[Buf] = fv.iterator.flatMap {
case (f, v) => f :: v :: Nil
}.toSeq

key +: (Buf.Utf8(milliseconds.toString) +: fvList)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.twitter.finagle.redis.protocol

import com.twitter.io.Buf
import scala.collection.breakOut
import scala.collection.compat.immutable.ArraySeq

trait CommandArgument extends Command

Expand All @@ -21,7 +21,7 @@ class Weights(underlying: Array[Double]) extends CommandArgument with IndexedSeq
def apply(idx: Int) = underlying(idx)
def length = underlying.length

override def body: Seq[Buf] = underlying.map(w => Buf.Utf8(w.toString))(breakOut)
override def body: Seq[Buf] = ArraySeq.unsafeWrapArray(underlying.map(w => Buf.Utf8(w.toString)))

override def toString: String = Weights.toString + " " + this.mkString(" ")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ case class HMGet(key: Buf, fields: Seq[Buf]) extends StrictKeyCommand {
case class HMSet(key: Buf, fv: Map[Buf, Buf]) extends StrictKeyCommand {
def name: Buf = Command.HMSET
override def body: Seq[Buf] = {
val fvList: Seq[Buf] = fv.flatMap {
val fvList: Seq[Buf] = fv.iterator.flatMap {
case (f, v) =>
f :: v :: Nil
}(collection.breakOut)
}.toSeq

key +: fvList
}
Expand All @@ -55,10 +55,10 @@ case class HMSet(key: Buf, fv: Map[Buf, Buf]) extends StrictKeyCommand {
case class HMSetEx(key: Buf, fv: Map[Buf, Buf], milliseconds: Long) extends StrictKeyCommand {
def name: Buf = Command.HMSETEX
override def body: Seq[Buf] = {
val fvList: Seq[Buf] = fv.flatMap {
val fvList: Seq[Buf] = fv.iterator.flatMap {
case (f, v) =>
f :: v :: Nil
}(collection.breakOut)
}.toSeq

key +: (Buf.Utf8(milliseconds.toString) +: fvList)
}
Expand All @@ -67,10 +67,10 @@ case class HMSetEx(key: Buf, fv: Map[Buf, Buf], milliseconds: Long) extends Stri
case class HMergeEx(key: Buf, fv: Map[Buf, Buf], milliseconds: Long) extends StrictKeyCommand {
def name: Buf = Command.HMADDEX
override def body: Seq[Buf] = {
val fvList: Seq[Buf] = fv.flatMap {
val fvList: Seq[Buf] = fv.iterator.flatMap {
case (f, v) =>
f :: v :: Nil
}(collection.breakOut)
}.toSeq

key +: (Buf.Utf8(milliseconds.toString) +: fvList)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ case class XAdd(key: Buf, id: Option[Buf], fv: Map[Buf, Buf]) extends StrictKeyC
override def name: Buf = Command.XADD

override def body: Seq[Buf] = {
val fvList: Seq[Buf] = fv.flatMap {
val fvList: List[Buf] = fv.iterator.flatMap {
case (f, v) => f :: v :: Nil
}(collection.breakOut)
}.toList

Seq(key, id.getOrElse(XAdd.AutogenId)) ++ fvList
key :: id.getOrElse(XAdd.AutogenId) :: fvList
}

override protected def validate(): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,5 +218,5 @@ trait MultiSet extends KeysCommand {
def kv: Map[Buf, Buf]
def keys: Seq[Buf] = kv.keys.toSeq
override def body: Seq[Buf] =
kv.flatMap({ case (k, v) => k :: v :: Nil })(collection.breakOut)
kv.iterator.flatMap { case (k, v) => k :: v :: Nil }.toSeq
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ object RedisCluster { self =>

def address: Option[InetSocketAddress] = instanceStack.head.address
def address(i: Int) = instanceStack(i).address
def addresses: Seq[Option[InetSocketAddress]] = instanceStack.map { i =>
i.address
}
def addresses: Seq[Option[InetSocketAddress]] =
instanceStack.map { i =>
i.address
}.toList

def hostAddresses(from: Int = 0, until: Int = instanceStack.size): String = {
require(instanceStack.nonEmpty)
Expand Down

0 comments on commit d90ae64

Please sign in to comment.