Skip to content

Commit

Permalink
refactor:update polaris mock server.
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyeBeFreeman committed Dec 12, 2024
1 parent 16a42a1 commit 9cd901f
Showing 1 changed file with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import com.tencent.polaris.specification.api.v1.fault.tolerance.CircuitBreakerProto;
import com.tencent.polaris.specification.api.v1.fault.tolerance.CircuitBreakerProto.CircuitBreaker;
import com.tencent.polaris.specification.api.v1.fault.tolerance.FaultDetectorProto;
import com.tencent.polaris.specification.api.v1.fault.tolerance.FaultDetectorProto.FaultDetectRule;
import com.tencent.polaris.specification.api.v1.model.ModelProto;
import com.tencent.polaris.specification.api.v1.model.ModelProto.Location;
import com.tencent.polaris.specification.api.v1.service.manage.ClientProto.Client;
Expand All @@ -45,16 +44,11 @@
import com.tencent.polaris.specification.api.v1.traffic.manage.RateLimitProto.RateLimit;
import com.tencent.polaris.specification.api.v1.traffic.manage.RoutingProto;
import io.grpc.stub.StreamObserver;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

public class NamingService extends PolarisGRPCGrpc.PolarisGRPCImplBase {

private static final Logger LOG = LoggerFactory.getLogger(NamingService.class);
Expand Down Expand Up @@ -205,7 +199,7 @@ public void addInstance(ServiceKey svcKey, Node node, InstanceParameter paramete
/**
* 批量增加服务实例
*
* @param svcKey 服务名
* @param svcKey 服务名
* @param portStart 起始端口
* @param instCount 实例数
* @param parameter 实例参数
Expand Down Expand Up @@ -259,7 +253,7 @@ public void setInstanceHealthyStatus(

@Override
public void registerInstance(ServiceProto.Instance request,
StreamObserver<ResponseProto.Response> responseObserver) {
StreamObserver<ResponseProto.Response> responseObserver) {
ServiceKey serviceKey = new ServiceKey(request.getNamespace().getValue(), request.getService().getValue());
if (!services.containsKey(serviceKey)) {
services.put(serviceKey, new ArrayList<ServiceProto.Instance>());
Expand Down Expand Up @@ -306,7 +300,7 @@ private ResponseProto.Response buildResponse(int code, String info, ServiceProto

@Override
public void deregisterInstance(ServiceProto.Instance request,
StreamObserver<ResponseProto.Response> responseObserver) {
StreamObserver<ResponseProto.Response> responseObserver) {
ServiceKey serviceKey = new ServiceKey(request.getNamespace().getValue(), request.getService().getValue());
if (!services.containsKey(serviceKey)) {
responseObserver.onNext(
Expand Down Expand Up @@ -450,6 +444,10 @@ private ResponseProto.DiscoverResponse buildServiceResponse(
break;
case LANE:
builder.setType(DiscoverResponseType.LANE);
case LOSSLESS:
builder.setType(DiscoverResponseType.LOSSLESS);
case BLOCK_ALLOW_RULE:
builder.setType(DiscoverResponseType.BLOCK_ALLOW_RULE);
case UNRECOGNIZED:
break;
default:
Expand Down

0 comments on commit 9cd901f

Please sign in to comment.