From c25a8d32152259f066105817f25b3a8342e6f32e Mon Sep 17 00:00:00 2001 From: Gregor Heine Date: Thu, 15 Aug 2024 14:23:05 +0200 Subject: [PATCH] FDN-???: Support internal host names in PCI --- src/main/scala/io/flow/util/clients/Registry.scala | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/scala/io/flow/util/clients/Registry.scala b/src/main/scala/io/flow/util/clients/Registry.scala index 82ecda8..5e3a852 100644 --- a/src/main/scala/io/flow/util/clients/Registry.scala +++ b/src/main/scala/io/flow/util/clients/Registry.scala @@ -102,18 +102,24 @@ class ProductionRegistry() extends Registry { publicHost } else { Try { - Await.result(asyncDnsLookupByName(applicationId), RegistryConstants.DnsLookupWaitTime) - }.fold(_ => publicHost, _ => s"http://$applicationId") + val future = Future.find(Seq( + asyncDnsLookupByName(applicationId), + asyncDnsLookupByName(s"$applicationId.$applicationId"), + asyncDnsLookupByName(s"$applicationId.production"), + ))(_ => true) + Await.result(future, RegistryConstants.DnsLookupWaitTime) + }.toOption.flatten.fold(publicHost)(localHost => s"http://$localHost") } RegistryConstants.log("Production", applicationId, s"host[$host]") host } - protected def asyncDnsLookupByName(name: String): Future[Unit] = { + protected def asyncDnsLookupByName(name: String): Future[String] = { Future { InetAddress.getByName(name) - }.map(_ => ()) + name + } } }