fix warnings in contrib, docs, osgi, persistence and slf4j
This commit is contained in:
parent
82b8238a9c
commit
a029a90502
17 changed files with 116 additions and 89 deletions
|
|
@ -92,7 +92,7 @@ class ActorWithMessagesWrapper {
|
|||
import MyActor._
|
||||
def receive = {
|
||||
case Greeting(greeter) => log.info(s"I was greeted by $greeter.")
|
||||
case Goodbye => log.info("Someone said goodbye to me.")
|
||||
case Goodbye => log.info("Someone said goodbye to me.")
|
||||
}
|
||||
}
|
||||
//#messages-in-companion
|
||||
|
|
@ -229,7 +229,7 @@ class Consumer extends Actor with ActorLogging with ConsumerBehavior {
|
|||
class ProducerConsumer extends Actor with ActorLogging
|
||||
with ProducerBehavior with ConsumerBehavior {
|
||||
|
||||
def receive = producerBehavior orElse consumerBehavior
|
||||
def receive = producerBehavior.orElse[Any, Unit](consumerBehavior)
|
||||
}
|
||||
|
||||
// protocol
|
||||
|
|
|
|||
|
|
@ -12,13 +12,10 @@ import akka.util.ByteString
|
|||
import akka.actor.Props
|
||||
import scala.collection.immutable
|
||||
|
||||
class FSMDocSpec extends MyFavoriteTestFrameWorkPlusAkkaTestKit {
|
||||
|
||||
//#fsm-code-elided
|
||||
//#simple-imports
|
||||
import akka.actor.{ ActorRef, FSM }
|
||||
import scala.concurrent.duration._
|
||||
//#simple-imports
|
||||
object FSMDocSpec {
|
||||
// messages and data types
|
||||
//#test-code
|
||||
import akka.actor.ActorRef
|
||||
//#simple-events
|
||||
// received events
|
||||
final case class SetTarget(ref: ActorRef)
|
||||
|
|
@ -38,6 +35,17 @@ class FSMDocSpec extends MyFavoriteTestFrameWorkPlusAkkaTestKit {
|
|||
case object Uninitialized extends Data
|
||||
final case class Todo(target: ActorRef, queue: immutable.Seq[Any]) extends Data
|
||||
//#simple-state
|
||||
//#test-code
|
||||
}
|
||||
|
||||
class FSMDocSpec extends MyFavoriteTestFrameWorkPlusAkkaTestKit {
|
||||
import FSMDocSpec._
|
||||
|
||||
//#fsm-code-elided
|
||||
//#simple-imports
|
||||
import akka.actor.{ ActorRef, FSM }
|
||||
import scala.concurrent.duration._
|
||||
//#simple-imports
|
||||
//#simple-fsm
|
||||
class Buncher extends FSM[State, Data] {
|
||||
|
||||
|
|
@ -56,6 +64,7 @@ class FSMDocSpec extends MyFavoriteTestFrameWorkPlusAkkaTestKit {
|
|||
case Active -> Idle =>
|
||||
stateData match {
|
||||
case Todo(ref, queue) => ref ! Batch(queue)
|
||||
case _ => // nothing to do
|
||||
}
|
||||
}
|
||||
//#transition-elided
|
||||
|
|
|
|||
|
|
@ -113,7 +113,8 @@ class Worker extends Actor with ActorLogging {
|
|||
//#messages
|
||||
object CounterService {
|
||||
final case class Increment(n: Int)
|
||||
case object GetCurrentCount
|
||||
sealed abstract class GetCurrentCount
|
||||
case object GetCurrentCount extends GetCurrentCount
|
||||
final case class CurrentCount(key: String, count: Long)
|
||||
class ServiceUnavailable(msg: String) extends RuntimeException(msg)
|
||||
|
||||
|
|
@ -176,9 +177,9 @@ class CounterService extends Actor {
|
|||
for ((replyTo, msg) <- backlog) c.tell(msg, sender = replyTo)
|
||||
backlog = IndexedSeq.empty
|
||||
|
||||
case msg @ Increment(n) => forwardOrPlaceInBacklog(msg)
|
||||
case msg: Increment => forwardOrPlaceInBacklog(msg)
|
||||
|
||||
case msg @ GetCurrentCount => forwardOrPlaceInBacklog(msg)
|
||||
case msg: GetCurrentCount => forwardOrPlaceInBacklog(msg)
|
||||
|
||||
case Terminated(actorRef) if Some(actorRef) == storage =>
|
||||
// After 3 restarts the storage child is stopped.
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ class FaultHandlingDocSpec extends TestKit(ActorSystem("FaultHandlingDocSpec", t
|
|||
}
|
||||
|
||||
"A supervisor" must "apply the chosen strategy for its child" in {
|
||||
//#testkit
|
||||
//#testkit
|
||||
|
||||
//#create
|
||||
val supervisor = system.actorOf(Props[Supervisor], "supervisor")
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ class TypedActorDocSpec extends AkkaSpec(Map("akka.loglevel" -> "INFO")) {
|
|||
//#typed-actor-call-strict
|
||||
//#typed-actor-calls
|
||||
|
||||
Await.result(fSquare, 3 seconds) should be(100)
|
||||
Await.result(fSquare, 3.seconds) should be(100)
|
||||
|
||||
oSquare should be(Some(100))
|
||||
|
||||
|
|
@ -193,7 +193,7 @@ class TypedActorDocSpec extends AkkaSpec(Map("akka.loglevel" -> "INFO")) {
|
|||
|
||||
TypedActor(system).poisonPill(awesomeFooBar)
|
||||
//#typed-actor-supercharge-usage
|
||||
Await.result(f, 3 seconds) should be("YES")
|
||||
Await.result(f, 3.seconds) should be("YES")
|
||||
}
|
||||
|
||||
"typed router pattern" in {
|
||||
|
|
|
|||
|
|
@ -70,18 +70,19 @@ class EchoManager(handlerClass: Class[_]) extends Actor with ActorLogging {
|
|||
|
||||
}
|
||||
|
||||
//#echo-handler
|
||||
object EchoHandler {
|
||||
final case class Ack(offset: Int) extends Tcp.Event
|
||||
|
||||
def props(connection: ActorRef, remote: InetSocketAddress): Props =
|
||||
Props(classOf[EchoHandler], connection, remote)
|
||||
}
|
||||
|
||||
//#echo-handler
|
||||
class EchoHandler(connection: ActorRef, remote: InetSocketAddress)
|
||||
extends Actor with ActorLogging {
|
||||
|
||||
import Tcp._
|
||||
|
||||
final case class Ack(offset: Int) extends Event
|
||||
import EchoHandler._
|
||||
|
||||
// sign death pact: this actor terminates when connection breaks
|
||||
context watch connection
|
||||
|
|
|
|||
|
|
@ -87,8 +87,9 @@ object ScalaUdpDocSpec {
|
|||
//#connected
|
||||
case msg: String =>
|
||||
connection ! UdpConnected.Send(ByteString(msg))
|
||||
case d @ UdpConnected.Disconnect => connection ! d
|
||||
case UdpConnected.Disconnected => context.stop(self)
|
||||
case UdpConnected.Disconnect =>
|
||||
connection ! UdpConnected.Disconnect
|
||||
case UdpConnected.Disconnected => context.stop(self)
|
||||
}
|
||||
}
|
||||
//#connected
|
||||
|
|
|
|||
|
|
@ -4,13 +4,19 @@
|
|||
|
||||
package docs.persistence
|
||||
|
||||
import akka.actor.{ Actor, ActorSystem, Props }
|
||||
import akka.actor.{ Actor, ActorRef, ActorSystem, Props }
|
||||
import akka.persistence._
|
||||
import com.typesafe.config.ConfigFactory
|
||||
|
||||
import scala.concurrent.duration._
|
||||
import scala.language.postfixOps
|
||||
trait PersistenceDocSpec {
|
||||
|
||||
object PersistenceDocSpec {
|
||||
|
||||
trait SomeOtherMessage
|
||||
|
||||
val persistentActor: ActorRef = ???
|
||||
|
||||
val config =
|
||||
"""
|
||||
//#auto-update-interval
|
||||
|
|
@ -21,13 +27,7 @@ trait PersistenceDocSpec {
|
|||
//#auto-update
|
||||
"""
|
||||
|
||||
trait SomeOtherMessage
|
||||
|
||||
implicit val system: ActorSystem
|
||||
|
||||
import system._
|
||||
|
||||
new AnyRef {
|
||||
object Recovery {
|
||||
trait MyPersistentActor1 extends PersistentActor {
|
||||
//#recover-on-start-disabled
|
||||
override def preStart() = ()
|
||||
|
|
@ -45,7 +45,6 @@ trait PersistenceDocSpec {
|
|||
//#recover-on-start-custom
|
||||
}
|
||||
|
||||
val persistentActor = system.deadLetters
|
||||
//#recover-explicit
|
||||
persistentActor ! Recover()
|
||||
//#recover-explicit
|
||||
|
|
@ -69,7 +68,7 @@ trait PersistenceDocSpec {
|
|||
}
|
||||
}
|
||||
|
||||
new AnyRef {
|
||||
object NoRecovery {
|
||||
trait MyPersistentActor1 extends PersistentActor {
|
||||
//#recover-fully-disabled
|
||||
override def preStart() = self ! Recover(toSequenceNr = 0L)
|
||||
|
|
@ -77,7 +76,7 @@ trait PersistenceDocSpec {
|
|||
}
|
||||
}
|
||||
|
||||
new AnyRef {
|
||||
object PersistenceId {
|
||||
trait PersistentActorMethods {
|
||||
//#persistence-id
|
||||
def persistenceId: String
|
||||
|
|
@ -101,7 +100,7 @@ trait PersistenceDocSpec {
|
|||
}
|
||||
}
|
||||
|
||||
new AnyRef {
|
||||
object AtLeastOnce {
|
||||
//#at-least-once-example
|
||||
import akka.actor.{ Actor, ActorPath }
|
||||
import akka.persistence.AtLeastOnceDelivery
|
||||
|
|
@ -145,7 +144,7 @@ trait PersistenceDocSpec {
|
|||
//#at-least-once-example
|
||||
}
|
||||
|
||||
new AnyRef {
|
||||
object SaveSnapshot {
|
||||
|
||||
class MyPersistentActor extends PersistentActor {
|
||||
override def persistenceId = "my-stable-persistence-id"
|
||||
|
|
@ -164,7 +163,7 @@ trait PersistenceDocSpec {
|
|||
}
|
||||
}
|
||||
|
||||
new AnyRef {
|
||||
object OfferSnapshot {
|
||||
class MyPersistentActor extends PersistentActor {
|
||||
override def persistenceId = "my-stable-persistence-id"
|
||||
|
||||
|
|
@ -183,8 +182,6 @@ trait PersistenceDocSpec {
|
|||
|
||||
import akka.actor.Props
|
||||
|
||||
val persistentActor = system.actorOf(Props[MyPersistentActor])
|
||||
|
||||
//#snapshot-criteria
|
||||
persistentActor ! Recover(fromSnapshot = SnapshotSelectionCriteria(
|
||||
maxSequenceNr = 457L,
|
||||
|
|
@ -192,9 +189,7 @@ trait PersistenceDocSpec {
|
|||
//#snapshot-criteria
|
||||
}
|
||||
|
||||
new AnyRef {
|
||||
|
||||
val persistentActor = system.actorOf(Props[MyPersistentActor]())
|
||||
object PersistAsync {
|
||||
|
||||
//#persist-async
|
||||
class MyPersistentActor extends PersistentActor {
|
||||
|
|
@ -228,9 +223,8 @@ trait PersistenceDocSpec {
|
|||
|
||||
//#persist-async
|
||||
}
|
||||
new AnyRef {
|
||||
|
||||
val persistentActor = system.actorOf(Props[MyPersistentActor]())
|
||||
object Defer {
|
||||
|
||||
//#defer
|
||||
class MyPersistentActor extends PersistentActor {
|
||||
|
|
@ -268,9 +262,12 @@ trait PersistenceDocSpec {
|
|||
|
||||
//#defer-caller
|
||||
}
|
||||
new AnyRef {
|
||||
|
||||
object View {
|
||||
import akka.actor.Props
|
||||
|
||||
val system: ActorSystem = ???
|
||||
|
||||
//#view
|
||||
class MyView extends PersistentView {
|
||||
override def persistenceId: String = "some-persistence-id"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue