Conversation
f246196 to
1885bb8
Compare
1885bb8 to
542f6e7
Compare
542f6e7 to
6f00489
Compare
6f00489 to
296ed15
Compare
296ed15 to
bbc408e
Compare
bbc408e to
c8c1e06
Compare
c8c1e06 to
c41b295
Compare
c41b295 to
63a3b57
Compare
63a3b57 to
f014476
Compare
f014476 to
46d6fdf
Compare
46d6fdf to
2525926
Compare
2525926 to
2f42f31
Compare
2f42f31 to
15511ad
Compare
| new HttpJsonServiceResumableUploadStubClassComposer(); | ||
|
|
||
| private static final Statement EMPTY_LINE_STATEMENT = EmptyLineStatement.create(); | ||
| private static final String RESUMABLE_UPLOAD_PATH_PREFIX = "resumable/upload"; |
There was a problem hiding this comment.
Is this hardcoded for Ads/Showcase?
There was a problem hiding this comment.
For this milestone the prefix is hardcoded. The requirement is to make it configurable in the next milestone.
| import org.jspecify.annotations.NullMarked; | ||
|
|
||
| @NullMarked | ||
| public class HttpJsonServiceResumableUploadStubClassComposer implements ClassComposer { |
There was a problem hiding this comment.
Is it possible to extend from AbstractTransportServiceStubClassComposer? Generation logics for methods like close, shutdown should be able to be reused.
There was a problem hiding this comment.
I ended up extracting the shared functionality to a common helper. Extending AbstractTransportServiceStubClassComposer seemed like an awkward fit because it's intended to generate the entire service stub (including stuff for LROs, pagination, etc.) whereas this stub is a much more narrow scope.
| public class HttpJsonResumableUploadServiceResumableUploadStub implements BackgroundResource { | ||
| private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); | ||
|
|
||
| private static final ApiMethodDescriptor<UploadMediaRequest, UploadMediaResponse> |
There was a problem hiding this comment.
IIRC, the ApiMethodDescriptor here is only used for startUpload?
There was a problem hiding this comment.
It's mostly for startUpload, though the response parser is used for the other resumable upload commands.
ec75b25 to
f772f86
Compare
| */ | ||
| public static HttpJsonResumableUploadServiceResumableUploadStub createFrom( | ||
| ClientContext clientContext, ResumableUploadServiceStubSettings settings) { | ||
| String uploadEndpoint = |
There was a problem hiding this comment.
Maybe create a new clientContext using ClientContext.create(settings)? So we don't have to manually re-create the clientContext from existing clientContext?
There was a problem hiding this comment.
After more investigation, I think ClientContext.create(settings) should work for httpjson stub without any issues. For grpc stub, we need to recreate the settings with a default internal header provider and httpjson channel, then ClientContext.create(settings) should work.
There was a problem hiding this comment.
Hmmm, I guess I'm not seeing how calling ClientContext.create(settings) inside the upload stub without referencing the parent context can avoid at least two main issues:
- for both transports, in the top-level stub layer's
create(ClientContext)factory overload,settingsis just<Service>StubSettings.newBuilder().build(), so if we re-create fromsettingsthen everything caller-supplied on theClientContextis dropped. We'd also be creating a separate thread pool and doing another ADC lookup on every client instance (even on REST stubs that already built an HTTPClientContext- this I guess isn't functionally a problem, just suboptimal). - we can't swap the gRPC internal headers (
x-goog-api-client: ... grpc/...) for HTTP headers viasettings.toBuilder()becauseStubSettings.Builder#setInternalHeaderProviderisprotectedand in a different package (unless you think it's worth widening it for this, but the above issue still seems like a blocker alone)
| * settings. This is protected so that it is easy to make a subclass, but otherwise, the static | ||
| * factory methods should be preferred. | ||
| */ | ||
| protected HttpJsonResumableUploadServiceResumableUploadStub( |
There was a problem hiding this comment.
We have three constructor/factory methods that have the same arguments, consider consolidate them.
There was a problem hiding this comment.
Modified this to have one private constructor and one factory method (which has a conditional to adapt for gRPC v. HTTP/JSON).
57daa1f to
954089e
Compare
| } | ||
|
|
||
| @InternalApi | ||
| public static List<ApiMethodDescriptor> getMethodDescriptors() { |
There was a problem hiding this comment.
Do we need this public method? I think this is only used in tests and we don't have to generate unit tests anymore.
There was a problem hiding this comment.
Doesn't look like it's necessary - removed.
There was a problem hiding this comment.
I don't think we need unit tests for these composers unless we think there are logics that are hard to test with goldens.
There was a problem hiding this comment.
Seems reasonable, removed.
| RetrySettings settings = null; | ||
| settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build(); | ||
| definitions.put("no_retry_params", settings); | ||
| RETRY_PARAM_DEFINITIONS = definitions.build(); |
There was a problem hiding this comment.
The retry settings are not used currently, we need to add the initial unary call settings to ResumableUploadCallSettings. I'll work on it in a separate PR.
Adds generator support for protocol-specific resumable upload options, independent of any transport stub wiring: - Emit ResumableUploadCallSettings on the generated <Service>Settings and <Service>StubSettings, populated with global timeouts extracted from the service config while bypassing standard unary retries. - Add HttpJsonServiceResumableUploadStubClassComposer, which generates the dedicated REST stub (HttpJson[Service]ResumableUploadStub) for services containing resumable upload RPC methods. - Extract HttpJsonDescriptorComposer out of HttpJsonServiceStubClassComposer and add path prefix support. Pure refactor with no golden changes, reused by the upload stub composer above. Supersedes #14318 and #14320, which are folded in here.
954089e to
5821e21
Compare
|
|



Modified and introduces composers to emit an internal, dedicated REST stub and settings for resumable upload-powered services