Created
August 21, 2020 14:06
-
-
Save nsivabalan/48b25de5d86e22fa903a78ef3acbbbf2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Grpc's implementation of {@link MethodInfo}. | |
* | |
* @param <ReqT> reqeust object of generic Type ReqT. | |
* @param <RespT> response object of generic Type RespT. | |
*/ | |
public class GrpcMethodInfo<ReqT, RespT> implements MethodInfo<MethodDescriptor> { | |
private MethodDescriptor<ReqT, RespT> methodDescriptor; | |
private MethodType methodType; | |
public GrpcMethodInfo(MethodDescriptor<ReqT, RespT> methodDescriptor) { | |
Preconditions.checkNotNull( | |
methodDescriptor, new IllegalArgumentException("MethodDescriptor cannot be null")); | |
this.methodDescriptor = methodDescriptor; | |
this.methodType = getMethodTypeInternal(methodDescriptor.getType()); | |
} | |
@Override | |
public MethodDescriptor getTransportMethodInfo() { | |
return methodDescriptor; | |
} | |
@Override | |
@Nullable | |
public String getUrlPath() { | |
return methodDescriptor.getFullMethodName(); | |
} | |
@Override | |
@Nullable | |
public String getServiceName() { | |
return methodDescriptor.getServiceName(); | |
} | |
@Override | |
public boolean isUnary() { | |
return methodDescriptor.getType() == io.grpc.MethodDescriptor.MethodType.UNARY; | |
} | |
@Override | |
public MethodType getMethodType() { | |
return methodType; | |
} | |
@Override | |
public boolean isIdempotent() { | |
return methodDescriptor.isIdempotent(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment