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

#651 Merge custom JSON properties across multiple ocelot.X.json configuration files using Newtonsoft's JToken merge functionality #1183

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from

Conversation

jlukawska
Copy link
Contributor

@jlukawska jlukawska commented Apr 7, 2020

Closes #651

Proposed Changes

  • The whole sections of config files (with custom properties) are merged.

@raman-m raman-m changed the title Feature/651 merge custom properties of config file #651 Merge custom properties of config file Jul 20, 2023
@raman-m raman-m changed the base branch from master to develop July 20, 2023 15:24
@raman-m raman-m self-requested a review July 20, 2023 16:05
@raman-m raman-m added the feature A new feature label Jul 20, 2023
@raman-m raman-m force-pushed the feature/651-merge-custom-properties branch from 4eb4482 to 9ec4b8d Compare July 26, 2023 14:36
@raman-m
Copy link
Member

raman-m commented Jul 26, 2023

Congrats, @jlukawska ! 🎉
Your feature branch has been rebased onto ThreeMammals:develop.

We can go with code review now...

@raman-m raman-m added the needs feedback Issue is waiting on feedback before acceptance label Jul 26, 2023
@raman-m
Copy link
Member

raman-m commented Aug 3, 2023

@nurhat
As the #651 issue author, could you review this solution please?
Will the solution be useful and helpful for your daily gateway development?

@raman-m
Copy link
Member

raman-m commented Aug 3, 2023

@RaynaldM @wast
You are great approvers! 🥇
Seems like @jlukawska is making breaking changes and you've approved them. 🤣
I am not sure about changes that they're breaking on 100%, but I will review the code thoroughly. 👇

Copy link
Member

@raman-m raman-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jlukawska
Could you fix the issues please?

How to read CustomStrategyProperty value of the route in run-time?


fileConfiguration.Aggregates.AddRange(config.Aggregates);
fileConfiguration.Routes.AddRange(config.Routes);
MergeConfig(fileConfiguration, config, isGlobal);
Copy link
Member

@raman-m raman-m Aug 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🆗 Merged config JSON goes to primaryConfigFile. And it will be serialized to ocelot.json file.
And the primary config will be attached to IConfigurationBuilder object by AddJsonFile method.

Could you show me a case how can I read this custom property inside of extension-methods for IConfigurationBuilder interface?

test/Ocelot.AcceptanceTests/ConfigurationMergeTests.cs Outdated Show resolved Hide resolved
test/Ocelot.AcceptanceTests/ConfigurationMergeTests.cs Outdated Show resolved Hide resolved
@raman-m
Copy link
Member

raman-m commented Aug 3, 2023

@nurhat @jlukawska
I would like to understand, how useful this feature for real world user scenarios.

User case 1

Change behavior of PollyQoSProvider

Given, I wish to override behavior of the Quality of Service feature by changes in PollyQoSProvider and/or AddPolly and/or PollyCircuitBreakingDelegatingHandler classes.
And, I will define custom property of the route for custom QoS overriding in a ocelot.xservices.json file.
And, I will read the custom property from DownstreamRoute object after merging all configs.
When, I read the custom property from DownstreamRoute object.
Then, I get stuck! 😉

Question:

  • How to read custom property from DownstreamRoute object?
  • How and what interface do I need to inject to a service class to be able to read custom property from DownstreamRoute object?

@raman-m raman-m force-pushed the feature/651-merge-custom-properties branch from 04debe6 to 7f61d01 Compare October 12, 2023 12:16
@jlukawska
Copy link
Contributor Author

@raman-m, I marked this PR as a draft, because I am not sure if the conflicts are resolved correctly (even though the tests passed correctly). It wasn't that easy ;) I'd have to revise the code, understand the changes from develop branch and maybe the PR code would have to be improved.
Apart from that, would this PR be helpful for anyone? I proposed it 4 years ago and the issue reporter no longer responds.

@raman-m
Copy link
Member

raman-m commented May 28, 2024

Understood, Jolanta. It seems you're uncertain and wish to further develop. I also notice that many PR files contain a fake diff indicating numerous merge conflicts were resolved.

Here's what I suggest:

  • Create a new feature branch from develop. Your forked repo develop is synced.
  • Clone the second repository for manual file operations.
  • Transfer all changes from the old feature branch to the new one using a file manager (Total Commander is my choice, an old school tool with a dual-pane interface vs useful comparison command).
  • Open a new PR after confirming successful compilation and passing tests.
  • Close this old PR and reference the new one.

Does this sound like a good approach?

P.S.
I believe the most important changes are in the file: src/Ocelot/DependencyInjection/ConfigurationBuilderExtensions.cs
which should be double checked.

@raman-m raman-m added Configuration Ocelot feature: Configuration and removed needs feedback Issue is waiting on feedback before acceptance labels Nov 11, 2024
@raman-m
Copy link
Member

raman-m commented Nov 11, 2024

🆗 I'm going to rebase the branch...

@raman-m raman-m force-pushed the feature/651-merge-custom-properties branch from 8c3ec5a to 1b2198c Compare November 11, 2024 15:47
@raman-m
Copy link
Member

raman-m commented Nov 11, 2024

@jlukawska commented on May 16, 2024

I am not sure if the conflicts are resolved correctly (even though the tests passed correctly). It wasn't that easy ;)

I've rebased the feature branch today and addressed the failed tests. The entire code appears to be in good shape. I will provide my final code review later, after receiving feedback from the team. However, the current acceptance test confirms the successful merging of JSON. More tests are necessary, and it seems they will be essential for the upcoming C# helpers that will be reused in the actual code of middlewares, similar to how the Metadata-helpers function.

Apart from that, would this PR be helpful for anyone?

Indeed, the question of whether this PR would be beneficial to anyone is quite pertinent, especially after the introduction of the Route Metadata feature (aka Metadata). While some developers may not favor storing additional route data in the Metadata property, the direct inclusion of properties in JSON remains a sought-after feature, as suggested by your PR. The primary challenge lies in crafting comprehensive documentation before we can develop truly useful C# helpers, potentially surpassing the current Metadata logic.

I proposed it 4 years ago and the issue reporter no longer responds.

Mr. @nurhat didn't even reply to me, which suggests he might have used a work account linked to a corporate email. Developers often change jobs and employers, along with their work emails. Regardless, I'll assume the role of the author. 😉

Copy link
Member

@raman-m raman-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready for Code Review❕

@raman-m raman-m changed the title #651 Merge custom properties of config file #651 Merge custom JSON properties across multiple ocelot.X.json configuration files using Newtonsoft's JToken merge functionality Nov 11, 2024
@raman-m
Copy link
Member

raman-m commented Nov 11, 2024

Successors

This PR must be merged first❗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Configuration Ocelot feature: Configuration feature A new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extending Route configuration
4 participants