zaneChou1 commented on a change in pull request #1356: [SCB-1565] add a Java client of servicecomb-service-center URL: https://github.com/apache/servicecomb-java-chassis/pull/1356#discussion_r342937739
########## File path: client/service-center-client/src/main/java/org/apache/servicecomb/service/center/client/ServiceCenterClient.java ########## @@ -0,0 +1,378 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.servicecomb.service.center.client; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.util.Map; + +import javax.management.OperationsException; + +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import org.apache.http.HttpStatus; +import org.apache.http.client.utils.URIBuilder; +import org.apache.servicecomb.service.center.client.http.*; +import org.apache.servicecomb.service.center.client.model.HeartbeatsRequest; +import org.apache.servicecomb.service.center.client.model.Microservice; +import org.apache.servicecomb.service.center.client.model.MicroserviceInstance; +import org.apache.servicecomb.service.center.client.model.MicroserviceInstanceStatus; +import org.apache.servicecomb.service.center.client.model.MicroserviceInstancesResponse; +import org.apache.servicecomb.service.center.client.model.MicroservicesResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Created by on 2019/10/16. + */ +public class ServiceCenterClient { + + private static final Logger LOGGER = LoggerFactory.getLogger(ServiceCenterClient.class); + + private ServiceCenterRawClient httpClient; + + /** + * Use default config parameter + */ + public ServiceCenterClient() { + this(new ServiceCenterRawClient()); + } + + /** + * Add TLS config of client + * @param tlsConfig + */ + public ServiceCenterClient(TLSConfig tlsConfig){ + this(tlsConfig,null); + } + + /** + * Add extraGlobalHeaders to http request + * @param extraGlobalHeaders + */ + public ServiceCenterClient(Map<String, String> extraGlobalHeaders) { + this(null,0,null,null,extraGlobalHeaders); + } + + /** + * Add TLS config and extraGlobalHeaders + * @param tlsConfig + * @param extraGlobalHeaders + */ + public ServiceCenterClient(TLSConfig tlsConfig,Map<String, String> extraGlobalHeaders){ + this(null,0,null,tlsConfig,extraGlobalHeaders); + } + + /** + * Customized host,port, + * @param host + * @param port + */ + public ServiceCenterClient(String host, int port) { + this(host, port, null,null, null); + } + + /** + * Customized host,port,domainName,TLSConf, headers and any one parameter can be null. + * @param host + * @param port + * @param domainName + * @param tlsConfig + * @param extraGlobalHeaders + */ + public ServiceCenterClient(String host, int port, String domainName, TLSConfig tlsConfig, Map<String, String> extraGlobalHeaders) { Review comment: yes, this is a good idea. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
