This is an automated email from the ASF dual-hosted git repository.

fanningpj pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko.git


The following commit(s) were added to refs/heads/main by this push:
     new d881e6a0f5 Auto-select SRV lookup for the name lookup if entry looks 
like a srv name (#2745)
d881e6a0f5 is described below

commit d881e6a0f526333e6b9792d35a71a51355f64b14
Author: Philippus Baalman <[email protected]>
AuthorDate: Mon Mar 16 20:45:39 2026 +0100

    Auto-select SRV lookup for the name lookup if entry looks like a srv name 
(#2745)
---
 .../apache/pekko/discovery/ServiceDiscovery.scala   | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git 
a/discovery/src/main/scala/org/apache/pekko/discovery/ServiceDiscovery.scala 
b/discovery/src/main/scala/org/apache/pekko/discovery/ServiceDiscovery.scala
index 7cf19a5187..9f372b67c4 100644
--- a/discovery/src/main/scala/org/apache/pekko/discovery/ServiceDiscovery.scala
+++ b/discovery/src/main/scala/org/apache/pekko/discovery/ServiceDiscovery.scala
@@ -22,7 +22,8 @@ import scala.collection.immutable
 import scala.concurrent.Future
 import scala.concurrent.duration.FiniteDuration
 import scala.jdk.OptionConverters._
-
+import scala.jdk.DurationConverters._
+import scala.jdk.FutureConverters._
 import org.apache.pekko
 import pekko.actor.{ DeadLetterSuppression, NoSerializationVerificationNeeded }
 import pekko.util.HashCode
@@ -306,10 +307,17 @@ abstract class ServiceDiscovery {
   /**
    * Scala API: Perform lookup using underlying discovery implementation.
    *
-   * Convenience for when only a name is required.
+   * Convenience lookup accepting a name. If the name is a valid SRV entry, an 
SRV lookup is done, otherwise
+   * a regular lookup. For more control use the overload accepting a 
[[Lookup]].
    */
-  def lookup(serviceName: String, resolveTimeout: FiniteDuration): 
Future[Resolved] =
-    lookup(Lookup(serviceName), resolveTimeout)
+  def lookup(serviceName: String, resolveTimeout: FiniteDuration): 
Future[Resolved] = {
+    val parsedLookup =
+      if (Lookup.isValidSrv(serviceName))
+        Lookup.parseSrv(serviceName)
+      else
+        Lookup(serviceName)
+    lookup(parsedLookup, resolveTimeout)
+  }
 
   /**
    * Java API: Perform basic lookup using underlying discovery implementation.
@@ -328,11 +336,14 @@ abstract class ServiceDiscovery {
   /**
    * Java API
    *
+   * Convenience lookup accepting a name. If the name is a valid SRV entry, an 
SRV lookup is done, otherwise
+   * a regular lookup. For more control use the overload accepting a 
[[Lookup]].
+   *
    * @param serviceName           A name, see discovery-method's docs for how 
this is interpreted
    * @param resolveTimeout Timeout. Up to the discovery-method to adhere to 
this and complete the CompletionStage with a
    *                                [DiscoveryTimeoutException]
    */
   def lookup(serviceName: String, resolveTimeout: java.time.Duration): 
CompletionStage[Resolved] =
-    lookup(Lookup(serviceName), resolveTimeout)
+    lookup(serviceName, resolveTimeout.toScala).asJava
 
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to