ThreeMammals / Ocelot

.NET API Gateway
https://www.nuget.org/packages/Ocelot
MIT License
8.35k stars 1.63k forks source link

#954 #957 #1026 Customize Consul services creation in `Consul` service discovery provider #2067

Closed raman-m closed 4 months ago

raman-m commented 4 months ago

Fixes #954 #957 #1026

Proposed Changes

This PR introduces general customization options for the Consul provider, taking inspiration from the Kube provider customization in PR #2052. However, this PR offers a more flexible design as outlined below 👇

In conclusion, customization hinges on the virtual methods of the DefaultConsulServiceBuilder class, allowing developers to override as needed for highly customized Consul setups in their environments.

Initially, I considered introducing JSON overrides for the ServiceDiscoveryProvider section in the global configuration of ocelot.json. However, I realized that approach was suboptimal. Writing C# code that inherits from the DefaultConsulServiceBuilder class is a superior solution.

Predecessors

raman-m commented 4 months ago

@ignacy130 Hello Ignacy! I would value your code review and your thoughts on it as well.

@ggnaegi You are the primary reviewer for this PR. 😉 I believe the C# design is finalized, and I am currently working on the tests... You could begin the code review today...

ggnaegi commented 4 months ago

@raman-m Your idea is great, but I think we should rework it a bit first. We should think about polling and long polling and give the ability to the users to develop their own implementations.

raman-m commented 4 months ago

We should think about polling and long polling and give the ability to the users to develop their own implementations.

@ggnaegi, I understand you're expecting new method overrides for the next version of the provider with enhanced polling capabilities, correct? You'll have the opportunity to do so. 😉 Are you suggesting that this bug fix should not be included in the current monthly release and that we need to work on it further? Please note that we now have a common release strategy where we release the library, the provider, and even the documentation together. If we release this bug fix in v23.3, the corresponding Ocelot.Provider.Consul v23.3 will also be released. If we further refactor Ocelot.Provider.Consul as you propose, it will be released in subsequent versions 23.x or 24.x. Therefore, I don't see the benefit of waiting for an ideal solution by delaying the delivery of the bug fix.

Let's proceed with releasing this bug fix and the package update in version 23.3, shall we?

raman-m commented 4 months ago

The rest of the work

raman-m commented 4 months ago

@ggnaegi Dev Complete! Docs written! Waiting for your approval after final review... Could you review this weekend please?