示例#1
0
        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());
        }
示例#2
0
        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());
        }
示例#3
0
        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]);
        }
示例#4
0
 public WriteTimeWatcherRepository(WatcherContext context)
 {
     _context = context;
 }
示例#5
0
 public CreationTimeWatcherRepository(WatcherContext context)
 {
     _context = context;
 }