public Task <IList <KeyValueConfig> > ListAndWatchAsync(string prefix, Action <WatcherEventArg <IList <KeyValueConfig> > > watchCallback) { var watcherContext = new WatcherContext <IList <KeyValueConfig> >( () => { return(new ConfigurationMonitorWatcher(prefix, _client, _logger) { WatchChanged = watchCallback }); }); return(watcherContext.GetInstanceAsync()); }
public Task <KeyValueConfig> GetAndWatchAsync(string key, Action <WatcherEventArg <KeyValueConfig> > watchCallback) { if (string.IsNullOrWhiteSpace(key)) { throw new ValidationException(nameof(key), "key is empty"); } var watcherContext = new WatcherContext <KeyValueConfig>( () => { return(new SingleConfigurationMonitorWatcher(key, _client, _logger) { WatchChanged = watchCallback }); }); return(watcherContext.GetInstanceAsync()); }
public async Task <ServiceInfo> GetServiceAsync(string serviceName) { if (string.IsNullOrWhiteSpace(serviceName)) { throw new ArgumentNullException("serviceName"); } var watcherContext = new WatcherContext <IList <ServiceInfo> >( () => { return(new ServicesMonitorWatcher( serviceName, RoutingStrategyFactory.GetRouting <ServiceInfo>(_consulConfig.Route), _client, _logger)); }); var services = await watcherContext.GetInstanceAsync(); return(services[0]); }