Skip to content

Consider making Polly easier to consume from F# and Visual Basic #2061

@martincostello

Description

@martincostello

Following on from #2045 and #2046, we should consider whether it is worth adding some convenience APIs to make the use of Polly.Core's asynchronous common-case public members easier to consume in F# and VisualBasic where ValueTask/ValueTask<T> cannot be awaited.

For example, we could create a new Polly.Interop (or better named) extension package that exposes extension methods for types such as ResiliencePipeline that add Task-based overloads that wrap the usage of ValueTask from the caller, at the expense of additional allocations/performance overhead.

namespace Polly.Core;

public static class ResiliencePipelineExtensions
{
    public static Task<TResult> ExecuteAsync<TResult>(
        this ResiliencePipeline pipeline,
        Func<ResilienceContext, Task<TResult>> callback,
        ResilienceContext context)
        => pipeline.ExecuteAsync((context) => new ValueTask<TResult>(callback(context)), context).AsTask();
}

We may ultimately decide to do nothing and instead rely on documentation to help users of F# and VisualBasic consume Polly.Core APIs as they already are in version 8+.

This issue to is to collect feedback on whether people think this is worth doing, and an issue to point to decision making if we elect not to add such convenience APIs.

Appetite for this may be minimal given that it has taken 6 months for us to become aware of this usability issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions