Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 23 commits into from
May 27, 2024

Conversation

raman-m
Copy link
Member

@raman-m raman-m commented May 15, 2024

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 👇

  • It allows overriding the behavior of the Consul provider.
  • It enables the injection of a new IConsulServiceBuilder service into the Consul provider.
  • It permits the overriding of the DefaultConsulServiceBuilder class's behavior.
  • The targeted virtual methods which solve the 954 problem are:
    • protected virtual ServiceHostAndPort GetServiceHostAndPort(ServiceEntry entry, Node node)
    • protected virtual string GetDownstreamHost(ServiceEntry entry, Node node)

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 raman-m self-assigned this May 15, 2024
@raman-m raman-m added bug Identified as a potential bug Service Discovery Ocelot feature: Service Discovery Consul Service discovery by Consul Spring'24 Spring 2024 release labels May 15, 2024
@raman-m raman-m added this to the March-April'24 milestone May 15, 2024
@raman-m raman-m changed the title #954 Customize Consul services creation in Consul service discovery provider #954 #957 #1026 Customize Consul services creation in Consul service discovery provider May 15, 2024
This was linked to issues May 15, 2024
@raman-m raman-m requested review from RaynaldM and ggnaegi May 15, 2024 14:05
@raman-m
Copy link
Member Author

raman-m commented May 15, 2024

@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
Copy link
Member

ggnaegi commented May 16, 2024

@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
Copy link
Member Author

raman-m commented May 16, 2024

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
Copy link
Member Author

raman-m commented May 18, 2024

The rest of the work

@raman-m
Copy link
Member Author

raman-m commented May 25, 2024

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

@ggnaegi ggnaegi self-requested a review May 26, 2024 20:02
@raman-m raman-m merged commit 34cb3eb into develop May 27, 2024
1 check passed
@raman-m raman-m deleted the raman-m/954 branch May 27, 2024 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Identified as a potential bug Consul Service discovery by Consul Service Discovery Ocelot feature: Service Discovery Spring'24 Spring 2024 release
Projects
None yet
3 participants