我注册了以下领事服务。
curl -s -X GET http://<CONSUL_URL>/v1/catalog/service/myservice | jq .
[
{
"ServicePort": 0000,
"ServiceAddress": "",
"ServiceTags": null,
"ServiceName": "myservice",
"ServiceID": "myservice",
"Address": "10.3.6.28",
"Node": "myservice-one"
},
{
"ServicePort": 0000,
"ServiceAddress": "",
"ServiceTags": null,
"ServiceName": "myservice",
"ServiceID": "myservice",
"Address": "10.3.6.28",
"Node": "myservice-main"
},
{
"ServicePort": 0000,
"ServiceAddress": "",
"ServiceTags": null,
"ServiceName": "myservice",
"ServiceID": "myservice",
"Address": "10.3.6.26",
"Node": "myservice-two"
},
{
"ServicePort": 0000,
"ServiceAddress": "",
"ServiceTags": null,
"ServiceName": "myservice",
"ServiceID": "myservice",
"Address": "10.3.6.27",
"Node": "myservice-three"
}
]
curl -s -X GET http://10.3.6.21:8500/v1/catalog/node/myservice-main | jq .
{
"Services": {
"myservice": {
"Port": 0000,
"Address": "",
"Tags": null,
"Service": "myservice",
"ID": "myservice"
}
},
"Node": {
"Address": "10.3.6.28",
"Node": "myservice-main"
}
}
如此处所示,我拥有的 myservice 服务中有一个节点 myservice-main。当 myservice-main 的地址发生变化时,我想执行一些特定的东西。我读到 consul watch 可以帮助实现它,但我无法为此编写 curl 命令。谁能指出我可以用来实现我的要求的http api?我只能使用 HTTP apis(curl) 和 shell 脚本,因为我想从远程系统执行它