Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
50 lines (38 sloc) 1.2 KB
/*
* Copyright (C) 2018-2019 Lightbend Inc. <https://www.lightbend.com>
*/
package docs.actor.io.dns
import akka.actor.{ ActorRef, ActorSystem }
import akka.io.dns.DnsProtocol
import akka.io.dns.DnsProtocol.Srv
import akka.pattern.ask
import akka.io.{ Dns, IO }
import akka.util.Timeout
import scala.concurrent.Future
import scala.concurrent.duration._
object DnsCompileOnlyDocSpec {
implicit val system = ActorSystem()
implicit val timeout = Timeout(1.second)
val actorRef: ActorRef = ???
//#resolve
val initial: Option[Dns.Resolved] = Dns(system).cache.resolve("google.com")(system, actorRef)
val cached: Option[Dns.Resolved] = Dns(system).cache.cached("google.com")
//#resolve
{
//#actor-api-inet-address
val resolved: Future[Dns.Resolved] = (IO(Dns) ? Dns.Resolve("google.com")).mapTo[Dns.Resolved]
//#actor-api-inet-address
}
{
//#actor-api-async
val resolved: Future[DnsProtocol.Resolved] =
(IO(Dns) ? DnsProtocol.Resolve("google.com")).mapTo[DnsProtocol.Resolved]
//#actor-api-async
}
{
//#srv
val resolved: Future[DnsProtocol.Resolved] =
(IO(Dns) ? DnsProtocol.Resolve("your-service", Srv)).mapTo[DnsProtocol.Resolved]
//#srv
}
}
You can’t perform that action at this time.