From 542adabf680066bf4c8629a96abc1db821d1b21c Mon Sep 17 00:00:00 2001 From: Filippo Mariotti Date: Mon, 29 Oct 2018 19:58:26 +0000 Subject: [PATCH] Removed dependency from typelevel compiler (#49) * Removed dependency from typelevel compiler * Fixed 2.11.x compilation * Readme and improved build --- .travis.yml | 2 +- README.md | 5 +- build.sbt | 74 ++++++++++++------- .../boilerplate/HashPExtra.scala.template | 2 +- .../HyperLogLogPExtra.scala.template | 2 +- .../boilerplate/StringPExtra.scala.template | 2 +- .../main/scala-2.11/laserdisc/protocol.scala | 4 +- core/src/main/scala/laserdisc/package.scala | 7 ++ .../laserdisc/protocol/ConnectionP.scala | 16 ++-- .../main/scala/laserdisc/protocol/HashP.scala | 4 +- .../laserdisc/protocol/HyperLogLogP.scala | 4 +- .../main/scala/laserdisc/protocol/KeyP.scala | 8 +- .../main/scala/laserdisc/protocol/ListP.scala | 8 +- .../main/scala/laserdisc/protocol/Read.scala | 13 ++-- .../scala/laserdisc/protocol/ServerP.scala | 46 ++++++------ .../scala/laserdisc/protocol/StringP.scala | 32 ++++---- .../scala/laserdisc/fs2/RedisClientSpec.scala | 1 - project/build.properties | 2 +- 18 files changed, 131 insertions(+), 101 deletions(-) diff --git a/.travis.yml b/.travis.yml index 37c9ba17..5570bb13 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ sudo: false dist: trusty language: scala scala: -- 2.12.4-bin-typelevel-4 +- 2.12.7 - 2.11.11-bin-typelevel-4 jdk: - oraclejdk8 diff --git a/README.md b/README.md index b8f60dfe..0ddf0c04 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,8 @@ LaserDisc is a(nother) Scala driver for [Redis](https://redis.io/), written in S It differentiates itself from the others for having a core layer, which is made up of all the supported Redis commands and the Redis Serialization Protocol ([RESP](https://redis.io/topics/protocol)), that is strongly typed and which makes heavy use of [shapeless](https://github.com/milessabin/shapeless) and [refined](https://github.com/fthomas/refined) to -achieve this. It's also worth noting that the core - in order to be built - makes use of -[Typelevel's Scala 2.12](https://typelevel.org/scala) fork, since it requires the enhancements on implicit heuristics -and the surfacing of literal types. Finally, it also provides an implementation of RESP built using +achieve this. It's also worth noting that the core - in order to be built on scala 2.11.x - makes use of +[Typelevel's Scala 2.11](https://typelevel.org/scala) fork, since it requires the enhancements on implicit heuristics. Finally, it also provides an implementation of RESP built using [scodec](http://scodec.org/). On top of this, one or more clients can be implemented. The only one currently available out of the box is built using diff --git a/build.sbt b/build.sbt index c3e47251..eb93944e 100644 --- a/build.sbt +++ b/build.sbt @@ -1,10 +1,15 @@ -import sbtcrossproject.{CrossType, crossProject} +import sbtcrossproject.CrossPlugin.autoImport.crossProject +import sbtcrossproject.CrossType + +val `scala 211` = "2.11.11-bin-typelevel-4" +val `scala 212` = "2.12.7" val V = new { val fs2 = "1.0.0" val `kind-projector` = "0.9.8" val kittens = "1.2.0" - val refined = "0.8.7" //FIXME can't upgrade see https://gist.github.com/sirocchj/64a00a28f5cc5776140c776c7db4e2e3 + val refined = "0.9.2" + val refined211 = "0.8.7" val scalacheck = "1.13.5" val scalatest = "3.0.5" val `scodec-bits` = "1.1.6" @@ -17,7 +22,6 @@ val V = new { val `fs2-core` = Def.setting("co.fs2" %%% "fs2-core" % V.fs2) val `fs2-io` = Def.setting("co.fs2" %% "fs2-io" % V.fs2) val kittens = Def.setting("org.typelevel" %%% "kittens" % V.kittens) -val refined = Def.setting("eu.timepit" %%% "refined" % V.refined) val `scodec-bits` = Def.setting("org.scodec" %%% "scodec-bits" % V.`scodec-bits`) val `scodec-core` = Def.setting("org.scodec" %%% "scodec-core" % V.`scodec-core`) val `scodec-stream` = Def.setting("org.scodec" %%% "scodec-stream" % V.`scodec-stream`) @@ -25,6 +29,13 @@ val shapeless = Def.setting("com.chuusai" %%% "shapeless" % V. val `log-effect-fs2` = Def.setting("io.laserdisc" %%% "log-effect-fs2" % V.`log-effect-fs2`) val scalacheck = Def.setting("org.scalacheck" %%% "scalacheck" % V.scalacheck % Test) val scalatest = Def.setting("org.scalatest" %%% "scalatest" % V.scalatest % Test) +val refined = Def.setting { + CrossVersion.partialVersion(scalaVersion.value) match { + case Some((2, 11)) => "eu.timepit" %%% "refined" % V.refined211 + case _ => "eu.timepit" %%% "refined" % V.refined + } +} + val `kind-projector-compiler-plugin` = Def.setting { compilerPlugin("org.spire-math" % "kind-projector" % V.`kind-projector` cross CrossVersion.binary) @@ -34,7 +45,15 @@ val `scalajs-compiler-plugin` = Def.setting { } val coreDeps = Def.Initialize.join { - Seq(`kind-projector-compiler-plugin`, refined, `scodec-bits`, `scodec-core`, shapeless, scalacheck, scalatest) + Seq( + `kind-projector-compiler-plugin`, + `scodec-bits`, + `scodec-core`, + shapeless, + refined, + scalacheck, + scalatest + ) } val fs2Deps = Def.Initialize.join { @@ -81,23 +100,24 @@ val externalApiMappings = Def.task { } val versionDependantScalacOptions = Def.setting { - def versionDependent(scalaVersion: String, flags: Seq[String]) = CrossVersion.partialVersion(scalaVersion) match { - case Some((2, major)) if major >= 12 => - flags ++ Seq( - "-Xlint:constant", // Evaluation of a constant arithmetic expression results in an error. - "-Ywarn-extra-implicit", // Warn when more than one implicit parameter section is defined. - "-Ywarn-unused:explicits", // Warn if a parameter is unused. - "-Ywarn-unused:imports", // Warn if an import selector is not referenced. - "-Ywarn-unused:locals", // Warn if a local definition is unused. - "-Ywarn-unused:patvars", // Warn if a variable bound in a pattern is unused. - "-Ywarn-unused:privates", // Warn if a private member is unused. - "-Ywarn-value-discard" // Warn when non-Unit expression results are unused. - ) - case _ => - flags - .filterNot(_ == "-Xlint:missing-interpolator") //@implicitNotFound uses ${A} syntax w/o need for s interpolator - } - + def versionDependent(scalaVersion: String, flags: Seq[String]) = + CrossVersion.partialVersion(scalaVersion) match { + case Some((2, major)) if major >= 12 => + flags ++ Seq( + "-Xlint:constant", // Evaluation of a constant arithmetic expression results in an error. + "-Ywarn-extra-implicit", // Warn when more than one implicit parameter section is defined. + "-Ywarn-unused:explicits", // Warn if a parameter is unused. + "-Ywarn-unused:imports", // Warn if an import selector is not referenced. + "-Ywarn-unused:locals", // Warn if a local definition is unused. + "-Ywarn-unused:patvars", // Warn if a variable bound in a pattern is unused. + "-Ywarn-unused:privates", // Warn if a private member is unused. + "-Ywarn-value-discard" // Warn when non-Unit expression results are unused. + ) + case _ => + (flags ++ Seq("-Yinduction-heuristics", "-Yliteral-types")) + .filterNot(_ == "-Xlint:missing-interpolator") //@implicitNotFound uses ${A} syntax w/o need for s interpolator + } + val flags = Seq( "-deprecation", // Emit warning and location for usages of deprecated APIs. "-encoding", @@ -136,8 +156,6 @@ val versionDependantScalacOptions = Def.setting { "-Ywarn-nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'. "-Ywarn-nullary-unit", // Warn when nullary methods return Unit. "-Ywarn-numeric-widen", // Warn when numerics are widened. - "-Yinduction-heuristics", // Nobody wants recursive implicit searches that last forever, we need TLS for this - "-Yliteral-types" // Allow inferring singleton types, we need TLS for this in 2.12 ) versionDependent(scalaVersion.value, flags) @@ -146,13 +164,17 @@ val versionDependantScalacOptions = Def.setting { inThisBuild { Def.settings( organization := "io.laserdisc", - scalaOrganization := "org.typelevel", - scalaVersion := "2.12.4-bin-typelevel-4" + scalaVersion := `scala 212` ) } lazy val commonSettings = Seq( - crossScalaVersions := Seq("2.11.11-bin-typelevel-4", "2.12.4-bin-typelevel-4"), + scalaOrganization := + (CrossVersion.partialVersion(scalaVersion.value) match { + case Some((2, 11)) => "org.typelevel" + case _ => "org.scala-lang" + }), + crossScalaVersions := Seq(`scala 211`, `scala 212`), scalacOptions ++= versionDependantScalacOptions.value, Compile / console / scalacOptions --= Seq("-Ywarn-unused:imports", "-Xfatal-warnings"), Test / console / scalacOptions := (Compile / console / scalacOptions).value diff --git a/core/src/main/boilerplate/HashPExtra.scala.template b/core/src/main/boilerplate/HashPExtra.scala.template index f570b2df..6b47ac35 100644 --- a/core/src/main/boilerplate/HashPExtra.scala.template +++ b/core/src/main/boilerplate/HashPExtra.scala.template @@ -23,7 +23,7 @@ trait HashPExtra { this: HashP => ] //HMSET - [..21#final def hmset[[#A1 <: XString, B1: Show#]](key: Key, [#field1: SingletonKey[A1], value1: B1#]): Protocol.Aux["OK"] = { + [..21#final def hmset[[#A1 <: XString, B1: Show#]](key: Key, [#field1: SingletonKey[A1], value1: B1#]): Protocol.Aux[OK] = { [#val tagged1 = tag[A1](Symbol(field1.value))# ] hmset(key, [#labelled.field[tagged1.type](value1)# :: ] :: HNil) diff --git a/core/src/main/boilerplate/HyperLogLogPExtra.scala.template b/core/src/main/boilerplate/HyperLogLogPExtra.scala.template index 7ab97fdf..54ce002f 100644 --- a/core/src/main/boilerplate/HyperLogLogPExtra.scala.template +++ b/core/src/main/boilerplate/HyperLogLogPExtra.scala.template @@ -13,7 +13,7 @@ trait HyperLogLogPExtra { this: HyperLogLogP => ] //PFMERGE - [..20#final def pfmerge(sourceKey##1: Key, [#sourceKey2: Key#], destinationKey: Key): Protocol.Aux["OK"] = + [..20#final def pfmerge(sourceKey##1: Key, [#sourceKey2: Key#], destinationKey: Key): Protocol.Aux[OK] = pfmerge(TwoOrMoreKeys.unsafeFrom(sourceKey##1 :: [#sourceKey2# :: ] :: Nil), destinationKey)# ] } \ No newline at end of file diff --git a/core/src/main/boilerplate/StringPExtra.scala.template b/core/src/main/boilerplate/StringPExtra.scala.template index 56897271..5e7358d4 100644 --- a/core/src/main/boilerplate/StringPExtra.scala.template +++ b/core/src/main/boilerplate/StringPExtra.scala.template @@ -19,7 +19,7 @@ trait StringPExtra { this: StringP => ] //MSET - [#final def mset[[#A1 <: XString, B1: Show#]]([#key1: SingletonKey[A1], value1: B1#]): Protocol.Aux["OK"] = { + [#final def mset[[#A1 <: XString, B1: Show#]]([#key1: SingletonKey[A1], value1: B1#]): Protocol.Aux[OK] = { [#val tagged1 = tag[A1](Symbol(key1.value))# ] mset([#labelled.field[tagged1.type](value1)# :: ] :: HNil) diff --git a/core/src/main/scala-2.11/laserdisc/protocol.scala b/core/src/main/scala-2.11/laserdisc/protocol.scala index 01813af8..a54062f5 100644 --- a/core/src/main/scala-2.11/laserdisc/protocol.scala +++ b/core/src/main/scala-2.11/laserdisc/protocol.scala @@ -1,7 +1,9 @@ package laserdisc package object protocol { - implicit def eitherSyntaxBase[A, B](aOrB: A | B): EitherSyntaxBaseOps[A, B] = new EitherSyntaxBaseOps(aOrB) + + implicit def eitherSyntaxBase[A, B](aOrB: A | B): EitherSyntaxBaseOps[A, B] = + new EitherSyntaxBaseOps(aOrB) } final private[laserdisc] class EitherSyntaxBaseOps[A, B](private val aOrB: A | B) extends AnyVal { diff --git a/core/src/main/scala/laserdisc/package.scala b/core/src/main/scala/laserdisc/package.scala index d3a0f2cb..551c0b2c 100644 --- a/core/src/main/scala/laserdisc/package.scala +++ b/core/src/main/scala/laserdisc/package.scala @@ -1,6 +1,7 @@ import java.{lang => j} import eu.timepit.refined.W +import eu.timepit.refined.auto._ import eu.timepit.refined.api._ import eu.timepit.refined.boolean.{And, Not, Or, True} import eu.timepit.refined.char.Whitespace @@ -23,6 +24,12 @@ package object laserdisc { final type RESP = protocol.RESP final type Show[A] = protocol.Show[A] + final type OK = String Refined Equal[W.`"OK"`.T] + final type PONG = String Refined Equal[W.`"PONG"`.T] + + final val OK: OK = "OK" + final val PONG: PONG = "PONG" + //object forwarders final val Protocol = protocol.Protocol final val Read = protocol.Read diff --git a/core/src/main/scala/laserdisc/protocol/ConnectionP.scala b/core/src/main/scala/laserdisc/protocol/ConnectionP.scala index 0f7c162c..00810e86 100644 --- a/core/src/main/scala/laserdisc/protocol/ConnectionP.scala +++ b/core/src/main/scala/laserdisc/protocol/ConnectionP.scala @@ -4,22 +4,22 @@ package protocol trait ConnectionP { import Read.==> - private[this] implicit final val pongRead: SimpleString ==> "PONG" = Read.instancePF { - case SimpleString("PONG") => "PONG" + private[this] implicit final val pongRead: SimpleString ==> PONG = Read.instancePF { + case SimpleString("PONG") => PONG } - final def auth(password: Key): Protocol.Aux["OK"] = Protocol("AUTH", password).as[SimpleString, "OK"] + final def auth(password: Key): Protocol.Aux[OK] = Protocol("AUTH", password).as[SimpleString, OK] final def echo(message: Key): Protocol.Aux[Key] = Protocol("ECHO", message).as[NonNullBulkString, Key] - final val ping: Protocol.Aux["PONG"] = Protocol("PING", Nil).as[SimpleString, "PONG"] + final val ping: Protocol.Aux[PONG] = Protocol("PING", Nil).as[SimpleString, PONG] final def ping(message: Key): Protocol.Aux[Key] = Protocol("PING", message).as[NonNullBulkString, Key] - final val quit: Protocol.Aux["OK"] = Protocol("QUIT", Nil).as[SimpleString, "OK"] + final val quit: Protocol.Aux[OK] = Protocol("QUIT", Nil).as[SimpleString, OK] - final def select(index: DbIndex): Protocol.Aux["OK"] = Protocol("SELECT", index).as[SimpleString, "OK"] + final def select(index: DbIndex): Protocol.Aux[OK] = Protocol("SELECT", index).as[SimpleString, OK] - final def swapdb(index1: DbIndex, index2: DbIndex): Protocol.Aux["OK"] = - Protocol("SWAPDB", index1 :: index2 :: Nil).as[SimpleString, "OK"] + final def swapdb(index1: DbIndex, index2: DbIndex): Protocol.Aux[OK] = + Protocol("SWAPDB", index1 :: index2 :: Nil).as[SimpleString, OK] } diff --git a/core/src/main/scala/laserdisc/protocol/HashP.scala b/core/src/main/scala/laserdisc/protocol/HashP.scala index 973a250d..8faeee57 100644 --- a/core/src/main/scala/laserdisc/protocol/HashP.scala +++ b/core/src/main/scala/laserdisc/protocol/HashP.scala @@ -42,7 +42,7 @@ trait HashP { implicit ev0: Length.Aux[L, N], ev1: N >= _1, ev2: LUBConstraint[L, FieldType[_, _]] - ): Protocol.Aux["OK"] = Protocol("HMSET", key :: l).as[SimpleString, "OK"] + ): Protocol.Aux[OK] = Protocol("HMSET", key :: l).as[SimpleString, OK] final def hmset[P <: Product, L <: HList, N <: Nat](key: Key, product: P)( implicit gen: LabelledGeneric.Aux[P, L], @@ -50,7 +50,7 @@ trait HashP { ev1: N >= _1, ev2: LUBConstraint[L, FieldType[_, _]], ev3: RESPParamWrite[L] - ): Protocol.Aux["OK"] = Protocol("HMSET", key :: gen.to(product)).as[SimpleString, "OK"] + ): Protocol.Aux[OK] = Protocol("HMSET", key :: gen.to(product)).as[SimpleString, OK] final def hscan(key: Key, cursor: NonNegLong): Protocol.Aux[ScanKV] = Protocol("HSCAN", key :: cursor :: HNil).as[NonNilArray, ScanKV] diff --git a/core/src/main/scala/laserdisc/protocol/HyperLogLogP.scala b/core/src/main/scala/laserdisc/protocol/HyperLogLogP.scala index 705e6236..42ffddcb 100644 --- a/core/src/main/scala/laserdisc/protocol/HyperLogLogP.scala +++ b/core/src/main/scala/laserdisc/protocol/HyperLogLogP.scala @@ -8,8 +8,8 @@ trait HyperLogLogP { final def pfcount(keys: OneOrMoreKeys): Protocol.Aux[NonNegInt] = Protocol("PFCOUNT", keys.value).as[Integer, NonNegInt] - final def pfmerge(sourceKeys: TwoOrMoreKeys, destinationKey: Key): Protocol.Aux["OK"] = - Protocol("PFMERGE", destinationKey :: sourceKeys.value).as[SimpleString, "OK"] + final def pfmerge(sourceKeys: TwoOrMoreKeys, destinationKey: Key): Protocol.Aux[OK] = + Protocol("PFMERGE", destinationKey :: sourceKeys.value).as[SimpleString, OK] } trait AllHyperLogLogP extends HyperLogLogP with HyperLogLogPExtra diff --git a/core/src/main/scala/laserdisc/protocol/KeyP.scala b/core/src/main/scala/laserdisc/protocol/KeyP.scala index 44813e24..63a99ce7 100644 --- a/core/src/main/scala/laserdisc/protocol/KeyP.scala +++ b/core/src/main/scala/laserdisc/protocol/KeyP.scala @@ -135,11 +135,11 @@ trait KeyP { final def renamenx(key: Key, newKey: Key): Protocol.Aux[Boolean] = Protocol("RENAMENX", key :: newKey :: Nil).as[Integer, Boolean] - final def restore(key: Key, ttl: NonNegLong, serializedValue: NonNullBulkString): Protocol.Aux["OK"] = - Protocol("RESTORE", key :: ttl :: serializedValue :: HNil).as[SimpleString, "OK"] + final def restore(key: Key, ttl: NonNegLong, serializedValue: NonNullBulkString): Protocol.Aux[OK] = + Protocol("RESTORE", key :: ttl :: serializedValue :: HNil).as[SimpleString, OK] - final def restorereplace(key: Key, ttl: NonNegLong, serializedValue: NonNullBulkString): Protocol.Aux["OK"] = - Protocol("RESTORE", key :: ttl :: serializedValue :: "REPLACE" :: HNil).as[SimpleString, "OK"] + final def restorereplace(key: Key, ttl: NonNegLong, serializedValue: NonNullBulkString): Protocol.Aux[OK] = + Protocol("RESTORE", key :: ttl :: serializedValue :: "REPLACE" :: HNil).as[SimpleString, OK] final def scan(cursor: NonNegLong): Protocol.Aux[Scan[Key]] = Protocol("SCAN", cursor).as[NonNilArray, Scan[Key]] diff --git a/core/src/main/scala/laserdisc/protocol/ListP.scala b/core/src/main/scala/laserdisc/protocol/ListP.scala index 3866c5c9..06ff67d9 100644 --- a/core/src/main/scala/laserdisc/protocol/ListP.scala +++ b/core/src/main/scala/laserdisc/protocol/ListP.scala @@ -53,11 +53,11 @@ trait ListP { final def lrem[A: Show](key: Key, count: Index, value: A): Protocol.Aux[NonNegInt] = Protocol("LREM", key :: count :: value :: HNil).as[Integer, NonNegInt] - final def lset[A: Show](key: Key, index: Index, value: A): Protocol.Aux["OK"] = - Protocol("LSET", key :: index :: value :: HNil).as[SimpleString, "OK"] + final def lset[A: Show](key: Key, index: Index, value: A): Protocol.Aux[OK] = + Protocol("LSET", key :: index :: value :: HNil).as[SimpleString, OK] - final def ltrim(key: Key, start: Index, stop: Index): Protocol.Aux["OK"] = - Protocol("LTRIM", key :: start :: stop :: HNil).as[SimpleString, "OK"] + final def ltrim(key: Key, start: Index, stop: Index): Protocol.Aux[OK] = + Protocol("LTRIM", key :: start :: stop :: HNil).as[SimpleString, OK] final def rpop[A](key: Key)( implicit ev: NonNullBulkString ==> A diff --git a/core/src/main/scala/laserdisc/protocol/Read.scala b/core/src/main/scala/laserdisc/protocol/Read.scala index 1ff40fb4..1cb905dc 100644 --- a/core/src/main/scala/laserdisc/protocol/Read.scala +++ b/core/src/main/scala/laserdisc/protocol/Read.scala @@ -72,8 +72,8 @@ trait LowPriorityReadInstances extends LowerPriorityReadInstances { implicit final val simpleString2StringRead: SimpleString ==> String = Read.instance { case SimpleString(s) => Some(s) } - implicit final val simpleString2OKRead: SimpleString ==> "OK" = Read.instancePF { - case SimpleString("OK") => "OK" + implicit final val simpleString2OKRead: SimpleString ==> OK = Read.instancePF { + case SimpleString("OK") => OK } implicit final val simpleString2KeyRead: SimpleString ==> Key = Read.instancePF { case SimpleString(Key(s)) => s @@ -165,7 +165,7 @@ trait LowPriorityReadInstances extends LowerPriorityReadInstances { implicit final def nonNilArray2Tuple2Read[A, B]( implicit RA: NonNullBulkString ==> A, - RB: NonNullBulkString ==> B, + RB: NonNullBulkString ==> B ): NonNilArray ==> (A, B) = Read.instancePF { case NonNilArray(RA(key) +: RB(value) +: Seq()) => key -> value } @@ -243,9 +243,10 @@ trait LowPriorityReadInstances extends LowerPriorityReadInstances { } implicit final def nonNilArray2HCons[H, T <: HList]( - implicit ev: H <:!< FieldType[_, _], - RH: NonNullBulkString ==> H, - RT: NonNilArray ==> T + implicit + ev: H <:!< FieldType[_, _], + RH: NonNullBulkString ==> H, + RT: NonNilArray ==> T ): NonNilArray ==> (H :: T) = Read.instance { case NonNilArray(RH(h) +: rest) => RT.read(RESP.arr(rest)).map(h :: _) } diff --git a/core/src/main/scala/laserdisc/protocol/ServerP.scala b/core/src/main/scala/laserdisc/protocol/ServerP.scala index 5dcd1189..3cd1a982 100644 --- a/core/src/main/scala/laserdisc/protocol/ServerP.scala +++ b/core/src/main/scala/laserdisc/protocol/ServerP.scala @@ -168,29 +168,29 @@ trait ServerP { final val flag = ShutdownFlag } - final val bgrewriteaof: Protocol.Aux["OK"] = Protocol("BGREWRITEAOF", Nil).as[SimpleString, "OK"] + final val bgrewriteaof: Protocol.Aux[OK] = Protocol("BGREWRITEAOF", Nil).as[SimpleString, OK] - final val bgsave: Protocol.Aux["OK"] = Protocol("BGSAVE", Nil).as[SimpleString, "OK"] + final val bgsave: Protocol.Aux[OK] = Protocol("BGSAVE", Nil).as[SimpleString, OK] final object client { val getname: Protocol.Aux[Option[ConnectionName]] = Protocol("CLIENT", "GETNAME").asC[NullBulkString :+: NonNullBulkString :+: CNil, Option[ConnectionName]] //FIXME other variations of kill - def kill(host: Host, port: Port): Protocol.Aux["OK"] = + def kill(host: Host, port: Port): Protocol.Aux[OK] = Protocol("CLIENT", "KILL" :: s"${Show.hostShow.show(host)}:${Show.portShow.show(port)}" :: Nil) - .as[SimpleString, "OK"] + .as[SimpleString, OK] val list: Protocol.Aux[ConnectedClients] = Protocol("CLIENT", "LIST").as[NonNullBulkString, ConnectedClients] - def pause(milliseconds: PosLong): Protocol.Aux["OK"] = - Protocol("CLIENT", "PAUSE" :: milliseconds :: HNil).as[SimpleString, "OK"] + def pause(milliseconds: PosLong): Protocol.Aux[OK] = + Protocol("CLIENT", "PAUSE" :: milliseconds :: HNil).as[SimpleString, OK] - def setname(connectionName: ConnectionName): Protocol.Aux["OK"] = - Protocol("CLIENT", "SETNAME" :: connectionName.value :: Nil).as[SimpleString, "OK"] + def setname(connectionName: ConnectionName): Protocol.Aux[OK] = + Protocol("CLIENT", "SETNAME" :: connectionName.value :: Nil).as[SimpleString, OK] - val unsetname: Protocol.Aux["OK"] = Protocol("CLIENT", "SETNAME" :: "" :: Nil).as[SimpleString, "OK"] + val unsetname: Protocol.Aux[OK] = Protocol("CLIENT", "SETNAME" :: "" :: Nil).as[SimpleString, OK] } //TODO command? @@ -199,23 +199,23 @@ trait ServerP { def get(parameter: GlobPattern): Protocol.Aux[Configuration] = Protocol("CONFIG", "GET" :: parameter.value :: Nil).as[NonNilArray, Configuration] - val resetstat: Protocol.Aux["OK"] = Protocol("CONFIG", "RESETSTAT").as[SimpleString, "OK"] + val resetstat: Protocol.Aux[OK] = Protocol("CONFIG", "RESETSTAT").as[SimpleString, OK] - val rewrite: Protocol.Aux["OK"] = Protocol("CONFIG", "REWRITE").as[SimpleString, "OK"] + val rewrite: Protocol.Aux[OK] = Protocol("CONFIG", "REWRITE").as[SimpleString, OK] - def set[A: Show](parameter: Key, value: A): Protocol.Aux["OK"] = - Protocol("CONFIG", "SET" :: parameter :: value :: HNil).as[SimpleString, "OK"] + def set[A: Show](parameter: Key, value: A): Protocol.Aux[OK] = + Protocol("CONFIG", "SET" :: parameter :: value :: HNil).as[SimpleString, OK] } final val dbsize: Protocol.Aux[NonNegLong] = Protocol("DBSIZE", Nil).as[Integer, NonNegLong] - final val flushall: Protocol.Aux["OK"] = Protocol("FLUSHALL", Nil).as[SimpleString, "OK"] + final val flushall: Protocol.Aux[OK] = Protocol("FLUSHALL", Nil).as[SimpleString, OK] - final val flushallasync: Protocol.Aux["OK"] = Protocol("FLUSHALL", "ASYNC").as[SimpleString, "OK"] + final val flushallasync: Protocol.Aux[OK] = Protocol("FLUSHALL", "ASYNC").as[SimpleString, OK] - final val flushdb: Protocol.Aux["OK"] = Protocol("FLUSHDB", Nil).as[SimpleString, "OK"] + final val flushdb: Protocol.Aux[OK] = Protocol("FLUSHDB", Nil).as[SimpleString, OK] - final val flushdbasync: Protocol.Aux["OK"] = Protocol("FLUSHDB", "ASYNC").as[SimpleString, "OK"] + final val flushdbasync: Protocol.Aux[OK] = Protocol("FLUSHDB", "ASYNC").as[SimpleString, OK] final val info: Protocol.Aux[Info] = info(servers.info.default) @@ -225,16 +225,16 @@ trait ServerP { final val role: Protocol.Aux[Role] = Protocol("ROLE", Nil).as[NonNilArray, Role] - final val save: Protocol.Aux["OK"] = Protocol("SAVE", Nil).as[SimpleString, "OK"] + final val save: Protocol.Aux[OK] = Protocol("SAVE", Nil).as[SimpleString, OK] - final val shutdown: Protocol.Aux["OK"] = Protocol("SHUTDOWN", Nil).as[SimpleString, "OK"] + final val shutdown: Protocol.Aux[OK] = Protocol("SHUTDOWN", Nil).as[SimpleString, OK] - final def shutdown(flag: ShutdownFlag): Protocol.Aux["OK"] = Protocol("SHUTDOWN", flag).as[SimpleString, "OK"] + final def shutdown(flag: ShutdownFlag): Protocol.Aux[OK] = Protocol("SHUTDOWN", flag).as[SimpleString, OK] - final def slaveof(host: Host, port: Port): Protocol.Aux["OK"] = - Protocol("SLAVEOF", host :: port :: HNil).as[SimpleString, "OK"] + final def slaveof(host: Host, port: Port): Protocol.Aux[OK] = + Protocol("SLAVEOF", host :: port :: HNil).as[SimpleString, OK] - final val slaveofnoone: Protocol.Aux["OK"] = Protocol("SLAVEOF", "NO" :: "ONE" :: Nil).as[SimpleString, "OK"] + final val slaveofnoone: Protocol.Aux[OK] = Protocol("SLAVEOF", "NO" :: "ONE" :: Nil).as[SimpleString, OK] //TODO slowlog? sync? diff --git a/core/src/main/scala/laserdisc/protocol/StringP.scala b/core/src/main/scala/laserdisc/protocol/StringP.scala index 2aa11d31..efc199bb 100644 --- a/core/src/main/scala/laserdisc/protocol/StringP.scala +++ b/core/src/main/scala/laserdisc/protocol/StringP.scala @@ -159,7 +159,7 @@ trait StringP { implicit ev0: Length.Aux[L, N], ev1: N >= _1, ev2: LUBConstraint[L, FieldType[_, _]] - ): Protocol.Aux["OK"] = Protocol("MSET", l).as[SimpleString, "OK"] + ): Protocol.Aux[OK] = Protocol("MSET", l).as[SimpleString, OK] final def mset[P <: Product, L <: HList, N <: Nat](product: P)( implicit gen: LabelledGeneric.Aux[P, L], @@ -167,10 +167,10 @@ trait StringP { ev1: N >= _1, ev2: LUBConstraint[L, FieldType[_, _]], ev3: RESPParamWrite[L] - ): Protocol.Aux["OK"] = Protocol("MSET", gen.to(product)).as[SimpleString, "OK"] + ): Protocol.Aux[OK] = Protocol("MSET", gen.to(product)).as[SimpleString, OK] - final def mset[A: Show](values: OneOrMore[(Key, A)]): Protocol.Aux["OK"] = - Protocol("MSET", values.value).as[SimpleString, "OK"] + final def mset[A: Show](values: OneOrMore[(Key, A)]): Protocol.Aux[OK] = + Protocol("MSET", values.value).as[SimpleString, OK] final def msetnx[L <: HList: RESPParamWrite, N <: Nat](l: L)( implicit ev0: Length.Aux[L, N], @@ -189,27 +189,27 @@ trait StringP { final def msetnx[A: Show](values: OneOrMore[(Key, A)]): Protocol.Aux[Boolean] = Protocol("MSETNX", values.value).as[Integer, Boolean] - final def psetex[A: Show](key: Key, milliseconds: PosLong, value: A): Protocol.Aux["OK"] = - Protocol("PSETEX", key :: milliseconds :: value :: HNil).as[SimpleString, "OK"] + final def psetex[A: Show](key: Key, milliseconds: PosLong, value: A): Protocol.Aux[OK] = + Protocol("PSETEX", key :: milliseconds :: value :: HNil).as[SimpleString, OK] - final def set[A: Show](key: Key, value: A): Protocol.Aux["OK"] = - Protocol("SET", key :: value :: HNil).as[SimpleString, "OK"] + final def set[A: Show](key: Key, value: A): Protocol.Aux[OK] = + Protocol("SET", key :: value :: HNil).as[SimpleString, OK] - final def set[A: Show](key: Key, value: A, expiry: Expiry): Protocol.Aux["OK"] = - Protocol("SET", key :: value :: expiry.unit :: expiry.value :: HNil).as[SimpleString, "OK"] + final def set[A: Show](key: Key, value: A, expiry: Expiry): Protocol.Aux[OK] = + Protocol("SET", key :: value :: expiry.unit :: expiry.value :: HNil).as[SimpleString, OK] - final def set[A: Show](key: Key, value: A, flag: Flag): Protocol.Aux[Option["OK"]] = - Protocol("SET", key :: value :: flag :: HNil).asC[NullBulkString :+: SimpleString :+: CNil, Option["OK"]] + final def set[A: Show](key: Key, value: A, flag: Flag): Protocol.Aux[Option[OK]] = + Protocol("SET", key :: value :: flag :: HNil).asC[NullBulkString :+: SimpleString :+: CNil, Option[OK]] - final def set[A: Show](key: Key, value: A, expiry: Expiry, flag: Flag): Protocol.Aux[Option["OK"]] = + final def set[A: Show](key: Key, value: A, expiry: Expiry, flag: Flag): Protocol.Aux[Option[OK]] = Protocol("SET", key :: value :: flag :: expiry.unit :: expiry.value :: HNil) - .asC[NullBulkString :+: SimpleString :+: CNil, Option["OK"]] + .asC[NullBulkString :+: SimpleString :+: CNil, Option[OK]] final def setbit(key: Key, offset: StringLength, bit: Bit): Protocol.Aux[Bit] = Protocol("SETBIT", key :: offset :: bit :: HNil).as[Integer, Bit] - final def setex[A: Show](key: Key, value: A, seconds: PosLong): Protocol.Aux["OK"] = - Protocol("SETEX", key :: seconds :: value :: HNil).as[SimpleString, "OK"] + final def setex[A: Show](key: Key, value: A, seconds: PosLong): Protocol.Aux[OK] = + Protocol("SETEX", key :: seconds :: value :: HNil).as[SimpleString, OK] final def setnx[A: Show](key: Key, value: A): Protocol.Aux[Boolean] = Protocol("SETNX", key :: value :: HNil).as[Integer, Boolean] diff --git a/fs2/src/test/scala/laserdisc/fs2/RedisClientSpec.scala b/fs2/src/test/scala/laserdisc/fs2/RedisClientSpec.scala index 77464793..a401934d 100644 --- a/fs2/src/test/scala/laserdisc/fs2/RedisClientSpec.scala +++ b/fs2/src/test/scala/laserdisc/fs2/RedisClientSpec.scala @@ -14,7 +14,6 @@ import cats.syntax.flatMap._ import cats.syntax.functor._ import cats.syntax.traverse._ import eu.timepit.refined.auto._ -import eu.timepit.refined.numeric._ import log.effect.fs2.Fs2LogWriter.noOpLogStream import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike} diff --git a/project/build.properties b/project/build.properties index 6d441921..7c58a83a 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.2.4 +sbt.version=1.2.6