GithubHelp home page GithubHelp logo

Comments (10)

Adamantinu avatar Adamantinu commented on May 26, 2024 3

Hi, ist this on the roadmap for a future version or not on the radar at all right now?
Would love to have this feature since more and more services are hosted in some kubernetes cluster with dynamic configuration over a service discovery.

from mmlib.swaggerforocelot.

Adamantinu avatar Adamantinu commented on May 26, 2024 3

Unfortunally I can't open a branch and create a pull request, but basically the Scheme that comes back in the SwaggerServiceDiscoveryProvider class is null since K8s works with IPs only internally. So you would have to set this one manually depending on the port - like:

        var scheme = service.Scheme;

        if (string.IsNullOrEmpty(service.Scheme))
        {
            switch (service.DownstreamPort)
            {
                case 80:
                    scheme = Uri.UriSchemeHttp;
                    break;
                case 443:
                    scheme = Uri.UriSchemeHttps;
                    break;
                default:
                    break;
            }
        }

        var builder = new UriBuilder(scheme, service.DownstreamHost, service.DownstreamPort);
        builder.Path = endPoint.Service.Path;

However, It only works with the standard kube ocelot serviceDiscovery type - with pollkube I didn't manage to find a fix yet, but for now this would suffice for our use case - would need documentation though.

from mmlib.swaggerforocelot.

Burgyn avatar Burgyn commented on May 26, 2024 2

Hi,
Yes, I'm planning it for the next major release. But unfortunately I don't have as much time as I would have imagined.

from mmlib.swaggerforocelot.

Burgyn avatar Burgyn commented on May 26, 2024 1

Thank you for your investigation. I'll implement it tomorrow (and write unit tests).

To the future contribution. If you don't have perrmission for contribution to GitHub repository then:

  1. Fork GitHub repo
  2. Create branch
  3. Write implementation / tests / documentations / ...
  4. Commit / push to your forked repo
  5. Create Pull Request

from mmlib.swaggerforocelot.

Burgyn avatar Burgyn commented on May 26, 2024

Hi,

Unfortunately, this package does not currently support this scenario.

from mmlib.swaggerforocelot.

Burgyn avatar Burgyn commented on May 26, 2024

This feature is availabe in preview version 2.0.0-alpha.1.

from mmlib.swaggerforocelot.

Adamantinu avatar Adamantinu commented on May 26, 2024

Very cool! Unfortunally it doesn't seem to work with kubernetes - neither with Ocelots PollKube where it doesn't find the service to connect too, nor with the normal "OnRequest" Provider where it can't build the Uri and throws and unhandled exception.

Stack Trace:

[15:54:10 ERR] Connection id "0HLTVH5MUK6FF", Request id "0HLTVH5MUK6FF:00000002": An unhandled exception was thrown by the application.
System.UriFormatException: Invalid URI: The URI scheme is not valid.
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at System.Uri..ctor(String uriString)
at System.UriBuilder.get_Uri()
at MMLib.SwaggerForOcelot.ServiceDiscovery.SwaggerServiceDiscoveryProvider.GetSwaggerUri(SwaggerEndPointConfig endPoint, ReRouteOptions reRoute)
at MMLib.SwaggerForOcelot.ServiceDiscovery.SwaggerServiceDiscoveryProvider.GetSwaggerUriAsync(SwaggerEndPointConfig endPoint, ReRouteOptions reRoute)
at MMLib.SwaggerForOcelot.Middleware.SwaggerForOcelotMiddleware.GetEndPoint(String path, ISwaggerServiceDiscoveryProvider discoveryProvider)
at MMLib.SwaggerForOcelot.Middleware.SwaggerForOcelotMiddleware.Invoke(HttpContext context, ISwaggerServiceDiscoveryProvider discoveryProvider)
.
.
.

from mmlib.swaggerforocelot.

Burgyn avatar Burgyn commented on May 26, 2024

Hi, Thank you for your feedback. I apologize for the trouble.

I'll try to investigate and fix it. But unfortunately I have no experience with kubernetes. It would help me if you could prepare a demo for this problem for me.

from mmlib.swaggerforocelot.

Adamantinu avatar Adamantinu commented on May 26, 2024

Very good, thanks for the information.
I actually thought of a better possibility for getting the right URI Scheme - since we have to configure the DownstreamScheme in ocelot anyhow, we should just use that for the discovery instead of a switch on the used port.

from mmlib.swaggerforocelot.

Burgyn avatar Burgyn commented on May 26, 2024

It will be fixed in version 2.0.0-alpha.2. Please check it.

Thanks for cooperation.

from mmlib.swaggerforocelot.

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.