Skip to content

Commit

Permalink
Optimized code linkis rpc module
Browse files Browse the repository at this point in the history
  • Loading branch information
ChengJie1053 committed Nov 21, 2023
1 parent 7935cde commit edf866d
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 183 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ import java.util
import scala.concurrent.duration.Duration
import scala.runtime.BoxedUnit

import feign.{Feign, Retryer}

private[rpc] class BaseRPCSender extends Sender with Logging {
private var name: String = _
private var rpc: RPCReceiveRemote = _
Expand Down Expand Up @@ -76,9 +74,6 @@ private[rpc] class BaseRPCSender extends Sender with Logging {

private[rpc] def getApplicationName = name

protected def doBuilder(builder: Feign.Builder): Unit =
builder.retryer(Retryer.NEVER_RETRY)

protected def newRPC: RPCReceiveRemote = {
getDynamicFeignClient.getFeignClient(classOf[RPCReceiveRemote], name)
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,18 @@
package org.apache.linkis.rpc.sender

import org.apache.linkis.common.ServiceInstance
import org.apache.linkis.common.conf.{Configuration => DWCConfiguration}
import org.apache.linkis.rpc.{BaseRPCSender, RPCMessageEvent, RPCSpringBeanCache}
import org.apache.linkis.rpc.interceptor.{RPCInterceptor, ServiceInstanceRPCInterceptorChain}

import org.apache.commons.lang3.StringUtils

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.cloud.client.loadbalancer.LoadBalancerClientsProperties
import org.springframework.cloud.loadbalancer.blocking.client.BlockingLoadBalancerClient
import org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient
import org.springframework.core.env.Environment

import feign._

private[rpc] class SpringMVCRPCSender private[rpc] (
private[rpc] val serviceInstance: ServiceInstance
) extends BaseRPCSender(serviceInstance.getApplicationName) {

import SpringCloudFeignConfigurationCache._

override protected def getRPCInterceptors: Array[RPCInterceptor] =
RPCSpringBeanCache.getRPCInterceptors

Expand All @@ -47,31 +39,6 @@ private[rpc] class SpringMVCRPCSender private[rpc] (
@Autowired
private var env: Environment = _

override protected def doBuilder(builder: Feign.Builder): Unit = {
val client = getClient.asInstanceOf[FeignBlockingLoadBalancerClient]
val loadBalancerClientFactory =
new LinkisLoadBalancerClientFactory(serviceInstance, new LoadBalancerClientsProperties)

val blockingLoadBalancerClient: BlockingLoadBalancerClient = new BlockingLoadBalancerClient(
loadBalancerClientFactory
)

val newClient = new FeignBlockingLoadBalancerClient(
client.getDelegate,
blockingLoadBalancerClient,
// getLoadBalancedRetryFactory,
loadBalancerClientFactory
)

super.doBuilder(builder)
builder
.contract(getContract)
.encoder(getEncoder)
.decoder(getDecoder)
.client(newClient)
.requestInterceptor(getRPCTicketIdRequestInterceptor)
}

/**
* Deliver is an asynchronous method that requests the target microservice asynchronously,
* ensuring that the target microservice is requested once, but does not guarantee that the target
Expand Down

0 comments on commit edf866d

Please sign in to comment.