From e770287b01dfeb6f7ef6c0e13b3aed32bdc41e8f Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Tue, 21 Feb 2017 16:08:47 +0100 Subject: [PATCH] deprecate CircuitBreakerProxy, #22198 --- akka-contrib/docs/circuitbreaker.rst | 9 +++++++-- .../contrib/circuitbreaker/CircuitBreakerProxy.scala | 2 ++ .../akka/contrib/circuitbreaker/askExtensions.scala | 5 +++++ akka-docs/rst/project/migration-guide-2.4.x-2.5.x.rst | 9 +++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/akka-contrib/docs/circuitbreaker.rst b/akka-contrib/docs/circuitbreaker.rst index d71935d965..1f1f93bdce 100644 --- a/akka-contrib/docs/circuitbreaker.rst +++ b/akka-contrib/docs/circuitbreaker.rst @@ -7,8 +7,12 @@ This is an alternative implementation of the :ref:`Akka Circuit Breaker Pattern The main difference is that it is intended to be used only for request-reply interactions with an actor using the Circuit-Breaker as a proxy of the target one in order to provide the same failfast functionalities and a protocol similar to the circuit-breaker implementation in Akka. +.. warning:: + **Deprecation warning** - ``CircuitBreakerProxy`` has been deprecated and is scheduled for removal + in the next major version. ``akka.pattern.CircuitBreaker`` with explicit ``ask`` requests can be used instead. -### Usage +Usage +----- Let's assume we have an actor wrapping a back-end service and able to respond to ``Request`` calls with a ``Response`` object containing an ``Either[String, String]`` to map successful and failed responses. The service is also potentially slowing down @@ -45,7 +49,8 @@ enabled by importing ``import akka.contrib.circuitbreaker.Implicits.futureExtens .. includecode:: @contribSrc@/src/test/scala/akka/contrib/circuitbreaker/sample/CircuitBreaker.scala#ask-with-failure-sample -#### Direct Communication With The Target Actor +Direct Communication With The Target Actor +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To send messages to the `target` actor without expecting any response you can wrap your message in a ``TellOnly`` or a ``Passthrough`` envelope. The difference between the two is that ``TellOnly`` will forward the message only when in closed mode and diff --git a/akka-contrib/src/main/scala/akka/contrib/circuitbreaker/CircuitBreakerProxy.scala b/akka-contrib/src/main/scala/akka/contrib/circuitbreaker/CircuitBreakerProxy.scala index 3eb1744dc3..da1ddbe4c7 100644 --- a/akka-contrib/src/main/scala/akka/contrib/circuitbreaker/CircuitBreakerProxy.scala +++ b/akka-contrib/src/main/scala/akka/contrib/circuitbreaker/CircuitBreakerProxy.scala @@ -15,6 +15,7 @@ import scala.util.{ Failure, Success } * This is an Actor which implements the circuit breaker pattern, * you may also be interested in the raw circuit breaker [[akka.pattern.CircuitBreaker]] */ +@deprecated("Use akka.pattern.CircuitBreaker + ask instead", "2.5.0") object CircuitBreakerProxy { /** @@ -100,6 +101,7 @@ object CircuitBreakerProxy { import akka.contrib.circuitbreaker.CircuitBreakerProxy._ +@deprecated("Use akka.pattern.CircuitBreaker + ask instead", "2.5.0") final class CircuitBreakerProxy( target: ActorRef, maxFailures: Int, diff --git a/akka-contrib/src/main/scala/akka/contrib/circuitbreaker/askExtensions.scala b/akka-contrib/src/main/scala/akka/contrib/circuitbreaker/askExtensions.scala index ac02d772d1..adb5ba83cf 100644 --- a/akka-contrib/src/main/scala/akka/contrib/circuitbreaker/askExtensions.scala +++ b/akka-contrib/src/main/scala/akka/contrib/circuitbreaker/askExtensions.scala @@ -10,6 +10,7 @@ import scala.language.implicitConversions import scala.concurrent.{ ExecutionContext, Future } +@deprecated("Use akka.pattern.CircuitBreaker + ask instead", "2.5.0") sealed class OpenCircuitException(message: String) extends RuntimeException(message) private[circuitbreaker] final object OpenCircuitException extends OpenCircuitException("Unable to complete operation since the Circuit Breaker Actor Proxy is in Open State") @@ -19,6 +20,7 @@ private[circuitbreaker] final object OpenCircuitException extends OpenCircuitExc * `Future` result of an `ask` pattern to fail in case of * [[akka.contrib.circuitbreaker.CircuitBreakerProxy.CircuitOpenFailure]] response */ +@deprecated("Use akka.pattern.CircuitBreaker + ask instead", "2.5.0") object Implicits { /** * Import this implicit to enable the methods `failForOpenCircuit` and `failForOpenCircuitWith` @@ -61,6 +63,7 @@ object Implicits { * [[akka.contrib.circuitbreaker.CircuitBreakerProxy.CircuitOpenFailure]] failure responses throwing * an exception built with the given exception builder */ +@deprecated("Use akka.pattern.CircuitBreaker + ask instead", "2.5.0") final class CircuitBreakerAwareFuture(val future: Future[Any]) extends AnyVal { @throws[OpenCircuitException] def failForOpenCircuit(implicit executionContext: ExecutionContext): Future[Any] = failForOpenCircuitWith(OpenCircuitException) @@ -75,6 +78,7 @@ final class CircuitBreakerAwareFuture(val future: Future[Any]) extends AnyVal { } } +@deprecated("Use akka.pattern.CircuitBreaker + ask instead", "2.5.0") final class AskeableWithCircuitBreakerActor(val actorRef: ActorRef) extends AnyVal { def askWithCircuitBreaker(message: Any)(implicit executionContext: ExecutionContext, timeout: Timeout, sender: ActorRef = Actor.noSender): Future[Any] = internalAskWithCircuitBreaker(message, timeout, sender) @@ -88,6 +92,7 @@ final class AskeableWithCircuitBreakerActor(val actorRef: ActorRef) extends AnyV } } +@deprecated("Use akka.pattern.CircuitBreaker + ask instead", "2.5.0") final class AskeableWithCircuitBreakerActorSelection(val actorSelection: ActorSelection) extends AnyVal { def askWithCircuitBreaker(message: Any)(implicit executionContext: ExecutionContext, timeout: Timeout, sender: ActorRef = Actor.noSender): Future[Any] = internalAskWithCircuitBreaker(message, timeout, sender) diff --git a/akka-docs/rst/project/migration-guide-2.4.x-2.5.x.rst b/akka-docs/rst/project/migration-guide-2.4.x-2.5.x.rst index 94be8aa263..988ee95102 100644 --- a/akka-docs/rst/project/migration-guide-2.4.x-2.5.x.rst +++ b/akka-docs/rst/project/migration-guide-2.4.x-2.5.x.rst @@ -561,6 +561,15 @@ We also anticipate to replace the uses of Agents by the upcoming Akka Typed, so If you use Agents and would like to take over the maintanance thereof, please contact the team on gitter or github. + +Contrib +======= + +CircuitBreakerProxy +------------------- + +:ref:`circuit-breaker-proxy` is deprecated in favor of ``akka.pattern.CircuitBreaker`` with explicit ``ask`` requests. + Akka Typed ==========