class AbstractRestInvoker {
    private static final Logger LOG = LoggerFactory.getLogger(AbstractRestInvoker.class);

    protected ServiceResource serviceResource;
    protected String serviceId;
    protected RestTemplate restTemplate;
    protected boolean async;

    public AbstractRestInvoker(ServiceResource serviceResource, String serviceId, RestTemplate restTemplate) {
        this(serviceResource, serviceId, restTemplate, false);
    }

    public AbstractRestInvoker(ServiceResource serviceResource, String serviceId, RestTemplate restTemplate, boolean async) {
        this.serviceResource = serviceResource;
        this.serviceId = serviceId;
        this.restTemplate = restTemplate;
        this.async = async;
    }

    public List<ResultEntity> invoke() {<FILL_FUNCTION_BODY>}

    protected String getInvokeType() {
        return async ? DiscoveryConstant.ASYNC : DiscoveryConstant.SYNC;
    }

    protected HttpHeaders getInvokeHeaders() {
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_JSON_UTF8);

        return headers;
    }

    protected HttpEntity<String> getInvokeEntity(String content) {
        HttpHeaders headers = getInvokeHeaders();

        return new HttpEntity<String>(content, headers);
    }

    protected abstract String getDescription();

    protected abstract String getSuffixPath();

    protected abstract String doRest(String url);
}

        List<ServiceInstance> instances = serviceResource.getInstances(serviceId);
        if (CollectionUtils.isEmpty(instances)) {
            LOG.warn("No service instances found");

            throw new DiscoveryException("No service instances found");
        }

        List<ResultEntity> resultEntityList = new ArrayList<ResultEntity>();
        for (ServiceInstance instance : instances) {
            Map<String, String> metadata = instance.getMetadata();
            String host = instance.getHost();
            int port = instance.getPort();

            String protocol = InstanceEntityWrapper.getProtocol(metadata);
            String contextPath = InstanceEntityWrapper.getFormatContextPath(metadata);

            String url = protocol + "://" + host + ":" + port + contextPath + getSuffixPath();

            String result = null;
            try {
                result = doRest(url);
                String error = RestUtil.getError(restTemplate);
                if (StringUtils.isNotEmpty(error)) {
                    result = error;
                }
            } catch (Exception e) {
                result = ResponseUtil.getFailureMessage(e);
            }

            ResultEntity resultEntity = new ResultEntity();
            resultEntity.setServiceId(serviceId);
            resultEntity.setHost(host);
            resultEntity.setPort(port);
            resultEntity.setUrl(url);
            resultEntity.setResult(result);

            resultEntityList.add(resultEntity);
        }

        String description = getDescription();

        LOG.info(description + " results=\n{}", resultEntityList);

        return resultEntityList;
    
<no_super_class>