获取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
  }
]

codecraft
11.9k 声望2k 粉丝

当一个代码的工匠回首往事时,不因虚度年华而悔恨,也不因碌碌无为而羞愧,这样,当他老的时候,可以很自豪告诉世人,我曾经将代码注入生命去打造互联网的浪潮之巅,那是个很疯狂的时代,我在一波波的浪潮上留下...