-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Configuration for use by extensions, custom pipelines, or other extensions #738
Comments
I really like this feature |
@margaale Any ideas as to what that configuration container should look like? That's where I'm a bit unsure as we need some way of providing a JSON Scheme onto FileConfiguration. My initial thought is it would be a Dictionary<string, Dictionary<string, object>> and the "extension" would receive the Dictionary<string, object> from the key that matches the extension name. So it would be something like this:
Then the extension named "ExtensionName" would receive the Dictionary<string, object> that contains "Key1" with the string "Value1" and "Key2" with the boolean "true" |
That would be my first choice too, but probably we could Json.Deserialize the configuration into an user defined class |
The ASP.NET configuration used doesn't allow that out of the box without defining the structure up front, that I'm aware of. I think in order to do that we'd have to implement our own way of loading the configuration from disk instead of relying on ASP.NET's |
In OcelotMiddlewareExtensions.cs we have this:
As you can see, it's already been noted that config could be made from the filesystem. If we did that instead, we could deserialize into a JObject easily and allow extensions to define their own configuration structured. However, this comes with at least two costs... Cons to this approach are:
|
I know that part of the code, the optionmonitor was my contribution :-)
There's is an administration API where you are able to modify the
configuration and save it to the filesystem that we have to take into account too.
We can load the configuration as your original idea and then add an extra
layer where we transform it to the desired class.
I don't want that the third party add-ons have to use the options extension. They
would have to use that layer (service) to fetch their configuration. Sorry
if I'm not being clear, English is not my first language...
|
I'm leaning towards providing the Dictionary with options, at least with the initial implementation. Perhaps we could allow some further customization in an update, but doing it with the Dictionary requires the least amount of disruption with the current configuration system. The transform layer would be difficult for any configuration that is not flat, we would need to reload the raw configuration. That may be feasible but would require a lot of mangling of the config, the Dictionary implementation is the simplest short-term to at least prove out the concept. |
Sure, let's start with the simple solution, we will have time to further refine it. Tell me if i can help you. I'm gonna give it a shota at the caching issue in the meanwhile |
Sounds good, I'll start work on this one soon. I'll probably also pick up #737 as I have found that one would resolve a number of other issues/requests in the backlog. |
This is interesting, I am not really clear what problem it is solving in my head or what it would look like though! |
hi, this feature would be great, any update? |
@philproctor What's up, Phil? Your feature has been accepted. So, the feature is in development now officially. Congrats! 🎉 |
@vantm Welcome! You are assigned! |
* feat(configuration): adding route metadata * feat(configuration): update docs * feat(configuration): replace Dictionary<> by IDictionary<>, code cleaning * feat(configuration): replace Dictionary<> by IDictionary<> * feat(configuration): replace Dictionary<> by IDictionary<> * feat(configuration): update the data type of FileDynamicRoute Metadata * formatting * feat(configuration): fix integration tests * feat !1843 add extension methods for DownstreamRoute to get metadata * feat !1843 add extension methods for DownstreamRoute * feat !1843 update docs * feat !1843 update docs * feat !1843 cleanup split string logic * SA1505: An opening brace should not be followed by a blank line * IDE1006: Naming rule violation: These words must begin with upper case characters: should_xxx * Fix compile errors after rebasing * Fix unit tests + AAA pattern * First Version, providing a generic extension method GetMetadata<T> with global configuration * Adding ConvertToNumericType method to be able to use the NumberStyles enum * adding first acceptance tests * The tests are now passing again... * adding latest test cases. That should be enough (includes global configuration changes too) * Update metadata.rst * adding the xml docs for IMetadataCreator and MetadataCreator * renaming MetadataCreator to DefaultMetadataCreator * number tests for .net 6 too * Moving Metadata specific downstream route extensions to the Metadata folder * cleanup * applying some of the requested changes * Final code review by @raman-m * Add traits * Fix docs build error --------- Co-authored-by: Raman Maksimchuk <[email protected]> Co-authored-by: Guillaume Gnaegi <[email protected]>
Closed by #1843 |
* feat(configuration): adding route metadata * feat(configuration): update docs * feat(configuration): replace Dictionary<> by IDictionary<>, code cleaning * feat(configuration): replace Dictionary<> by IDictionary<> * feat(configuration): replace Dictionary<> by IDictionary<> * feat(configuration): update the data type of FileDynamicRoute Metadata * formatting * feat(configuration): fix integration tests * feat !1843 add extension methods for DownstreamRoute to get metadata * feat !1843 add extension methods for DownstreamRoute * feat !1843 update docs * feat !1843 update docs * feat !1843 cleanup split string logic * SA1505: An opening brace should not be followed by a blank line * IDE1006: Naming rule violation: These words must begin with upper case characters: should_xxx * Fix compile errors after rebasing * Fix unit tests + AAA pattern * First Version, providing a generic extension method GetMetadata<T> with global configuration * Adding ConvertToNumericType method to be able to use the NumberStyles enum * adding first acceptance tests * The tests are now passing again... * adding latest test cases. That should be enough (includes global configuration changes too) * Update metadata.rst * adding the xml docs for IMetadataCreator and MetadataCreator * renaming MetadataCreator to DefaultMetadataCreator * number tests for .net 6 too * Moving Metadata specific downstream route extensions to the Metadata folder * cleanup * applying some of the requested changes * Final code review by @raman-m * Add traits * Fix docs build error --------- Co-authored-by: Raman Maksimchuk <[email protected]> Co-authored-by: Guillaume Gnaegi <[email protected]>
New Feature
Add some container for storing configuration values into the configuration container into both the GlobalConfiguration and into the individual ReRoute configurations. Additionally, the creator methods for reroutes and possibly other configurations (such as service discovery) should have hooks that provide a mechanism for reloading these configurations on configuration change and adding properties to the configured object (such as the ReRoute object)
Motivation for New Feature
Currently the Ocelot configuration has predefined values based on what Ocelot internally uses. This works for official extensions, however it makes it difficult for third parties to extend with configurations that are not already in the standard FileConfiguration. When an option needs to be applied to an individual reroute, using the standard IConfiguration options from ASP.NET require knowing the array index and other information that may not be easily available.
The text was updated successfully, but these errors were encountered: