Skip to content

Suggestions for Microsoft.ServiceFabric.AspNetCore.Gateway #4

@cwe1ss

Description

@cwe1ss

Hi,

I created a very similar Gateway. You can find the code here: https://github.com/c3-ls/ServiceFabric-HttpServiceGateway

If I understood correctly, you are working on the Service Fabric team. It would be great if you could consider my code in case you plan to move this project into the SDK. It would also be great if you could keep it an open source project even though it moves into the SDK. I'd be happy to retire my project and help you with this one in that case!

these are the main differences:

CommunicationClient:

  • CommunicationClient holds a reference to HttpClient -> so it's more similar to the current WCF solution
  • HttpClientHandler.AllowAutoRedirect = false -> this is very important. The gateway should pass responses to the client 1:1 and not follow redirects.
  • OperationTimeout for HttpClient -> You don't have any timout logic yet

CommunicationClientFactory:

  • Logging -> this is critical and one of the main pain points in the SDK. we need to know when retries happen.
  • I already implemented some exception/retry handling. This is a hard and very opinionated topic! there should be an easy hook for devs to change this behavior. I currently only have an option for setting whether valid (but semantically failed) responses (404, 500, etc.) should be retried. A more general hook would be better I guess.

Request forwarding:

  • the original request body is a forward-only stream - you can't use it within the InvokeWithRetry loop, it will throw an Exception on the second attempt.
  • the gateway sets Via, X-Forwarded-* and Forwarded headers to allow the services to get the original information
  • the gateway also adds the path of the gateway as a non-standard X-Forwarded-BasePath header. this allows services to adjust their base path in responses (e.g. gateway has path /SampleService but service is hosted on localhost:30001/). it would be better if the gateway could rewrite URLs in the response but this is quite complex
  • the gateway doesn't forward headers that are not valid for forwarding (the current asp.net proxy sample just forwards everything.) E.g. it is not allowed to forward the "Host" header. (you overwrite it correctly though)

Options:

  • I structured them a little bit different but both contain a way to pass the PartitionKey-resolver.

You can find some more information in the project wiki

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions