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
/** | |
* Adaptor for Grpc which does all the translation from generic uber types to grpc entities and | |
* places the call to a grpc ManagedChannel. This class manages multiple channels and routes new | |
* calls based on host fetched from UberInternalCallOptions. | |
*/ | |
public class UbergRPCAdaptor implements UberChannel { | |
private static final Logger LOGGER = Logger.getLogger(UbergRPCAdaptor.class.getName()); | |
// static variable singleInstance of type Singleton |
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
/** | |
* Call router interceptor which routes calls to corresponding transport adaptors. | |
* | |
* @param <ReqT> request msg of generic type ReqT. | |
* @param <RespT> response msg of generic type RespT. | |
* @param <T> methodInfo of generic type T. | |
*/ | |
public class UberCallRouterInterceptor<ReqT, RespT, T> extends UberInterceptor<ReqT, RespT, T> { | |
// Adaptors will the next in the chain of interceptors. |
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
/** | |
* A virtual connection to a conceptual endpoint, to perform RPCs. A channel is free to have zero or | |
* many actual connections to the endpoint based on configuration, load, etc. A channel is also free | |
* to determine which actual endpoints to use and may change it every RPC, permitting client-side | |
* load balancing. Applications are generally expected to use stubs instead of calling this class | |
* directly. | |
* | |
* <p>Every new request will return an instance of {@link UberClientCall} and all further | |
* processing, monitoring, manipulations are done with the UberClientCall instance. | |
* |
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
public class UberClientCall<ReqT, RespT> { | |
@Nullable private ClientCall<ReqT, RespT> delegate; | |
public UberClientCall() {} | |
public UberClientCall(ClientCall<ReqT, RespT> delegate) { | |
this.delegate = delegate; | |
} |
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; |
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
/** | |
* Generic interface to represent MethodInfo fo type <T>. Used to hold method info like url path, | |
* call type etc. | |
* | |
* @param <T> | |
*/ | |
public interface MethodInfo<T> { | |
/** @return the methodInfo object as is. */ | |
T getTransportMethodInfo(); |
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
/** | |
* Interface representing Request/Response headers. This is a common interface for all network | |
* transports and each transport is expected to have its own implementation. | |
* | |
* @param <T> represents the actual transport header object of generic type T. | |
*/ | |
public interface UberCallHeaders<T> { | |
/** | |
* Fetch value corresponding to the given key. |
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
/** | |
* Interface representing Request's final status. This is a common interface for all network | |
* transports and each transport is expected to have its own implementation. | |
* | |
* @param <T> represents the actual Status object of generic type T. | |
*/ | |
public interface UberRequestStatus<T> { | |
/** | |
* Refers to the Http status code. |
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
/** | |
* Callbacks for receiving headers, response messages and completion status from the server. | |
* | |
* <p>Implementations are free to block for extended periods of time. Implementations are not | |
* required to be thread-safe. | |
* | |
* <p>This exactly mimics {@link io.grpc.ClientCall.Listener} with Uber specific entities. This will | |
* also act as a wrapper for grpc's {@link ClientCall.Listener} in Adaptor/ grpc translations | |
* layers. | |
* |
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
/** | |
* UberInterceptor interface is synonymous to {@link UberClientCall}. This class extends {@link | |
* UberClientCall} and lends way for developers for easy interceptor development. Every new grpc | |
* call by the client/application, will result in creating a new chain of interceptors and so each | |
* instance of an interceptor deals with only one grpc call in its lifetime. Any synchronization | |
* across different calls needs to be abstracted out to a different class and all interceptor copies | |
* will be accessing the a single instance of such class. For eg: Failover module. | |
* | |
* @param <ReqT> request msg of generic type RequestT. | |
* @param <RespT> response msg of generic type RequestT. |