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

Restructure backend/endpoint config, config reload #42

Merged
merged 4 commits into from
Apr 10, 2020

Conversation

Tratcher
Copy link
Member

@Tratcher Tratcher commented Apr 3, 2020

#9 Restructure backend/endpoint config as discussed in https://github.com/microsoft/reverse-proxy/blob/master/docs/config.md#backend-configuration, nesting endpoints under their backends, and moving from list to object/dictionary formats. After Consulting with David I also took the opportunity to simplify the internal object model to match.

Also moved the config reload logic into the product assemblies.

@Tratcher Tratcher self-assigned this Apr 3, 2020
@Tratcher Tratcher force-pushed the tratcher/reloadconfig branch from 29bbb5d to 94912b0 Compare April 7, 2020 18:20
@Tratcher
Copy link
Member Author

Tratcher commented Apr 9, 2020

bump

Copy link
Member

@analogrelay analogrelay left a comment

Choose a reason for hiding this comment

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

Spec-wise this looks OK to me. Haven't dug into code at this time.

// You can then change appsettings.json on disk and we will apply the new configs without a restart.
services.Configure<ProxyConfigRoot>(_configuration.GetSection("ReverseProxy"));
services.AddHostedService<ProxyConfigApplier>();
services.AddReverseProxy().LoadFromConfig(_configuration.GetSection("ReverseProxy"), reloadOnChange: true);
Copy link
Member

Choose a reason for hiding this comment

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

Other places tend to do this by accepting an IConfiguration in the AddXYZ call. Is that not appropriate here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to clarify the separation between "I'll set some of the proxies options from config" and "I'm loading routes and endpoints from config". I expect this is where you'd add similar extensions for LoadFromServiceFabric, LoadFromDatabase, etc..

Copy link
Contributor

Choose a reason for hiding this comment

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

This brings up a question for services like Antares, we probably don't want to fetch the entire route table from the db, but instead have a pull and cache for each hostname model. Is that basically a replacememt router?

Copy link
Member Author

Choose a reason for hiding this comment

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

This brings up a question for services like Antares, we probably don't want to fetch the entire route table from the db, but instead have a pull and cache for each hostname model. Is that basically a replacememt router?

Hmm, that doesn't fit well into the current model. I'll file a separate issue to evaluate that.

Copy link
Member Author

Choose a reason for hiding this comment

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

@samsp-msft well done, you broke it. I've filed #46 for that scenario. I think supporting it would require a much different architecture.

{
_subscription = _proxyConfig.OnChange((newConfig, name) => _ = ApplyAsync(newConfig));
}
return ApplyAsync(_proxyConfig.CurrentValue);
Copy link
Member

Choose a reason for hiding this comment

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

I know this isn't new, but could there be overlapping calls to ApplyAsync? Should we use a semaphore or something?

Copy link
Member Author

Choose a reason for hiding this comment

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

In theory there could be multiple calls, but everything ApplyAsync calls is already heavily guarded. The config objects all deep clone, the route and backeds repos lock on set and get, and the various collections used by ApplyConfigurationsAsync also lock. It's not an efficient process, but hopefully your config isn't changing that frequently.

@Tratcher Tratcher merged commit 61055e1 into master Apr 10, 2020
@Tratcher Tratcher deleted the tratcher/reloadconfig branch April 10, 2020 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants