Skip to content

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

Open
jlukawska wants to merge 19 commits intoThreeMammals:developfrom
jlukawska:feature/651-merge-custom-properties
Open

#651 Merge custom JSON properties across multiple ocelot.X.json configuration files using Newtonsoft's JToken merge functionality#1183
jlukawska wants to merge 19 commits intoThreeMammals:developfrom
jlukawska:feature/651-merge-custom-properties

Conversation

@jlukawska
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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?

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

raman-m commented Nov 11, 2024

Successors

This PR must be merged first❗

@coveralls
Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 93.397% (-0.1%) from 93.503%
when pulling 94e251d on jlukawska:feature/651-merge-custom-properties
into 9fc4e78 on ThreeMammals:develop.

@raman-m
Copy link
Copy Markdown
Member

raman-m commented Jan 12, 2026

Ready for code review ✔️

  • Require code coverage improvement

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 Spring'26 Spring 2026 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extending Route configuration

5 participants