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

ClientModel: Add retry classification to MessageClassifier #41586

Merged
merged 6 commits into from
Jan 26, 2024

Conversation

annelo-msft
Copy link
Member

@annelo-msft annelo-msft commented Jan 25, 2024

This PR changes the API for PipelineResponseClassifier in two ways:

  • It makes error classification composable with other classifiers
  • It adds retry classification in a way that it is also composable with other classifiers

Since we had previously put default retry classification in the ClientRetryPolicy, this is removed in favor of using the classifier on the message.

Addresses #41465

@azure-sdk
Copy link
Collaborator

API change check

APIView has identified API level changes in this PR and created following API reviews.

System.ClientModel

ChainingClassifier classifier = new ChainingClassifier(last);
classifier.AddClassifier(new RetriableStatusCodeClassifier(429, isRetriable: false));
classifier.AddClassifier(new ErrorStatusCodeClassifier(404, isError: false));
classifier.AddClassifier(new ErrorStatusCodeClassifier(201, isError: true));
Copy link
Member Author

Choose a reason for hiding this comment

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

With the new API, we can create a classifier that composes retry and error classifiers in a chain.


message.SetResponse(new MockPipelineResponse(200));
Assert.IsTrue(classifier.TryClassify(message, out bool isError));
Assert.IsTrue(classifier.TryClassify(message, exception: default, out bool isRetriable));
Copy link
Member Author

Choose a reason for hiding this comment

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

ClientModel pipeline policies will call these APIs to determine if a response is an error response, or a response is retriable, as shown here.

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.

4 participants