在将https://github.com/level077/lua-resty-upstream-etcd整合到项目中时,function set_current_peer(server)会调用lua-resty-core/lib/ngx/balancer.lua的set_current_peer(addr, port)。这时候传的参数就是ip:port,因此port默认为0。但是,在运行时没有报错,转发也正常。看了C.ngx_http_lua_ffi_balancer_set_current_peer, 它将ip:port作为addr,将0作为port。
那么在这里port参数是做什么用的,感觉不是必须的啊。