-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
ClientModel: Add retry classification to MessageClassifier #41586
Conversation
API change check APIView has identified API level changes in this PR and created following API reviews. |
sdk/core/System.ClientModel/src/Options/PipelineMessageClassifier.cs
Outdated
Show resolved
Hide resolved
sdk/core/System.ClientModel/src/Options/PipelineMessageClassifier.cs
Outdated
Show resolved
Hide resolved
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)); |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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.
This PR changes the API for PipelineResponseClassifier in two ways:
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