Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a doc comment for PollUntilDone() freq arg #719

Merged
merged 3 commits into from
Oct 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/generator/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function generateResponses(session: Session<CodeModel>): Promise<st
for (const respEnv of values(responseEnvelopes)) {
const respType = generateStruct(imports, respEnv.language.go!, respEnv.properties);
if (respEnv.language.go!.isLRO) {
generatePollUntilDoneForResponse(respType);
generatePollUntilDoneForResponse(respType, <boolean>session.model.language.go!.azureARM);
generateResumeForResponse(respType, session.model.language.go!.openApiType === 'arm', imports);
}
structs.push(respType);
Expand Down Expand Up @@ -91,7 +91,7 @@ function generateUnmarshallerForResultEnvelope(structDef: StructDef) {
structDef.Methods.push({ name: 'UnmarshalJSON', desc: `UnmarshalJSON implements the json.Unmarshaller interface for type ${structDef.Language.name}.`, text: unmarshaller });
}

function generatePollUntilDoneForResponse(structDef: StructDef) {
function generatePollUntilDoneForResponse(structDef: StructDef, isAzureARM: boolean) {
const pagedResponse = (<PollerInfo>structDef.Language.pollerInfo).op.language.go!.pageableType;
const respType = getResponseType(<PollerInfo>structDef.Language.pollerInfo);
let pollUntilDone = `func (l ${structDef.Language.name}) PollUntilDone(ctx context.Context, freq time.Duration) (`;
Expand Down Expand Up @@ -129,7 +129,14 @@ function generatePollUntilDoneForResponse(structDef: StructDef) {
}
pollUntilDone += '\treturn respType, nil\n';
pollUntilDone += '}\n\n';
structDef.Methods.push({ name: 'PollUntilDone', desc: 'PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received.', text: pollUntilDone });
let desc = 'PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received.\nfreq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second.';
if (isAzureARM) {
desc += '\nA good starting value is 30 seconds. Note that some resources might benefit from a different value.';
}
structDef.Methods.push({
name: 'PollUntilDone',
desc: desc,
text: pollUntilDone });
}

function generateResumeForResponse(structDef: StructDef, isARM: boolean, imports: ImportManager) {
Expand Down
79 changes: 79 additions & 0 deletions test/autorest/lrogroup/zz_generated_response_types.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions test/autorest/paginggroup/zz_generated_response_types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

178 changes: 178 additions & 0 deletions test/compute/2019-12-01/armcompute/zz_generated_response_types.go

Large diffs are not rendered by default.

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions test/keyvault/7.2/azkeyvault/zz_generated_response_types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading