public FeatureToggleCache(FeatureToggleProvider featureToggleProvider, TimeSpan cacheUpdateInterval)
        {
            _featureToggleProvider = featureToggleProvider;
            _updateInterval        = cacheUpdateInterval;

            if (_updateInterval < TimeSpan.FromSeconds(1))
            {
                throw new Exception("Cache update interval must be at least 1 second long");
            }
        }
        public FeatureToggleCache(FeatureToggleProvider featureToggleProvider, TimeSpan cacheUpdateInterval)
        {
            _featureToggleProvider = featureToggleProvider;
            _updateInterval = cacheUpdateInterval;

            if (_updateInterval < TimeSpan.FromSeconds(1))
            {
                throw new Exception("Cache update interval must be at least 1 second long");
            }
        }
        public HobknobClient Create(string etcdHost, int etcdPort, string applicationName, TimeSpan cacheUpdateInterval)
        {
            var etcdKeysPath = string.Format("http://{0}:{1}/v2/keys/", etcdHost, etcdPort);

            var etcdClient = new EtcdClient(new Uri(etcdKeysPath));
            var featureToggleProvider = new FeatureToggleProvider(etcdClient, applicationName);
            var featureToggleCache = new FeatureToggleCache(featureToggleProvider, cacheUpdateInterval);
            var hobknobClient = new HobknobClient(featureToggleCache, applicationName);

            featureToggleCache.Initialize();

            return hobknobClient;
        }
示例#4
0
        public HobknobClient Create(string etcdHost, int etcdPort, string applicationName, TimeSpan cacheUpdateInterval)
        {
            var etcdKeysPath = string.Format("http://{0}:{1}/v2/keys/", etcdHost, etcdPort);

            var etcdClient            = new EtcdClient(new Uri(etcdKeysPath));
            var featureToggleProvider = new FeatureToggleProvider(etcdClient, applicationName);
            var featureToggleCache    = new FeatureToggleCache(featureToggleProvider, cacheUpdateInterval);
            var hobknobClient         = new HobknobClient(featureToggleCache, applicationName);

            featureToggleCache.Initialize();

            return(hobknobClient);
        }
示例#5
0
        public IHobknobClient Create(string etcdHost, int etcdPort, string applicationName, TimeSpan cacheUpdateInterval, EventHandler <CacheUpdateFailedArgs> cacheUpdateFailed)
        {
            var etcdKeysPath = string.Format("http://{0}:{1}/v2/keys/", etcdHost, etcdPort);

            var etcdClient            = new EtcdClient(new Uri(etcdKeysPath));
            var featureToggleProvider = new FeatureToggleProvider(etcdClient, applicationName);
            var featureToggleCache    = new FeatureToggleCache(featureToggleProvider, cacheUpdateInterval);
            var hobknobClient         = new HobknobClient(featureToggleCache, applicationName);

            if (cacheUpdateFailed == null)
            {
                throw new ArgumentNullException("cacheUpdateFailed", "Cached update handler is empty");
            }
            featureToggleCache.CacheUpdateFailed += cacheUpdateFailed;

            featureToggleCache.Initialize();

            return(hobknobClient);
        }
示例#6
0
        public IHobknobClient Create(string host, int port, string applicationName, TimeSpan cacheUpdateInterval, EventHandler <CacheUpdateFailedArgs> cacheUpdateFailed)
        {
            var applicationFeaturesPath = $"http://{host}:{port}/api/applications/{applicationName}";

            var apiClient             = new ApiClient(new Uri(applicationFeaturesPath));
            var featureToggleProvider = new FeatureToggleProvider(apiClient);
            var featureToggleCache    = new FeatureToggleCache(featureToggleProvider, cacheUpdateInterval);
            var hobknobClient         = new HobknobClient(featureToggleCache, applicationName);

            if (cacheUpdateFailed == null)
            {
                throw new ArgumentNullException("cacheUpdateFailed", "Cached update handler is emtpy");
            }
            featureToggleCache.CacheUpdateFailed += cacheUpdateFailed;

            featureToggleCache.Initialize();

            return(hobknobClient);
        }