SkyeYoung commented on code in PR #12906:
URL: https://github.com/apache/apisix/pull/12906#discussion_r2693724311
##########
apisix/discovery/eureka/init.lua:
##########
@@ -39,34 +39,37 @@ local _M = {
}
-local function service_info()
- local host = local_conf.discovery and
+-- build all eureka endpoints from config
+local function build_endpoints()
+ local host_list = local_conf.discovery and
local_conf.discovery.eureka and local_conf.discovery.eureka.host
- if not host then
+ if not host_list or #host_list == 0 then
log.error("do not set eureka.host")
- return
- end
-
- local basic_auth
- -- TODO Add health check to get healthy nodes.
- local url = host[math_random(#host)]
- local auth_idx = str_find(url, "@")
- if auth_idx then
- local protocol_idx = str_find(url, "://")
- local protocol = string_sub(url, 1, protocol_idx + 2)
- local user_and_password = string_sub(url, protocol_idx + 3, auth_idx -
1)
- local other = string_sub(url, auth_idx + 1)
- url = protocol .. other
- basic_auth = "Basic " .. ngx.encode_base64(user_and_password)
- end
- if local_conf.discovery.eureka.prefix then
- url = url .. local_conf.discovery.eureka.prefix
- end
- if string_sub(url, #url) ~= "/" then
- url = url .. "/"
+ return nil
+ end
+
+ local built_endpoints = core.table.new(#host_list, 0)
Review Comment:
The current calling relationship is as follows:
fetch_full_registry -> build_endpoints
```lua
function _M.init_worker()
...
ngx_timer_at(0, fetch_full_registry)
ngx_timer_every(fetch_interval, fetch_full_registry)
end
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]