diff --git a/core/src/main/scala/dev/profunktor/fs2rabbit/algebra/Connection.scala b/core/src/main/scala/dev/profunktor/fs2rabbit/algebra/Connection.scala index 2bcaf81a..13721a62 100644 --- a/core/src/main/scala/dev/profunktor/fs2rabbit/algebra/Connection.scala +++ b/core/src/main/scala/dev/profunktor/fs2rabbit/algebra/Connection.scala @@ -33,6 +33,7 @@ import dev.profunktor.fs2rabbit.model.AMQPConnection import dev.profunktor.fs2rabbit.model.RabbitChannel import dev.profunktor.fs2rabbit.model.RabbitConnection +import java.util import java.util.Collections import java.util.concurrent.AbstractExecutorService import java.util.concurrent.ExecutorService @@ -46,47 +47,6 @@ import java.util.concurrent.Executors object ConnectionResource { type ConnectionResource[F[_]] = Connection[Resource[F, *]] - @deprecated(message = "Use `make` with explicit ExecutionContext", since = "5.0.0") - def make[F[_]: Sync: Log]( - conf: Fs2RabbitConfig, - sslCtx: Option[SSLContext] = None, - // Unlike SSLContext, SaslConfig is not optional because it is always set - // by the underlying Java library, even if the user doesn't set it. - saslConf: SaslConfig = DefaultSaslConfig.PLAIN, - metricsCollector: Option[MetricsCollector] = None, - threadFactory: Option[F[ThreadFactory]] = None - ): F[Connection[Resource[F, *]]] = { - val addThreadFactory: F[ConnectionFactory => Unit] = - threadFactory.fold(Sync[F].pure((_: ConnectionFactory) => ())) { threadFact => - threadFact.map { tf => (cf: ConnectionFactory) => - cf.setThreadFactory(tf) - } - } - - val numOfThreads = Runtime.getRuntime().availableProcessors() * 2 - val esF: F[ExecutorService] = threadFactory - .fold(Executors.newFixedThreadPool(numOfThreads).pure[F]) { - _.map(Executors.newFixedThreadPool(numOfThreads, _)) - } - .map { es => - val _ = sys.addShutdownHook(es.shutdown()) - es - } - - for { - es <- esF - fn <- addThreadFactory - conn <- _make( - conf, - Some(ExecutionContext.fromExecutorService(es)), - sslCtx, - saslConf, - metricsCollector, - fn - ) - } yield conn - } - def make[F[_]: Sync: Log]( conf: Fs2RabbitConfig, executionContext: ExecutionContext, @@ -185,10 +145,10 @@ object ConnectionResource { case es: ExecutorService => es case _ => new AbstractExecutorService { - override def isShutdown = false - override def isTerminated = false - override def shutdown() = () - override def shutdownNow() = Collections.emptyList[Runnable] + override def isShutdown: Boolean = false + override def isTerminated: Boolean = false + override def shutdown(): Unit = () + override def shutdownNow(): util.List[Runnable] = Collections.emptyList[Runnable] override def execute(runnable: Runnable): Unit = ec execute runnable override def awaitTermination(length: Long, unit: TimeUnit): Boolean = false } diff --git a/core/src/main/scala/dev/profunktor/fs2rabbit/interpreter/RabbitClient.scala b/core/src/main/scala/dev/profunktor/fs2rabbit/interpreter/RabbitClient.scala index db8dd989..ffeb466b 100644 --- a/core/src/main/scala/dev/profunktor/fs2rabbit/interpreter/RabbitClient.scala +++ b/core/src/main/scala/dev/profunktor/fs2rabbit/interpreter/RabbitClient.scala @@ -40,49 +40,6 @@ import javax.net.ssl.SSLContext import scala.concurrent.ExecutionContext object RabbitClient { - @deprecated(message = "Use `default` to create Builder instead", since = "5.0.0") - def apply[F[_]: Async]( - config: Fs2RabbitConfig, - dispatcher: Dispatcher[F], - sslContext: Option[SSLContext] = None, - // Unlike SSLContext, SaslConfig is not optional because it is always set - // by the underlying Java library, even if the user doesn't set it. - saslConfig: SaslConfig = DefaultSaslConfig.PLAIN, - metricsCollector: Option[MetricsCollector] = None, - threadFactory: Option[F[ThreadFactory]] = None - ): F[RabbitClient[F]] = { - val internalQ = new LiveInternalQueue[F](config.internalQueueSize.getOrElse(500)) - val connection = ConnectionResource.make(config, sslContext, saslConfig, metricsCollector, threadFactory) - val consumingProgram = AckConsumingProgram.make[F](config, internalQ, dispatcher) - val publishingProgram = PublishingProgram.make[F](dispatcher) - val bindingClient = Binding.make[F] - val declarationClient = Declaration.make[F] - val deletionClient = Deletion.make[F] - - connection.map { conn => - new RabbitClient[F]( - conn, - bindingClient, - declarationClient, - deletionClient, - consumingProgram, - publishingProgram - ) - } - } - - @deprecated(message = "Use `default` to create Builder instead", since = "5.0.0") - def resource[F[_]: Async]( - config: Fs2RabbitConfig, - sslContext: Option[SSLContext] = None, - // Unlike SSLContext, SaslConfig is not optional because it is always set - // by the underlying Java library, even if the user doesn't set it. - saslConfig: SaslConfig = DefaultSaslConfig.PLAIN, - metricsCollector: Option[MetricsCollector] = None, - threadFactory: Option[F[ThreadFactory]] = None - ): Resource[F, RabbitClient[F]] = Dispatcher.parallel[F](await = false).evalMap { dispatcher => - apply[F](config, dispatcher, sslContext, saslConfig, metricsCollector, threadFactory) - } sealed abstract class Builder[F[_]: Async] private[RabbitClient] ( config: Fs2RabbitConfig,