Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(clustering/rpc): connection lost event #14257

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

StarlightIbuki
Copy link
Contributor

Summary

Emit an event when the connection is lost

Checklist

  • The Pull Request has tests
  • A changelog file has been created under changelog/unreleased/kong or skip-changelog label added on PR if changelog is unnecessary. README.md
  • There is a user-facing docs PR against https://github.com/Kong/docs.konghq.com - PUT DOCS PR HERE

Issue reference

Precondition for KAG-6178

@github-actions github-actions bot added core/clustering size/S cherry-pick kong-ee schedule this PR for cherry-picking to kong/kong-ee labels Feb 11, 2025
@StarlightIbuki StarlightIbuki added skip-changelog and removed core/clustering size/S cherry-pick kong-ee schedule this PR for cherry-picking to kong/kong-ee labels Feb 11, 2025
@@ -605,16 +605,16 @@ function _M:connect(premature, node_id, host, path, cert, key)
local meta_cap = resp_headers["sec_websocket_protocol"]

if meta_cap ~= RPC_META_V1 then
ngx_log(ngx_ERR, _log_prefix, "did not support protocol : ", meta_cap)
err = "did not support protocol : " .. (type(meta_cap) == "string" and meta_cap or "unknown")
c:send_close() -- can't do much if this fails
goto err
end

-- if timeout (default is 5s) we will close the connection
local ok, err = self:_meta_call(c, meta_cap, node_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
local ok, err = self:_meta_call(c, meta_cap, node_id)
ok, err = self:_meta_call(c, meta_cap, node_id)

@@ -587,7 +587,7 @@ function _M:connect(premature, node_id, host, path, cert, key)

local ok, err = c:connect(uri, opts)
if not ok then
ngx_log(ngx_ERR, _log_prefix, "unable to connect to peer: ", err)
err = "unable to connect to peer: " .. (err or "unknown error")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the log?

local worker_events = assert(kong.worker_events)

-- notify this worker
local ok, err = worker_events.post_local("clustering:jsonrpc", "connection_lost")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may cause duplicated event when connection disconnected, what's your opinion? how do we distinguish them?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, it is dp side event.

@chronolaw chronolaw changed the title feat(rpc): connection lost event feat(clustering/rpc): connection lost event Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants