-
Notifications
You must be signed in to change notification settings - Fork 203
Add support for a lazy ConfigurationProvider #584
Comments
@HaoK Our source/provider plugs to DI and resolves our current request context to figure out which client this setting is for. Just a thought at this point. Might not be possible or not a very elegant solution... |
Are you able to have a provider per tenant? That would align with how reload works |
Some initial thoughts for how this might look, will try switching a few providers over to this to see how it feels. public class LazyConfigurationProvider : IConfigurationProvider {
private ConfigurationReloadToken _reloadToken = new ConfigurationReloadToken();
private IEnumerable<string> _allKeys;
protected IDictionary<string, string> Data { get; set; }
public abstract IEnumerable<string> LoadAllKeys();
public abstract LoadValue(string key);
// Interface methods
IEnumerable<string> GetChildKeys(IEnumerable<string> earlierKeys, string parentPath) {
// Reuse same code as ConfigurationProvider with _allKeys;
}
bool TryGet(string key, out string value) {
// If we don't have data already, call LoadValue and store in Data
}
void Set(string key, string value) => Data[key] = value;
IChangeToken GetReloadToken() => _reloadToken;
void Load() {
_allKeys = LoadAllKeys();
// We could setup the dictionary with a bunch of Lazy<string> calls to LoadValue to simplify TryGet
}
} |
The problem is I would prefer to avoid initializing all client sources/providers at startup. I would rather have the ability to dynamically add the source at runtime the first time a client request comes in. This is how I'm handling it right now but within a single source. I pull the client settings upon request if not there already. However when I need to invalidate a single client this model doesn't work. Thoughts? |
I'll have to think about this a bit more, we'll discuss this in the next triage as we are seeing a lot of requests about multi-tenancy scenarios. @glennc |
We've decided not to purse changes in this direction after discussing our plans for 2.0. This is a fairly advanced scenario that individual providers can attempt if so desired. |
Today our base provider only handles eagerly loading all key/values in load, we should have some way to delay loading the values until needed
The text was updated successfully, but these errors were encountered: