Skip to content

Commit

Permalink
feat: RedisLogger for redis-client
Browse files Browse the repository at this point in the history
  • Loading branch information
jachro committed Jan 22, 2024
1 parent 1c1da91 commit 01bc694
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
6 changes: 4 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,12 @@ lazy val commonSettings = Seq(
),
Compile / console / scalacOptions := (Compile / scalacOptions).value.filterNot(_ == "-Xfatal-warnings"),
Test / console / scalacOptions := (Compile / console / scalacOptions).value,
libraryDependencies ++= (
Dependencies.scribe
),
libraryDependencies ++= (
Dependencies.catsEffectMunit ++
Dependencies.scalacheckEffectMunit ++
Dependencies.scribe
Dependencies.scalacheckEffectMunit
).map(_ % Test),
// Format: on
organizationName := "Swiss Data Science Center (SDSC)",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2024 Swiss Data Science Center (SDSC)
* A partnership between École Polytechnique Fédérale de Lausanne (EPFL) and
* Eidgenössische Technische Hochschule Zürich (ETHZ).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.renku.redis.client

import dev.profunktor.redis4cats.effect.Log
import scribe.Scribe

class RedisLogger[F[_]](scribe: Scribe[F]) extends Log[F]:

override def debug(msg: => String): F[Unit] =
scribe.debug(msg)

override def info(msg: => String): F[Unit] =
scribe.info(msg)

override def error(msg: => String): F[Unit] =
scribe.error(msg)

object RedisLogger:
def apply[F[_]: Scribe]: Log[F] = new RedisLogger[F](Scribe[F])
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,19 @@ import cats.syntax.all.*
import dev.profunktor.redis4cats.connection.RedisClient
import dev.profunktor.redis4cats.data.RedisCodec
import dev.profunktor.redis4cats.effect.Log
import dev.profunktor.redis4cats.effect.MkRedis.forAsync
import dev.profunktor.redis4cats.streams.RedisStream
import dev.profunktor.redis4cats.streams.data.{StreamingOffset, XAddMessage, XReadMessage}
import dev.profunktor.redis4cats.{Redis, RedisCommands}
import fs2.Stream
import io.renku.queue.client.*
import scodec.bits.ByteVector
import scribe.Scribe

object RedisQueueClient:
def apply[F[_]: Async: Scribe]: Resource[F, QueueClient[F]] =
given Log[F] = RedisLogger[F]
RedisClient[F].from("url").map(new RedisQueueClient[F](_))

class RedisQueueClient[F[_]: Async: Log](client: RedisClient) extends QueueClient[F] {

Expand Down

0 comments on commit 01bc694

Please sign in to comment.