获取instance信息
@Autowired
DiscoveryClient discoveryClient;
public List<ServiceInstance> serviceUrl(String service) {
List<ServiceInstance> instances = discoveryClient.getInstances(service);
return instances;
}
返回实例
[
{
"instanceInfo": {
"instanceId": "XXX-h0257:XXX:3000",
"app": "XXX",
"appGroupName": null,
"ipAddr": "11.1.98.15",
"sid": "na",
"homePageUrl": "http://11.1.98.15:3000/",
"statusPageUrl": "http://11.1.98.15:3000/info",
"healthCheckUrl": "http://11.1.98.15:3000/health",
"secureHealthCheckUrl": null,
"vipAddress": "XXX",
"secureVipAddress": "XXX",
"countryId": 1,
"dataCenterInfo": {
"@class": "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo",
"name": "MyOwn"
},
"hostName": "11.1.98.15",
"status": "UP",
"leaseInfo": {
"renewalIntervalInSecs": 10,
"durationInSecs": 90,
"registrationTimestamp": 1480504169270,
"lastRenewalTimestamp": 1480504388555,
"evictionTimestamp": 0,
"serviceUpTimestamp": 1480504169271
},
"isCoordinatingDiscoveryServer": false,
"metadata": {},
"lastUpdatedTimestamp": 1480504169271,
"lastDirtyTimestamp": 1480504168214,
"actionType": "ADDED",
"asgName": null,
"overriddenStatus": "UNKNOWN"
},
"serviceId": "XXX",
"metadata": {},
"uri": "http://11.1.98.15:3000",
"secure": false,
"host": "11.1.98.15",
"port": 3000
},
{
"instanceInfo": {
"instanceId": "XXX-s4lwl:XXX:3000",
"app": "XXX",
"appGroupName": null,
"ipAddr": "11.1.16.11",
"sid": "na",
"homePageUrl": "http://11.1.16.11:3000/",
"statusPageUrl": "http://11.1.16.11:3000/info",
"healthCheckUrl": "http://11.1.16.11:3000/health",
"secureHealthCheckUrl": null,
"vipAddress": "XXX",
"secureVipAddress": "XXX",
"countryId": 1,
"dataCenterInfo": {
"@class": "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo",
"name": "MyOwn"
},
"hostName": "11.1.16.11",
"status": "UP",
"leaseInfo": {
"renewalIntervalInSecs": 10,
"durationInSecs": 90,
"registrationTimestamp": 1480504289728,
"lastRenewalTimestamp": 1480504570040,
"evictionTimestamp": 0,
"serviceUpTimestamp": 1480504289728
},
"isCoordinatingDiscoveryServer": false,
"metadata": {},
"lastUpdatedTimestamp": 1480504289728,
"lastDirtyTimestamp": 1480504289735,
"actionType": "ADDED",
"asgName": null,
"overriddenStatus": "UNKNOWN"
},
"serviceId": "XXX",
"metadata": {},
"uri": "http://11.1.16.11:3000",
"secure": false,
"host": "11.1.16.11",
"port": 3000
}
]
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。