Skip to content

Commit

Permalink
Add scmInfo to build, formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
kubukoz committed Jan 24, 2020
1 parent 3beaae4 commit 9de2427
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 48 deletions.
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ val commonSettings = Seq(
f = Seq.empty
),
scalafmtOnCompile := true,
scmInfo := Some(ScmInfo(url("https://github.com/profunktor/redis4cats"), "scm:git:[email protected]:profunktor/redis4cats.git")),
publishTo := {
val sonatype = "https://oss.sonatype.org/"
if (isSnapshot.value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@

package dev.profunktor.redis4cats

import scala.collection.convert.{DecorateAsJava, DecorateAsScala}
import scala.collection.convert.{ DecorateAsJava, DecorateAsScala }

object JavaConversions extends DecorateAsJava with DecorateAsScala
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@

package dev.profunktor.redis4cats

import scala.collection.convert.{AsJavaExtensions, AsScalaExtensions}
import scala.collection.convert.{ AsJavaExtensions, AsScalaExtensions }

object JavaConversions extends AsJavaExtensions with AsScalaExtensions
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ object RedisClient {

val release: RedisClient => F[Unit] = client =>
F.info(s"Releasing Redis connection: $uri") *>
JRFuture.fromCompletableFuture(F.delay(client.underlying.shutdownAsync())).void
JRFuture.fromCompletableFuture(F.delay(client.underlying.shutdownAsync())).void

(acquire, release)
}

private[redis4cats] def acquireAndReleaseWithoutUri[F[_]: Concurrent: ContextShift: Log]
: F[(F[RedisClient], RedisClient => F[Unit])] =
: F[(F[RedisClient], RedisClient => F[Unit])] =
F.delay(RedisURI.fromUnderlying(new JRedisURI())).map(acquireAndRelease(_))

def apply[F[_]: Concurrent: ContextShift: Log](uri: => RedisURI): Resource[F, RedisClient] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ object RedisClusterClient {

val acquire: F[RedisClusterClient] =
F.info(s"Acquire Redis Cluster client") *>
F.delay(JClusterClient.create(uri.map(_.underlying).asJava))
.flatTap(initializeClusterPartitions[F])
.map(new RedisClusterClient(_) {})
F.delay(JClusterClient.create(uri.map(_.underlying).asJava))
.flatTap(initializeClusterPartitions[F])
.map(new RedisClusterClient(_) {})

val release: RedisClusterClient => F[Unit] = client =>
F.info(s"Releasing Redis Cluster client: ${client.underlying}") *>
JRFuture.fromCompletableFuture(F.delay(client.underlying.shutdownAsync())).void
JRFuture.fromCompletableFuture(F.delay(client.underlying.shutdownAsync())).void

(acquire, release)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ object RedisMasterReplica {

val release: RedisMasterReplica[K, V] => F[Unit] = connection =>
F.info(s"Releasing Redis Master/Replica connection: ${connection.underlying}") *>
JRFuture.fromCompletableFuture(F.delay(connection.underlying.closeAsync())).void
JRFuture.fromCompletableFuture(F.delay(connection.underlying.closeAsync())).void

(acquire, release)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,21 @@ trait SortedSetGetter[F[_], K, V] {
def zRange(key: K, start: Long, stop: Long): F[List[V]]
def zRangeByLex(key: K, range: ZRange[V], limit: Option[RangeLimit]): F[List[V]]
def zRangeByScore[T: Numeric](key: K, range: ZRange[T], limit: Option[RangeLimit]): F[List[V]]
def zRangeByScoreWithScores[T: Numeric](key: K,
range: ZRange[T],
limit: Option[RangeLimit]): F[List[ScoreWithValue[V]]]
def zRangeByScoreWithScores[T: Numeric](
key: K,
range: ZRange[T],
limit: Option[RangeLimit]
): F[List[ScoreWithValue[V]]]
def zRangeWithScores(key: K, start: Long, stop: Long): F[List[ScoreWithValue[V]]]
def zRank(key: K, value: V): F[Option[Long]]
def zRevRange(key: K, start: Long, stop: Long): F[List[V]]
def zRevRangeByLex(key: K, range: ZRange[V], limit: Option[RangeLimit]): F[List[V]]
def zRevRangeByScore[T: Numeric](key: K, range: ZRange[T], limit: Option[RangeLimit]): F[List[V]]
def zRevRangeByScoreWithScores[T: Numeric](key: K,
range: ZRange[T],
limit: Option[RangeLimit]): F[List[ScoreWithValue[V]]]
def zRevRangeByScoreWithScores[T: Numeric](
key: K,
range: ZRange[T],
limit: Option[RangeLimit]
): F[List[ScoreWithValue[V]]]
def zRevRangeWithScores(key: K, start: Long, stop: Long): F[List[ScoreWithValue[V]]]
def zRevRank(key: K, value: V): F[Option[Long]]
def zScore(key: K, value: V): F[Option[Double]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -640,15 +640,14 @@ private[redis4cats] class BaseRedis[F[_]: Concurrent: ContextShift, K, V](

override def geoRadius(key: K, geoRadius: GeoRadius, unit: GeoArgs.Unit): F[Set[V]] =
JRFuture {
async.flatMap(
c => F.delay(c.georadius(key, geoRadius.lon.value, geoRadius.lat.value, geoRadius.dist.value, unit))
async.flatMap(c => F.delay(c.georadius(key, geoRadius.lon.value, geoRadius.lat.value, geoRadius.dist.value, unit))
)
}.map(_.asScala.toSet)

override def geoRadius(key: K, geoRadius: GeoRadius, unit: GeoArgs.Unit, args: GeoArgs): F[List[GeoRadiusResult[V]]] =
JRFuture {
async.flatMap(
c => F.delay(c.georadius(key, geoRadius.lon.value, geoRadius.lat.value, geoRadius.dist.value, unit, args))
async.flatMap(c =>
F.delay(c.georadius(key, geoRadius.lon.value, geoRadius.lat.value, geoRadius.dist.value, unit, args))
)
}.map(_.asScala.toList.map(_.asGeoRadiusResult))

Expand Down Expand Up @@ -814,8 +813,8 @@ private[redis4cats] class BaseRedis[F[_]: Concurrent: ContextShift, K, V](
JRFuture {
limit match {
case Some(x) =>
async.flatMap(
c => F.delay(c.zrangebylex(key, JRange.create[V](range.start, range.end), JLimit.create(x.offset, x.count)))
async.flatMap(c =>
F.delay(c.zrangebylex(key, JRange.create[V](range.start, range.end), JLimit.create(x.offset, x.count)))
)
case None => async.flatMap(c => F.delay(c.zrangebylex(key, JRange.create[V](range.start, range.end))))
}
Expand All @@ -838,8 +837,8 @@ private[redis4cats] class BaseRedis[F[_]: Concurrent: ContextShift, K, V](
JRFuture {
limit match {
case Some(x) =>
async.flatMap(
c => F.delay(c.zrangebyscoreWithScores(key, range.asJavaRange, JLimit.create(x.offset, x.count)))
async.flatMap(c =>
F.delay(c.zrangebyscoreWithScores(key, range.asJavaRange, JLimit.create(x.offset, x.count)))
)
case None => async.flatMap(c => F.delay(c.zrangebyscoreWithScores(key, range.asJavaRange)))
}
Expand All @@ -864,9 +863,8 @@ private[redis4cats] class BaseRedis[F[_]: Concurrent: ContextShift, K, V](
JRFuture {
limit match {
case Some(x) =>
async.flatMap(
c =>
F.delay(c.zrevrangebylex(key, JRange.create[V](range.start, range.end), JLimit.create(x.offset, x.count)))
async.flatMap(c =>
F.delay(c.zrevrangebylex(key, JRange.create[V](range.start, range.end), JLimit.create(x.offset, x.count)))
)
case None => async.flatMap(c => F.delay(c.zrevrangebylex(key, JRange.create[V](range.start, range.end))))
}
Expand All @@ -889,8 +887,8 @@ private[redis4cats] class BaseRedis[F[_]: Concurrent: ContextShift, K, V](
JRFuture {
limit match {
case Some(x) =>
async.flatMap(
c => F.delay(c.zrangebyscoreWithScores(key, range.asJavaRange, JLimit.create(x.offset, x.count)))
async.flatMap(c =>
F.delay(c.zrangebyscoreWithScores(key, range.asJavaRange, JLimit.create(x.offset, x.count)))
)
case None => async.flatMap(c => F.delay(c.zrangebyscoreWithScores(key, range.asJavaRange)))
}
Expand Down Expand Up @@ -936,15 +934,14 @@ private[redis4cats] class BaseRedis[F[_]: Concurrent: ContextShift, K, V](
override def info: F[Map[String, String]] =
JRFuture {
async.flatMap(c => F.delay(c.info))
}.flatMap(
info =>
F.delay(
info
.split("\\r?\\n")
.toList
.map(_.split(":", 2).toList)
.collect { case k :: v :: Nil => (k, v) }
.toMap
}.flatMap(info =>
F.delay(
info
.split("\\r?\\n")
.toList
.map(_.split(":", 2).toList)
.collect { case k :: v :: Nil => (k, v) }
.toMap
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ object pipeline {
) {
def run[A](fa: F[A]): F[A] =
F.info("Pipeline started") *>
cmd.disableAutoFlush
.bracketCase(_ => fa) {
case (_, ExitCase.Completed) => cmd.flushCommands *> F.info("Pipeline completed")
case (_, ExitCase.Error(e)) => F.error(s"Pipeline failed: ${e.getMessage}")
case (_, ExitCase.Canceled) => F.error("Pipeline canceled")
}
.guarantee(cmd.enableAutoFlush)
cmd.disableAutoFlush
.bracketCase(_ => fa) {
case (_, ExitCase.Completed) => cmd.flushCommands *> F.info("Pipeline completed")
case (_, ExitCase.Error(e)) => F.error(s"Pipeline failed: ${e.getMessage}")
case (_, ExitCase.Canceled) => F.error("Pipeline canceled")
}
.guarantee(cmd.enableAutoFlush)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object PubSub {

private[redis4cats] def acquireAndRelease[F[_]: ConcurrentEffect: ContextShift: Log, K, V](
client: RedisClient,
codec: RedisCodec[K, V],
codec: RedisCodec[K, V]
): (F[StatefulRedisPubSubConnection[K, V]], StatefulRedisPubSubConnection[K, V] => F[Unit]) = {

val acquire: F[StatefulRedisPubSubConnection[K, V]] = JRFuture.fromConnectionFuture {
Expand All @@ -40,7 +40,7 @@ object PubSub {

val release: StatefulRedisPubSubConnection[K, V] => F[Unit] = c =>
JRFuture.fromCompletableFuture(F.delay(c.closeAsync())) *>
F.info(s"Releasing PubSub connection: ${client.uri.underlying}")
F.info(s"Releasing PubSub connection: ${client.uri.underlying}")

(acquire, release)
}
Expand Down Expand Up @@ -72,7 +72,7 @@ object PubSub {
* */
def mkPublisherConnection[F[_]: ConcurrentEffect: ContextShift: Log, K, V](
client: RedisClient,
codec: RedisCodec[K, V],
codec: RedisCodec[K, V]
): Stream[F, PublishCommands[Stream[F, *], K, V]] = {
val (acquire, release) = acquireAndRelease[F, K, V](client, codec)
Stream.bracket(acquire)(release).map(c => new Publisher[F, K, V](c))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ object RedisStream {

val release: RedisRawStreaming[F, K, V] => F[Unit] = c =>
JRFuture.fromCompletableFuture(F.delay(c.client.closeAsync())) *>
F.info(s"Releasing Streaming connection: ${client.uri.underlying}")
F.info(s"Releasing Streaming connection: ${client.uri.underlying}")

Stream.bracket(acquire)(release).map(rs => new RedisStream(rs))
}
Expand Down

0 comments on commit 9de2427

Please sign in to comment.