Skip to content

feat: add control api for discovery module#3742

Merged
spacewander merged 6 commits into
apache:masterfrom
yongboy:control_for_discovery
Mar 8, 2021
Merged

feat: add control api for discovery module#3742
spacewander merged 6 commits into
apache:masterfrom
yongboy:control_for_discovery

Conversation

@yongboy

@yongboy yongboy commented Mar 3, 2021

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Just implement the _M.dump_data() function for discovery module, then call the control api for dumping running details online.

The dump api uri template:

GET /v1/discovery/{discovery_type}/dump

eg:

curl http://127.0.0.1:9090/v1/discovery/eureka/dump

Pre-submission checklist:

  • Did you explain what problem does this PR solve? Or what new features have been added?
  • Have you added corresponding test cases?
  • Have you modified the corresponding document?
  • Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list first

@spacewander

Copy link
Copy Markdown
Member

The conflict needs to be solved so that the CI can run.

Comment thread docs/en/latest/discovery.md Outdated
Comment thread apisix/control/router.lua
if discovery_type then
local discovery = require("apisix.discovery.init").discovery
local dump_apis = {}
for key, _ in pairs(discovery_type) do

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems we can use for key, dis_mod in pairs(discovery) do directly?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good idea!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

if use for key, dis_mod in pairs(discovery) do, the dis_mod is function type, not a table object.

So, we can't do it.

Comment thread t/control/discovery.t Outdated
Comment thread t/control/discovery.t Outdated
GET /v1/discovery/eureka/dump
--- error_code: 200
--- response_body_unlike
^{}$

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ditto

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Y

@spacewander

Copy link
Copy Markdown
Member

The CI fails because of #3747

Comment thread docs/en/latest/discovery.md Outdated


function _M.dump_data()
... ...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think an example return data shoul be written here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

for example ?

  function _M.dump_data()
      return {config = your_config, services = your_services, other = ... } 
  end

@spacewander
spacewander merged commit 34f60ee into apache:master Mar 8, 2021
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