Coder Social home page Coder Social logo

Comments (4)

MihaZupan avatar MihaZupan commented on June 9, 2024 1

We have a general issue to track traffic mirroring (#105), but that is mainly about duplicating outgoing requests and potentially performing validation on different responses. The forwarded response still comes from a single destination.

Splitting requests and then merging responses like in your scenario is bound to involve custom logic to specify how requests are generated, how merging should work, what policies to use for some failed/delayed responses, etc. I'm not aware of an established practice that one would follow here.
Given the highly custom nature of such scenarios (and limited examples of different users doing so), I don't think we should be trying to design an abstraction here, as it's not clear what benefits it would provide.

Closing this issue as wont-fix, but we can of course revisit the decision in the future if there's more user demand and we believe we can provide value.

from reverse-proxy.

danielmarbach avatar danielmarbach commented on June 9, 2024 1

Absolutely agree with the reasoning. Thanks for taking the time to reply

from reverse-proxy.

MihaZupan avatar MihaZupan commented on June 9, 2024

For a scatter scenario, would you want to send anything other than GET requests?

If you want to create new scatter requests, all that is involved is along the lines of

async Task<HttpRequestMessage> CreateScatterRequestAsync(HttpContext context, string destinationPrefix, CancellationToken cancellationToken = default)
{
    if (context.Request.Method != HttpMethods.Get || context.WebSockets.IsWebSocketRequest)
    {
        throw new NotSupportedException("...");
    }

    var request = new HttpRequestMessage
    {
        Method = HttpMethod.Get,
        Version = HttpVersion.Version20,
        VersionPolicy = HttpVersionPolicy.RequestVersionOrLower
    };

    await ScatterTransformer.Instance.TransformRequestAsync(context, request, destinationPrefix, cancellationToken);

    // If you're not setting it in your transformer already
    request.RequestUri ??= RequestUtilities.MakeDestinationAddress(destinationPrefix, context.Request.Path, context.Request.QueryString);

    return request;
}

Most of the YARP logic around creating requests is around handling things like WebSocket version upgrades/downgrades and dealing with a custom HttpContent for POST requests.

In practice the above example is just setting the Method & Version, then calling the transformer. I'm not sure that is all that helpful / generic enough to have in YARP.

from reverse-proxy.

danielmarbach avatar danielmarbach commented on June 9, 2024

Thanks for following up! Yes it would be Get only.

Yeah this code would work. We could then simply pass the request message to the HttpMessageInvoker.

I figured I raise it here since you might be want to consider a scatter gather like abstraction similar to the forwarder interface

from reverse-proxy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.