Ocelot icon indicating copy to clipboard operation
Ocelot copied to clipboard

#1844 More open customization of Polly use

Open RaynaldM opened this issue 1 year ago • 4 comments

In certain contexts, we need to be able to fully tune the way Polly is used for timeouts and circuit-breakers, but not only that. With this in mind, I'm proposing in this PR to open up the use of AddPolly by adding :

public static IOcelotBuilder AddPolly<T>(this IOcelotBuilder builder, Dictionary<Type, Func<Exception, Error>> errorMapping)
     where T : class, IPollyQoSProvider<HttpResponseMessage> =>
     AddPolly<T>(builder, GetDelegatingHandler, errorMapping);

 public static IOcelotBuilder AddPolly<T>(this IOcelotBuilder builder, QosDelegatingHandlerDelegate delegatingHandler)
     where T : class, IPollyQoSProvider<HttpResponseMessage> =>
     AddPolly<T>(builder, delegatingHandler, ErrorMapping);

 public static IOcelotBuilder AddPolly<T>(this IOcelotBuilder builder)
     where T : class, IPollyQoSProvider<HttpResponseMessage> =>
     AddPolly<T>(builder, GetDelegatingHandler, ErrorMapping);

Thanks to this, we will be able to use our own implementations of IPollyQoSProvider<HttpResponseMessage>, QosDelegatingHandlerDelegate and Dictionary<Type, Func<Exception, Error>>

RaynaldM avatar Dec 07 '23 14:12 RaynaldM

@ggnaegi FYI Easy to review, but it is marked for Dec'23 release...

raman-m avatar Dec 11 '23 10:12 raman-m

@RaynaldM Thanks for the PR! New extensions will be useful. Why not to test them somehow?

raman-m avatar Dec 11 '23 10:12 raman-m

@ggnaegi Please review!

raman-m avatar Feb 17 '24 13:02 raman-m

But the build is still 🔴

raman-m avatar Feb 19 '24 11:02 raman-m

@RaynaldM Is your development finished here?

raman-m avatar Feb 23 '24 10:02 raman-m

🤕

raman-m avatar Feb 23 '24 10:02 raman-m

If you love to press GitHub buttons then I'm letting you to finish your PR. Please fix compilation errors!

raman-m avatar Feb 23 '24 10:02 raman-m

My understanding this PR should be merged first before #1914 ... right?

raman-m avatar Feb 23 '24 10:02 raman-m

My understanding this PR should be merged first before #1914 ... right?

Exactly, it is an intermediate step

RaynaldM avatar Feb 23 '24 11:02 RaynaldM