feat(gax): add ResumableUploadCallable and ResumableUploadCallSettings - #14052
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the ResumableUploadCallSettings and ResumableUploadCallable classes to support transport-independent resumable uploads, along with associated unit tests. The review feedback suggests adding input validation to ensure chunkSize is positive and totalBytes is non-negative, as well as removing several redundant null casts in the overloaded call and futureCall methods to clean up the code.
| public ApiFuture<ResponseT> futureCall(RequestT request, InputStream payload) { | ||
| return futureCall( | ||
| request, payload, (ResumableUploadCallSettings<RequestT, ResponseT>) null, (ApiCallContext) null); | ||
| } |
There was a problem hiding this comment.
The casts (ResumableUploadCallSettings<RequestT, ResponseT>) null and (ApiCallContext) null are redundant because there is only one 4-argument overload of futureCall. Removing them simplifies the code and improves readability.
public ApiFuture<ResponseT> futureCall(RequestT request, InputStream payload) {
return futureCall(request, payload, null, null);
}c52d225 to
2cf5521
Compare
There was a problem hiding this comment.
Do we want to also provide a version that accepts something like a supplier/provider of InputStream?
An addition could probably be in a subsequent PR but I'm curious what your thinking is on the concept. IIUC, since most InputStream implementations aren't seekable/resetable (this notably includes FileInputStream) this could be useful for error recovery.
There was a problem hiding this comment.
Do we want to also provide a version that accepts something like a supplier/provider of InputStream?
I think it is a good idea. But I would prefer to use the native InputStream if it already meets all the use cases.
Regarding seek-ability, FileInputStream does support skipping over bytes? It does not support resetting but I don't think we need to reset a stream either?
There was a problem hiding this comment.
I think you're right - since we'll be buffering each chunk until complete receipt is confirmed by the server we shouldn't need to rewind or reset. So skip-ability should suffice.
21df0c9 to
742f627
Compare
…sumableUploadCallSettings Add ResumableUploadFuture interface for active upload session URL tracking and cancellation. Update ResumableUploadCallable to return ResumableUploadFuture and include resumeCall(sessionUrl, payload, settings).
742f627 to
04f55d0
Compare
Description
This PR introduces the foundational GAX Public API surface for HTTP/JSON resumable uploads.
Changes
futureCall(request, payload, settings)andresumeCall(sessionUrl, payload, settings)returningResumableUploadFuture<ResponseT>.ApiFuture<ResponseT>interface for active session inspection (getUploadSessionUrl()) and cancellation control.@AutoValueconfiguration class withmerge(other)method andchunkSize = 8MBdefault.merge(other)overrides.