Skip to content

Commit

Permalink
refactor: Scribe instance to be created for each class
Browse files Browse the repository at this point in the history
  • Loading branch information
jachro committed Jan 30, 2024
1 parent a1c8167 commit 846cdeb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import cats.effect.{Async, Resource}
import fs2.Stream
import io.renku.redis.client.{RedisQueueClient, RedisUrl}
import scodec.bits.ByteVector
import scribe.Scribe

trait QueueClient[F[_]] {

Expand All @@ -44,5 +43,5 @@ trait QueueClient[F[_]] {
}

object QueueClient:
def apply[F[_]: Async: Scribe](redisUrl: RedisUrl): Resource[F, QueueClient[F]] =
def apply[F[_]: Async](redisUrl: RedisUrl): Resource[F, QueueClient[F]] =
RedisQueueClient[F](redisUrl)
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ import scodec.bits.ByteVector
import scribe.Scribe

object RedisQueueClient:
def apply[F[_]: Async: Scribe](redisUrl: RedisUrl): Resource[F, QueueClient[F]] =
def apply[F[_]: Async](redisUrl: RedisUrl): Resource[F, QueueClient[F]] =
given Scribe[F] = scribe.cats[F]
given Log[F] = RedisLogger[F]
RedisClient[F].from(redisUrl.toString).map(new RedisQueueClient[F](_))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ trait SearchProvisioner[F[_]]:
def provisionSolr: F[Unit]

object SearchProvisioner:
def apply[F[_]: Async: Network: Scribe](
def apply[F[_]: Async: Network](
queueName: QueueName,
redisUrl: RedisUrl,
solrConfig: SolrConfig
Expand All @@ -45,12 +45,14 @@ object SearchProvisioner:
.flatMap(qc => SearchSolrClient[F](solrConfig).tupleLeft(qc))
.map { case (qc, sc) => new SearchProvisionerImpl[F](queueName, qc, sc) }

private class SearchProvisionerImpl[F[_]: Async: Scribe](
private class SearchProvisionerImpl[F[_]: Async](
queueName: QueueName,
queueClient: QueueClient[F],
solrClient: SearchSolrClient[F]
) extends SearchProvisioner[F]:

private given Scribe[F] = scribe.cats[F]

override def provisionSolr: F[Unit] =
queueClient
.acquireEventsStream(queueName, chunkSize = 1, maybeOffset = None)
Expand Down

0 comments on commit 846cdeb

Please sign in to comment.