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

[core-lro] proof-of-concept for https://github.com/Azure/azure-sdk-for-js/issues/32142 #6

Draft
wants to merge 2 commits into
base: keyvault-admin-typespec
Choose a base branch
from

Conversation

maorleger
Copy link
Owner

Wanted to get some early feedback on the approach for resolving Azure#32142 from the core-lro experts. This PR demonstrates the idea behind providing the option to skip the final leg of the LRO where the resource location is used to GET the final resource.

background information:

@@ -19,6 +19,7 @@ export interface CreateHttpPollerOptions<TResult, TState> {
resolveOnUnsuccessful?: boolean;
resourceLocationConfig?: ResourceLocationConfig;
restoreFrom?: string;
skipFinalGet?: boolean;
Copy link
Owner Author

@maorleger maorleger Jan 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name TBD: any suggestions? skipFinalGet seems pretty specific. Other options might be

  • withoutResourceLocation
  • skipResourceLocation

or something else - feel free to chime in. Thoughts?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name could be unclear for someone who is not too familiar with how our pollers work. Could we name it based on impact instead? e.g. noResourceRetrieval. I also wonder if other languages have a similar flag and what name did they choose for it.

Copy link
Owner Author

@maorleger maorleger Jan 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skipResourceLocation or skipGetResource maybe? Would that make sense? I don't have a good domain understanding of the LRO concepts so I am just brainstorming names 👍 feels like resourceLocation is a known term in LROs?

Copy link

@MaryGao MaryGao Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I even prefer the specific name skipFinalGet here, because for me LRO would be three steps: initial -> polling -> final get(optional) and the main purpose of this option is to always skip the final step. I guess this would be clear with someone who knows LRO.

My concern for ResourceRetrieval is - skipping the final get doesn't mean we will not retrieve the resources, for example maybe the resource is directly returned from the initial request or non-standard LRO returns the resources directly from polling process?

But open to hear feedbacks also.

@@ -49,6 +51,10 @@ export function createHttpPoller<TResult, TState extends OperationState<TResult>
init: async () => {
const response = await lro.sendInitialRequest();
const config = inferLroMode(response.rawResponse, resourceLocationConfig);
if (skipFinalGet && config?.resourceLocation) {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will end up moving into inferLroMode so we are not setting config then overriding it. The proof-of-concept just touches as little code as possible

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change works for me. And I was also thinking of that this could also work in the resumeFrom case.

nit: should we put this logic into inferLroMode?

@@ -286,6 +287,7 @@ export class KeyVaultBackupClient {
onResponse: options.onResponse,
tracingOptions: options.tracingOptions,
updateIntervalInMs: options.intervalInMs,
skipFinalGet: true,
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The KeyVault backup client will use this parameter to suppress the final GET

if ((httpPoller.operationState as any)?.config?.resourceLocation) {
(httpPoller.operationState as any).config.resourceLocation = undefined;
}
// if ((httpPoller.operationState as any)?.config?.resourceLocation) {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't be needed anymore

@@ -110,6 +114,7 @@ export function getLongRunningPoller<
processResult: (result: unknown) => {
return processResponseBody(result as TResponse);
},
skipFinalGet: options?.skipFinalGet
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need to get codegen'd in all cases

@@ -19,6 +19,7 @@ export interface CreateHttpPollerOptions<TResult, TState> {
resolveOnUnsuccessful?: boolean;
resourceLocationConfig?: ResourceLocationConfig;
restoreFrom?: string;
skipFinalGet?: boolean;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name could be unclear for someone who is not too familiar with how our pollers work. Could we name it based on impact instead? e.g. noResourceRetrieval. I also wonder if other languages have a similar flag and what name did they choose for it.

@maorleger maorleger force-pushed the keyvault-admin-typespec branch 2 times, most recently from bef0e52 to f71b88c Compare January 16, 2025 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants