replace unicode arrows
* ⇒, →, ← * because we don't want to show them in documentation snippets and then it's complicated to avoid that when snippets are located in src/test/scala in individual modules * dont replace object `→` in FSM.scala and PersistentFSM.scala
This commit is contained in:
parent
e4d38f92a4
commit
5c96a5f556
1521 changed files with 18846 additions and 18786 deletions
|
|
@ -92,7 +92,7 @@ object IntegrationDocSpec {
|
|||
|
||||
class DatabaseService(probe: ActorRef) extends Actor {
|
||||
override def receive = {
|
||||
case Save(tweet: Tweet) ⇒
|
||||
case Save(tweet: Tweet) =>
|
||||
probe ! tweet.author.handle
|
||||
sender() ! SaveDone
|
||||
}
|
||||
|
|
@ -123,7 +123,7 @@ object IntegrationDocSpec {
|
|||
//#ask-actor
|
||||
class Translator extends Actor {
|
||||
def receive = {
|
||||
case word: String ⇒
|
||||
case word: String =>
|
||||
// ... process message
|
||||
val reply = word.toUpperCase
|
||||
sender() ! reply // reply to the ask
|
||||
|
|
@ -169,14 +169,14 @@ class IntegrationDocSpec extends AkkaSpec(IntegrationDocSpec.config) {
|
|||
//#email-addresses-mapAsync
|
||||
val emailAddresses: Source[String, NotUsed] =
|
||||
authors
|
||||
.mapAsync(4)(author ⇒ addressSystem.lookupEmail(author.handle))
|
||||
.collect { case Some(emailAddress) ⇒ emailAddress }
|
||||
.mapAsync(4)(author => addressSystem.lookupEmail(author.handle))
|
||||
.collect { case Some(emailAddress) => emailAddress }
|
||||
//#email-addresses-mapAsync
|
||||
|
||||
//#send-emails
|
||||
val sendEmails: RunnableGraph[NotUsed] =
|
||||
emailAddresses
|
||||
.mapAsync(4)(address ⇒ {
|
||||
.mapAsync(4)(address => {
|
||||
emailServer.send(
|
||||
Email(to = address, title = "Akka", body = "I like your tweet"))
|
||||
})
|
||||
|
|
@ -205,7 +205,7 @@ class IntegrationDocSpec extends AkkaSpec(IntegrationDocSpec.config) {
|
|||
// sent from stream to actor to indicate start, end or failure of stream:
|
||||
val InitMessage = AckingReceiver.StreamInitialized
|
||||
val OnCompleteMessage = AckingReceiver.StreamCompleted
|
||||
val onErrorMessage = (ex: Throwable) ⇒ AckingReceiver.StreamFailure(ex)
|
||||
val onErrorMessage = (ex: Throwable) => AckingReceiver.StreamFailure(ex)
|
||||
|
||||
val probe = TestProbe()
|
||||
val receiver = system.actorOf(
|
||||
|
|
@ -242,20 +242,20 @@ class IntegrationDocSpec extends AkkaSpec(IntegrationDocSpec.config) {
|
|||
import AckingReceiver._
|
||||
|
||||
def receive: Receive = {
|
||||
case StreamInitialized ⇒
|
||||
case StreamInitialized =>
|
||||
log.info("Stream initialized!")
|
||||
probe ! "Stream initialized!"
|
||||
sender() ! Ack // ack to allow the stream to proceed sending more elements
|
||||
|
||||
case el: String ⇒
|
||||
case el: String =>
|
||||
log.info("Received element: {}", el)
|
||||
probe ! el
|
||||
sender() ! Ack // ack to allow the stream to proceed sending more elements
|
||||
|
||||
case StreamCompleted ⇒
|
||||
case StreamCompleted =>
|
||||
log.info("Stream completed!")
|
||||
probe ! "Stream completed!"
|
||||
case StreamFailure(ex) ⇒
|
||||
case StreamFailure(ex) =>
|
||||
log.error(ex, "Stream failed!")
|
||||
}
|
||||
}
|
||||
|
|
@ -272,7 +272,7 @@ class IntegrationDocSpec extends AkkaSpec(IntegrationDocSpec.config) {
|
|||
|
||||
val emailAddresses: Source[String, NotUsed] =
|
||||
authors.via(
|
||||
Flow[Author].mapAsync(4)(author ⇒ addressSystem.lookupEmail(author.handle))
|
||||
Flow[Author].mapAsync(4)(author => addressSystem.lookupEmail(author.handle))
|
||||
.withAttributes(supervisionStrategy(resumingDecider)))
|
||||
//#email-addresses-mapAsync-supervision
|
||||
}
|
||||
|
|
@ -288,12 +288,12 @@ class IntegrationDocSpec extends AkkaSpec(IntegrationDocSpec.config) {
|
|||
|
||||
val emailAddresses: Source[String, NotUsed] =
|
||||
authors
|
||||
.mapAsyncUnordered(4)(author ⇒ addressSystem.lookupEmail(author.handle))
|
||||
.collect { case Some(emailAddress) ⇒ emailAddress }
|
||||
.mapAsyncUnordered(4)(author => addressSystem.lookupEmail(author.handle))
|
||||
.collect { case Some(emailAddress) => emailAddress }
|
||||
|
||||
val sendEmails: RunnableGraph[NotUsed] =
|
||||
emailAddresses
|
||||
.mapAsyncUnordered(4)(address ⇒ {
|
||||
.mapAsyncUnordered(4)(address => {
|
||||
emailServer.send(
|
||||
Email(to = address, title = "Akka", body = "I like your tweet"))
|
||||
})
|
||||
|
|
@ -320,15 +320,15 @@ class IntegrationDocSpec extends AkkaSpec(IntegrationDocSpec.config) {
|
|||
val authors = tweets.filter(_.hashtags.contains(akkaTag)).map(_.author)
|
||||
|
||||
val phoneNumbers =
|
||||
authors.mapAsync(4)(author ⇒ addressSystem.lookupPhoneNumber(author.handle))
|
||||
.collect { case Some(phoneNo) ⇒ phoneNo }
|
||||
authors.mapAsync(4)(author => addressSystem.lookupPhoneNumber(author.handle))
|
||||
.collect { case Some(phoneNo) => phoneNo }
|
||||
|
||||
//#blocking-mapAsync
|
||||
val blockingExecutionContext = system.dispatchers.lookup("blocking-dispatcher")
|
||||
|
||||
val sendTextMessages: RunnableGraph[NotUsed] =
|
||||
phoneNumbers
|
||||
.mapAsync(4)(phoneNo ⇒ {
|
||||
.mapAsync(4)(phoneNo => {
|
||||
Future {
|
||||
smsServer.send(
|
||||
TextMessage(to = phoneNo, body = "I like your tweet"))
|
||||
|
|
@ -357,12 +357,12 @@ class IntegrationDocSpec extends AkkaSpec(IntegrationDocSpec.config) {
|
|||
val authors = tweets.filter(_.hashtags.contains(akkaTag)).map(_.author)
|
||||
|
||||
val phoneNumbers =
|
||||
authors.mapAsync(4)(author ⇒ addressSystem.lookupPhoneNumber(author.handle))
|
||||
.collect { case Some(phoneNo) ⇒ phoneNo }
|
||||
authors.mapAsync(4)(author => addressSystem.lookupPhoneNumber(author.handle))
|
||||
.collect { case Some(phoneNo) => phoneNo }
|
||||
|
||||
//#blocking-map
|
||||
val send = Flow[String]
|
||||
.map { phoneNo ⇒
|
||||
.map { phoneNo =>
|
||||
smsServer.send(TextMessage(to = phoneNo, body = "I like your tweet"))
|
||||
}
|
||||
.withAttributes(ActorAttributes.dispatcher("blocking-dispatcher"))
|
||||
|
|
@ -393,7 +393,7 @@ class IntegrationDocSpec extends AkkaSpec(IntegrationDocSpec.config) {
|
|||
implicit val timeout = Timeout(3.seconds)
|
||||
val saveTweets: RunnableGraph[NotUsed] =
|
||||
akkaTweets
|
||||
.mapAsync(4)(tweet ⇒ database ? Save(tweet))
|
||||
.mapAsync(4)(tweet => database ? Save(tweet))
|
||||
.to(Sink.ignore)
|
||||
//#save-tweets
|
||||
|
||||
|
|
@ -423,9 +423,9 @@ class IntegrationDocSpec extends AkkaSpec(IntegrationDocSpec.config) {
|
|||
ActorMaterializerSettings(system).withInputBuffer(initialSize = 4, maxSize = 4))
|
||||
|
||||
Source(List("a", "B", "C", "D", "e", "F", "g", "H", "i", "J"))
|
||||
.map(elem ⇒ { println(s"before: $elem"); elem })
|
||||
.map(elem => { println(s"before: $elem"); elem })
|
||||
.mapAsync(4)(service.convert)
|
||||
.runForeach(elem ⇒ println(s"after: $elem"))
|
||||
.runForeach(elem => println(s"after: $elem"))
|
||||
//#sometimes-slow-mapAsync
|
||||
|
||||
probe.expectMsg("after: A")
|
||||
|
|
@ -455,9 +455,9 @@ class IntegrationDocSpec extends AkkaSpec(IntegrationDocSpec.config) {
|
|||
ActorMaterializerSettings(system).withInputBuffer(initialSize = 4, maxSize = 4))
|
||||
|
||||
Source(List("a", "B", "C", "D", "e", "F", "g", "H", "i", "J"))
|
||||
.map(elem ⇒ { println(s"before: $elem"); elem })
|
||||
.map(elem => { println(s"before: $elem"); elem })
|
||||
.mapAsyncUnordered(4)(service.convert)
|
||||
.runForeach(elem ⇒ println(s"after: $elem"))
|
||||
.runForeach(elem => println(s"after: $elem"))
|
||||
//#sometimes-slow-mapAsyncUnordered
|
||||
|
||||
probe.receiveN(10).toSet should be(Set(
|
||||
|
|
@ -481,19 +481,19 @@ class IntegrationDocSpec extends AkkaSpec(IntegrationDocSpec.config) {
|
|||
val queue = Source
|
||||
.queue[Int](bufferSize, OverflowStrategy.backpressure)
|
||||
.throttle(elementsToProcess, 3.second)
|
||||
.map(x ⇒ x * x)
|
||||
.toMat(Sink.foreach(x ⇒ println(s"completed $x")))(Keep.left)
|
||||
.map(x => x * x)
|
||||
.toMat(Sink.foreach(x => println(s"completed $x")))(Keep.left)
|
||||
.run()
|
||||
|
||||
val source = Source(1 to 10)
|
||||
|
||||
implicit val ec = system.dispatcher
|
||||
source.mapAsync(1)(x ⇒ {
|
||||
source.mapAsync(1)(x => {
|
||||
queue.offer(x).map {
|
||||
case QueueOfferResult.Enqueued ⇒ println(s"enqueued $x")
|
||||
case QueueOfferResult.Dropped ⇒ println(s"dropped $x")
|
||||
case QueueOfferResult.Failure(ex) ⇒ println(s"Offer failed ${ex.getMessage}")
|
||||
case QueueOfferResult.QueueClosed ⇒ println("Source Queue closed")
|
||||
case QueueOfferResult.Enqueued => println(s"enqueued $x")
|
||||
case QueueOfferResult.Dropped => println(s"dropped $x")
|
||||
case QueueOfferResult.Failure(ex) => println(s"Offer failed ${ex.getMessage}")
|
||||
case QueueOfferResult.QueueClosed => println("Source Queue closed")
|
||||
}
|
||||
}).runWith(Sink.ignore)
|
||||
//#source-queue
|
||||
|
|
@ -505,8 +505,8 @@ class IntegrationDocSpec extends AkkaSpec(IntegrationDocSpec.config) {
|
|||
|
||||
val ref = Source
|
||||
.actorRef[Int](bufferSize, OverflowStrategy.fail) // note: backpressure is not supported
|
||||
.map(x ⇒ x * x)
|
||||
.toMat(Sink.foreach(x ⇒ println(s"completed $x")))(Keep.left)
|
||||
.map(x => x * x)
|
||||
.toMat(Sink.foreach(x => println(s"completed $x")))(Keep.left)
|
||||
.run()
|
||||
|
||||
ref ! 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue