Skip to content

Commit

Permalink
Improve performance
Browse files Browse the repository at this point in the history
  • Loading branch information
hexiaofeng committed Jan 27, 2025
1 parent 273082d commit 979c55f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
import com.jd.live.agent.governance.policy.service.live.UnitPolicy;
import com.jd.live.agent.governance.policy.service.loadbalance.LoadBalancePolicy;
import com.jd.live.agent.governance.policy.service.loadbalance.StickyType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

/**
* The {@code ServiceMetadata} class encapsulates the metadata for a service request.
*/
@Getter
@AllArgsConstructor
@Builder
public class ServiceMetadata {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.jd.live.agent.governance.request.HttpRequest;
import com.jd.live.agent.governance.request.ServiceRequest;

import java.util.HashMap;
import java.util.Map;

import static com.jd.live.agent.governance.policy.PolicyId.KEY_SERVICE_GROUP;
Expand Down Expand Up @@ -80,25 +81,15 @@ public ServiceMetadata parse() {
String method = parseMethod();
ServicePolicy servicePolicy = parseServicePolicy(service, serviceGroup, path, method);
boolean writeProtect = parseWriteProtect(servicePolicy);
URI uri = URI.builder().host(serviceName).path(path).build();

Map<String, String> parameters = new HashMap<>(4);
parameters.put(KEY_SERVICE_METHOD, method);
if (serviceGroup != null && !serviceGroup.isEmpty()) {
uri = uri.parameters(KEY_SERVICE_GROUP, serviceGroup, KEY_SERVICE_METHOD, method);
} else {
uri = uri.parameters(KEY_SERVICE_METHOD, method);
parameters.put(KEY_SERVICE_GROUP, serviceGroup);
}
URI uri = new URI(null, serviceName, null, path, parameters);

return ServiceMetadata.builder().
consumer(consumer).
serviceConfig(serviceConfig).
serviceName(serviceName).
serviceGroup(serviceGroup).
path(path).
method(method).
service(service).
uri(uri).
servicePolicy(servicePolicy).
writeProtect(writeProtect).
build();
return new ServiceMetadata(serviceConfig, serviceName, serviceGroup, path, method, writeProtect, service, consumer, servicePolicy, uri);
}

/**
Expand Down

0 comments on commit 979c55f

Please sign in to comment.