Periodically Update YARP destinations #1963
-
Background: Since we didn't find anything like that, I want to share what we did, So here goes: 1.Added a BackgroundService which I called "ConfigurationUpdaterBackgroundService" that runs every 3 minutes. 2.On the ConfigureServices when creating our new BackgroundService we use the service provider to get the IProxyConfigProvider and pass it to the background service constructor. services.AddHostedService(serviceProvider => new ConfigurationUpdaterBackgroundService(proxyBuilder, ServiceInstanceFinder, Configuration, serviceProvider.GetRequiredService())); 3.The BackgroundService will now periodically check for updates in the list (we have another service to get it), and if needed it wil call the Update function of YARP: this.reverseProxyInMemoryConfigProvider.Update(routes, clusters); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
See https://microsoft.github.io/reverse-proxy/articles/config-providers.html#reload Yes, that's a common pattern. IProxyConfigProvider is the abstraction for providing and reloading config. Using the existing InMemoryConfigProvider is a fine way to plug in when you're pulling your config from somewhere else. Are you using the new public one from the 2.0 previews? |
Beta Was this translation helpful? Give feedback.
See https://microsoft.github.io/reverse-proxy/articles/config-providers.html#reload
Yes, that's a common pattern. IProxyConfigProvider is the abstraction for providing and reloading config. Using the existing InMemoryConfigProvider is a fine way to plug in when you're pulling your config from somewhere else. Are you using the new public one from the 2.0 previews?