parent
629c7441a4
commit
1a3408661e
@ -1,44 +1,44 @@
|
|||||||
/*
|
///*
|
||||||
* Tencent is pleased to support the open source community by making Spring Cloud Tencent available.
|
// * Tencent is pleased to support the open source community by making Spring Cloud Tencent available.
|
||||||
*
|
// *
|
||||||
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
|
// * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
|
||||||
*
|
// *
|
||||||
* Licensed under the BSD 3-Clause License (the "License");
|
// * Licensed under the BSD 3-Clause License (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
// * you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
// * You may obtain a copy of the License at
|
||||||
*
|
// *
|
||||||
* https://opensource.org/licenses/BSD-3-Clause
|
// * https://opensource.org/licenses/BSD-3-Clause
|
||||||
*
|
// *
|
||||||
* Unless required by applicable law or agreed to in writing, software distributed
|
// * 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
|
// * 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
|
// * CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations under the License.
|
// * specific language governing permissions and limitations under the License.
|
||||||
*/
|
// */
|
||||||
|
//
|
||||||
package com.tencent.cloud.polaris.loadbalancer.reactive;
|
//package com.tencent.cloud.polaris.loadbalancer.reactive;
|
||||||
|
//
|
||||||
import com.tencent.cloud.common.constant.HeaderConstant;
|
//import com.tencent.cloud.common.constant.HeaderConstant;
|
||||||
import com.tencent.polaris.api.core.ConsumerAPI;
|
//import com.tencent.polaris.api.core.ConsumerAPI;
|
||||||
|
//
|
||||||
import org.springframework.cloud.client.ServiceInstance;
|
//import org.springframework.cloud.client.ServiceInstance;
|
||||||
import org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerClientRequestTransformer;
|
//import org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerClientRequestTransformer;
|
||||||
import org.springframework.http.HttpHeaders;
|
//import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.web.reactive.function.client.ClientRequest;
|
//import org.springframework.web.reactive.function.client.ClientRequest;
|
||||||
|
//
|
||||||
public class PolarisLoadBalancerClientRequestTransformer implements LoadBalancerClientRequestTransformer {
|
//public class PolarisLoadBalancerClientRequestTransformer implements LoadBalancerClientRequestTransformer {
|
||||||
|
//
|
||||||
private final ConsumerAPI consumerAPI;
|
// private final ConsumerAPI consumerAPI;
|
||||||
|
//
|
||||||
public PolarisLoadBalancerClientRequestTransformer(ConsumerAPI consumerAPI) {
|
// public PolarisLoadBalancerClientRequestTransformer(ConsumerAPI consumerAPI) {
|
||||||
this.consumerAPI = consumerAPI;
|
// this.consumerAPI = consumerAPI;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public ClientRequest transformRequest(ClientRequest request, ServiceInstance instance) {
|
// public ClientRequest transformRequest(ClientRequest request, ServiceInstance instance) {
|
||||||
if (instance != null) {
|
// if (instance != null) {
|
||||||
HttpHeaders headers = request.headers();
|
// HttpHeaders headers = request.headers();
|
||||||
headers.add(HeaderConstant.INTERNAL_CALLEE_SERVICE_ID, instance.getServiceId());
|
// headers.add(HeaderConstant.INTERNAL_CALLEE_SERVICE_ID, instance.getServiceId());
|
||||||
}
|
// }
|
||||||
return request;
|
// return request;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
@ -1,29 +1,29 @@
|
|||||||
/*
|
///*
|
||||||
* Tencent is pleased to support the open source community by making Spring Cloud Tencent available.
|
// * Tencent is pleased to support the open source community by making Spring Cloud Tencent available.
|
||||||
*
|
// *
|
||||||
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
|
// * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
|
||||||
*
|
// *
|
||||||
* Licensed under the BSD 3-Clause License (the "License");
|
// * Licensed under the BSD 3-Clause License (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
// * you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
// * You may obtain a copy of the License at
|
||||||
*
|
// *
|
||||||
* https://opensource.org/licenses/BSD-3-Clause
|
// * https://opensource.org/licenses/BSD-3-Clause
|
||||||
*
|
// *
|
||||||
* Unless required by applicable law or agreed to in writing, software distributed
|
// * 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
|
// * 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
|
// * CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations under the License.
|
// * specific language governing permissions and limitations under the License.
|
||||||
*/
|
// */
|
||||||
|
//
|
||||||
package com.tencent.cloud.rpc.enhancement.resttemplate;
|
//package com.tencent.cloud.rpc.enhancement.resttemplate;
|
||||||
|
//
|
||||||
import org.springframework.web.client.ResponseErrorHandler;
|
//import org.springframework.web.client.ResponseErrorHandler;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* Polaris Response Error Handler Definition Of {@link ResponseErrorHandler}.
|
// * Polaris Response Error Handler Definition Of {@link ResponseErrorHandler}.
|
||||||
*
|
// *
|
||||||
* @author wh 2022/6/21
|
// * @author wh 2022/6/21
|
||||||
*/
|
// */
|
||||||
public interface PolarisResponseErrorHandler extends ResponseErrorHandler {
|
//public interface PolarisResponseErrorHandler extends ResponseErrorHandler {
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.tencent.cloud.rpc.enhancement.webclient;
|
||||||
|
|
||||||
|
import com.tencent.cloud.common.constant.HeaderConstant;
|
||||||
|
import com.tencent.cloud.common.metadata.MetadataContextHolder;
|
||||||
|
|
||||||
|
import org.springframework.cloud.client.ServiceInstance;
|
||||||
|
import org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerClientRequestTransformer;
|
||||||
|
import org.springframework.web.reactive.function.client.ClientRequest;
|
||||||
|
|
||||||
|
public class PolarisLoadBalancerClientRequestTransformer implements LoadBalancerClientRequestTransformer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClientRequest transformRequest(ClientRequest request, ServiceInstance instance) {
|
||||||
|
if (instance != null) {
|
||||||
|
MetadataContextHolder.get().setLoadbalancer(HeaderConstant.INTERNAL_CALLEE_SERVICE_ID, instance.getServiceId());
|
||||||
|
}
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue