Skip to content

Commit

Permalink
relax capability constraints on ConsulUriResolver and ConsulMiddleware
Browse files Browse the repository at this point in the history
  • Loading branch information
bpholt committed Jul 24, 2024
1 parent 6bf5db9 commit 47b87bb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.dwolla.consul

import cats.effect.syntax.all._
import cats.effect.{Trace => _, _}
import cats.effect.implicits.effectResourceOps
import cats.syntax.all._
import cats.~>
import natchez.Trace
Expand All @@ -23,7 +23,8 @@ trait ConsulUriResolver[F[_]] { self =>

object ConsulUriResolver {
private final val name = "com.dwolla.consul.ConsulUriResolver"
def apply[F[_] : Async : LoggerFactory : Trace](backgroundResolver: ConsulServiceDiscoveryAlg[F]): Resource[F, ConsulUriResolver[F]] =

def apply[F[_] : Temporal : LoggerFactory : Trace](backgroundResolver: ConsulServiceDiscoveryAlg[F]): Resource[F, ConsulUriResolver[F]] =
LoggerFactory[F]
.create(LoggerName(name))
.toResource
Expand All @@ -33,7 +34,7 @@ object ConsulUriResolver {
.map(ConsulUriResolver(_))
}

private[consul] def apply[F[_] : Async : Logger : Trace](backgroundResolver: KeyPool[F, ServiceName, F[Uri.Authority]]): ConsulUriResolver[F] =
private[consul] def apply[F[_] : MonadCancelThrow : Logger : Trace](backgroundResolver: KeyPool[F, ServiceName, F[Uri.Authority]]): ConsulUriResolver[F] =
new ConsulUriResolver[F] {
override def resolve(uri: Uri): F[Uri] = uri match {
case Uri(Some(scheme), Some(Uri.Authority(_, service, _)), _, _, _) if scheme == scheme"consul" =>
Expand Down Expand Up @@ -64,4 +65,11 @@ object ConsulUriResolver {
L: LoggerFactory[F]): Resource[F, ConsulUriResolver[F]] =
apply(backgroundResolver)(F, L, NoopTrace()(F))

@deprecated("maintained for binary compatibility: this version requires a higher capability constraint than is actually required", "0.3.2")
def apply[F[_]](backgroundResolver: ConsulServiceDiscoveryAlg[F],
F: Async[F],
L: LoggerFactory[F],
T: Trace[F]): Resource[F, ConsulUriResolver[F]] =
apply(backgroundResolver)(F, L, T)

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ object ConsulMiddleware {
* @param consulServiceDiscoveryAlg: the [[ConsulServiceDiscoveryAlg]] used to construct the background processes
* @param client the `org.http4s.client.Client[F]` being wrapped, which will be used to make the eventual service requests
*/
def apply[F[_] : Async : LoggerFactory : Trace](consulServiceDiscoveryAlg: ConsulServiceDiscoveryAlg[F])
(client: Client[F]): Resource[F, Client[F]] =
def apply[F[_] : Temporal : LoggerFactory : Trace](consulServiceDiscoveryAlg: ConsulServiceDiscoveryAlg[F])
(client: Client[F]): Resource[F, Client[F]] =
LoggerFactory[F]
.create(LoggerName("com.dwolla.consul.http4s.ConsulMiddleware"))
.toResource
Expand All @@ -48,4 +48,12 @@ object ConsulMiddleware {
F: Async[F],
L: LoggerFactory[F]): Resource[F, Client[F]] =
apply(consulServiceDiscoveryAlg)(client)(F, L, NoopTrace()(F))

@deprecated("maintained for binary compatibility: this version requires a higher capability constraint than is actually required", "0.3.2")
def apply[F[_]](consulServiceDiscoveryAlg: ConsulServiceDiscoveryAlg[F],
client: Client[F],
F: Async[F],
L: LoggerFactory[F],
T: Trace[F]): Resource[F, Client[F]] =
apply(consulServiceDiscoveryAlg)(client)(F, L, T)
}

0 comments on commit 47b87bb

Please sign in to comment.