Is there a way to specify a timeout individually instead of an implicit value in the Ask of Scala Ask?

Asked 1 years ago, Updated 1 years ago, 122 views

I have looked around some sample codes for Ask in Scala's Actor, all of which have implicitly set the timeout as implicit val timeout=Timeout(5seconds) as shown in the following URL:
Does that mean that it is not possible to set it individually with the second argument of Wait.result?

http://alvinalexander.com/scala/scala-akka-actors-ask-examples-future-await-timeout-result
http://kimutansk.hatenablog.com/entry/20140726/1406330944
https://stackoverflow.com/questions/20124072/akka-the-proper-use-of-ask-pattern

scala

2022-09-30 21:14

1 Answers

I think it's probably this one, so
http://doc.akka.io/api/akka/2.4.2/ #akka.pattern.AskableActorRef

def?(message:Any) (implicit timeout:Timeout, sender:ActorRef=Actor.noSender): Future [Any]

In other words,

actor.?(message) (Timeout (5 seconds))

or
actor.?(message)(Timeout(5 seconds),implicitly [ActorRef])

I think we can do it with

In other words, scala has several argument groups and is shaped like def method(a:Int, b:Long)(c:Byte).When calling, write something like method(a,b)(c). If implicit is a declaration such as def method(a:Int,b:Long)(implicit c:Byte), look for a Byte type variable declared by explicit val, etc. implicitly [ActorRef] is a function that explicitly takes implicit arguments (details>).


2022-09-30 21:14

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.