spacewander commented on a change in pull request #3686:
URL: https://github.com/apache/apisix/pull/3686#discussion_r584029064



##########
File path: apisix/core/dns/client.lua
##########
@@ -29,6 +31,67 @@ local _M = {
 }
 
 
+local function gcd(a, b)
+    if b == 0 then
+        return a
+    end
+
+    return gcd(b, a % b)
+end
+
+
+local function resolve_srv(client, answers)
+    if #answers == 0 then
+        return nil, "empty SRV record"
+    end
+
+    local resolved_answers = {}
+    local answer_to_count = {}
+    for _, answer in ipairs(answers) do
+        if answer.type ~= client.TYPE_SRV then
+            return nil, "mess SRV with other record"
+        end
+
+        local resolved, err = client.resolve(answer.target)
+        if not resolved then
+            local msg = "failed to resolve SRV record " .. answer.target .. ": 
" .. err
+            return nil, msg
+        end
+
+        log.info("dns resolve SRV ", answer.target, ", result: ",
+                 json.delay_encode(resolved))
+
+        local weight = answer.weight

Review comment:
       Added: 
https://github.com/apache/apisix/pull/3686/files#diff-eeebb3321eff56ec1f7b883a6a08b29bbc6359cdd06407eca329772b9a619676R122




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to