Skip to content

Instantly share code, notes, and snippets.

@nsivabalan
Last active July 15, 2020 15:42
Show Gist options
  • Select an option

  • Save nsivabalan/d32c2f867f0e11b32f49b6d0e8cb0fef to your computer and use it in GitHub Desktop.

Select an option

Save nsivabalan/d32c2f867f0e11b32f49b6d0e8cb0fef to your computer and use it in GitHub Desktop.
/**
* Interface for client side UberInterceptor at mobile networking layer
* @param <ReqT> request object of generic type.
* @param <RespT> response object of generic type.
*/
public abstract class UberInterceptor<ReqT, RespT> {
/**
* Fetch MethodInfo for the call in flux.
* @param <T> type of MethodInfo
* @return the instance of MethodInfo
*/
public abstract <T> T getMethodInfo();
/**
* Invoked with outgoing request headers.
* @param requestHeaders request headers that are sent as part of the request.
*/
protected abstract void onRequestHeaders(UberCallHeaders requestHeaders);
/**
* Invoked when a message is sent out from client to server.
* @param message message being sent out.
*/
protected abstract void onRequestMessage(ReqT message);
/**
* Invoked with response headers.
* @param responseHeaders response headers that are received from the server.
*/
protected abstract void onResponseHeaders(UberCallHeaders responseHeaders);
/**
* Invoked with message received from the server.
* @param msg message being received.
*/
protected abstract void onResponseMessage(RespT msg);
/**
* Invoked when the call is completes
* @param status instance of UberNetworkRequestStatus with final status of the request/call.
* @param trailers final set of headers if any.
*/
protected void onClose(UberNetworkRequestStatus status, UberCallHeaders trailers) {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment