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: support xrpc custom healthcheck methods #1

Merged
merged 7 commits into from
Sep 23, 2024
Merged

Conversation

AlinsRan
Copy link

@AlinsRan AlinsRan commented Sep 20, 2024

By adding callback functions, custom health check methods can be applied to private protocols.

local checker = healthcheck.new({
  name = "testing",
  shm_name = "test_shm",
  type = "xrpc",
  checks = {
      active = {
          healthy  = {
              interval = 0.5, -- we don't want active checks
              statuses = {200,201},
              successes = 2,
          },
          unhealthy  = {
              interval = 0.5, -- we don't want active checks
              statuses = {500, 501},
              failures = 2,
          },
          xrpc_handler = function(node, conf)
              local http = require('resty.http')
              local httpc = http.new()
              local res, err = httpc:request_uri("http://127.0.0.1:2119/status", {
                  method = "GET",
                  path = "/status",
              })
              if not res then
                  return false
              end
              return true, res.status
          end
      },
  },
})

@CLAassistant
Copy link

CLAassistant commented Sep 20, 2024

CLA assistant check
All committers have signed the CLA.

@AlinsRan AlinsRan closed this Sep 20, 2024
@AlinsRan AlinsRan reopened this Sep 20, 2024
@membphis membphis self-requested a review September 20, 2024 07:22
lib/resty/healthcheck.lua Outdated Show resolved Hide resolved
@@ -27,6 +27,7 @@ jobs:
run: |
sudo cpanm --notest Test::Nginx > build.log 2>&1 || (cat build.log && exit 1)
sudo luarocks install luacheck
sudo luarocks install api7-lua-resty-http 0.2.2-0

Choose a reason for hiding this comment

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

we'd better add xrpc, it is meaningful

Copy link
Author

@AlinsRan AlinsRan Sep 20, 2024

Choose a reason for hiding this comment

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

The resty.http is only used in testing.
After merging the PR here, the healthcheck library will be released and the xrpc suffix will be added.

Copy link
Author

@AlinsRan AlinsRan Sep 20, 2024

Choose a reason for hiding this comment

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

image

@AlinsRan AlinsRan changed the title feat: support xrpc protocol custom protocol feat: support xrpc custom health check methods Sep 20, 2024
@AlinsRan AlinsRan changed the title feat: support xrpc custom health check methods feat: support xrpc custom healthcheck methods Sep 20, 2024
@AlinsRan AlinsRan merged commit 06dea8a into release/2.3 Sep 23, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants