msgraph-sdk-go-core icon indicating copy to clipboard operation
msgraph-sdk-go-core copied to clipboard

Customize retry Handler Middleware

Open ritu-rubrik opened this issue 1 year ago • 1 comments

Currently while using middlewate I use this code to get the default lit of middlewares. defaultClientOptions := msgraph.GetDefaultClientOptions() defaultMiddleWare := msgraphgocore.GetDefaultMiddlewaresWithOptions(&defaultClientOptions)

However, I am not sure how to override the Retry handler alone in this list of middlewares.

Looking for an example to do this/

ritu-rubrik avatar Jul 18 '24 18:07 ritu-rubrik

Hi @ritu-rubrik, thanks for trying out the SDK. If you would like to override the Retry handler, you are able to do it when executing the command i.e here is an example. You will only need to provide the retry option in the request configuration

	retryHandlerOptions := nethttplibrary.RetryHandlerOptions{
		ShouldRetry: func(delay time.Duration, executionCount int, request *http.Request, response *http.Response) bool {
			return false
		},
	}
	
	opts := applications.ApplicationsRequestBuilderGetRequestConfiguration{
		QueryParameters: &applications.ApplicationsRequestBuilderGetQueryParameters{
			Select: []string{"displayName", "appId", "id", "keyCredentials", "passwordCredentials"},
			Top:    to.Ptr[int32](100),
		},
		Options: []abstractions.RequestOption{&retryHandlerOptions},
	}

rkodev avatar Aug 12 '24 10:08 rkodev

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.