Ejemplo n.º 1
0
        public void Initialize()
        {
            _log        = new Mock <ISplitLogger>();
            _splitCache = new Mock <ISplitCache>();

            trafficTypeValidator = new TrafficTypeValidator(_splitCache.Object, _log.Object);
        }
Ejemplo n.º 2
0
        private void BuildRedisCache()
        {
            _redisAdapter = new RedisAdapter(_config.RedisHost, _config.RedisPort, _config.RedisPassword, _config.RedisDatabase, _config.RedisConnectTimeout, _config.RedisConnectRetry, _config.RedisSyncTimeout);

            Task.Factory.StartNew(() => _redisAdapter.Connect());

            _segmentCache         = new RedisSegmentCache(_redisAdapter, _config.RedisUserPrefix);
            _splitParser          = new RedisSplitParser(_segmentCache);
            _splitCache           = new RedisSplitCache(_redisAdapter, _splitParser, _config.RedisUserPrefix);
            _metricsCache         = new RedisMetricsCache(_redisAdapter, _config.SdkMachineIP, _config.SdkVersion, _config.SdkMachineName, _config.RedisUserPrefix);
            _trafficTypeValidator = new TrafficTypeValidator(_splitCache);
        }
Ejemplo n.º 3
0
        private void BuildSplitFetcher()
        {
            var segmentRefreshRate   = _config.RandomizeRefreshRates ? Random(_config.SegmentRefreshRate) : _config.SegmentRefreshRate;
            var segmentChangeFetcher = new ApiSegmentChangeFetcher(_segmentSdkApiClient);
            var segmentTaskQueue     = new SegmentTaskQueue();

            _selfRefreshingSegmentFetcher = new SelfRefreshingSegmentFetcher(segmentChangeFetcher, _statusManager, segmentRefreshRate, _segmentCache, _config.NumberOfParalellSegmentTasks, segmentTaskQueue, _tasksManager, _wrapperAdapter);

            var splitChangeFetcher = new ApiSplitChangeFetcher(_splitSdkApiClient);
            var splitsRefreshRate  = _config.RandomizeRefreshRates ? Random(_config.SplitsRefreshRate) : _config.SplitsRefreshRate;

            _splitParser          = new InMemorySplitParser((SelfRefreshingSegmentFetcher)_selfRefreshingSegmentFetcher, _segmentCache);
            _splitFetcher         = new SelfRefreshingSplitFetcher(splitChangeFetcher, _splitParser, _statusManager, splitsRefreshRate, _tasksManager, _splitCache);
            _trafficTypeValidator = new TrafficTypeValidator(_splitCache);
        }
Ejemplo n.º 4
0
        private void BuildRedisCache()
        {
            _redisAdapter = new RedisAdapter(_config.RedisHost, _config.RedisPort, _config.RedisPassword, _config.RedisDatabase, _config.RedisConnectTimeout, _config.RedisConnectRetry, _config.RedisSyncTimeout, _config.TlsConfig);

            Task.Factory.StartNew(() =>
            {
                _redisAdapter.Connect();
                RecordConfigInit();
            });

            _segmentCache         = new RedisSegmentCache(_redisAdapter, _config.RedisUserPrefix);
            _splitParser          = new RedisSplitParser(_segmentCache);
            _splitCache           = new RedisSplitCache(_redisAdapter, _splitParser, _config.RedisUserPrefix);
            _trafficTypeValidator = new TrafficTypeValidator(_splitCache);
        }
Ejemplo n.º 5
0
        private void BuildRedisCache()
        {
            redisAdapter = new RedisAdapter(RedisHost, RedisPort, RedisPassword, RedisDatabase, RedisConnectTimeout, RedisConnectRetry, RedisSyncTimeout);
            if (BlockMilisecondsUntilReady > 0 && !redisAdapter.IsConnected())
            {
                throw new TimeoutException($"SDK was not ready in {BlockMilisecondsUntilReady} miliseconds. Could not connect to Redis");
            }

            splitCache            = new RedisSplitCache(redisAdapter, RedisUserPrefix);
            segmentCache          = new RedisSegmentCache(redisAdapter, RedisUserPrefix);
            metricsCache          = new RedisMetricsCache(redisAdapter, SdkMachineIP, SdkVersion, RedisUserPrefix);
            impressionsCacheRedis = new RedisImpressionsCache(redisAdapter, SdkMachineIP, SdkVersion, RedisUserPrefix);
            eventsCache           = new RedisEventsCache(redisAdapter, SdkMachineName, SdkMachineIP, SdkVersion, RedisUserPrefix);

            _trafficTypeValidator = new TrafficTypeValidator(_log, splitCache);
        }
Ejemplo n.º 6
0
        public SplitClientForTesting(ILog _log,
                                     ISplitCache _splitCache,
                                     Splitter _splitter,
                                     IListener <WrappedEvent> _eventListener,
                                     IListener <KeyImpression> _impressionListener,
                                     IBlockUntilReadyService blockUntilReadyService)
            : base(_log)
        {
            splitCache              = _splitCache;
            splitter                = _splitter;
            eventListener           = _eventListener;
            impressionListener      = _impressionListener;
            _blockUntilReadyService = blockUntilReadyService;
            _trafficTypeValidator   = new TrafficTypeValidator(_log, _splitCache);

            ApiKey = "SplitClientForTesting";
        }
Ejemplo n.º 7
0
        public SplitClientForTesting(ISplitLogger log,
                                     ISplitCache splitCache,
                                     IEventsLog eventsLog,
                                     IImpressionsLog impressionsLog,
                                     IBlockUntilReadyService blockUntilReadyService,
                                     IEvaluator evaluator)
            : base(log)
        {
            _splitCache             = splitCache;
            _eventsLog              = eventsLog;
            _impressionsLog         = impressionsLog;
            _blockUntilReadyService = blockUntilReadyService;
            _trafficTypeValidator   = new TrafficTypeValidator(_splitCache, log);
            _evaluator              = evaluator;

            ApiKey = "SplitClientForTesting";
        }
Ejemplo n.º 8
0
        private void BuildSplitFetcher()
        {
            var segmentRefreshRate = RandomizeRefreshRates ? Random(SegmentRefreshRate) : SegmentRefreshRate;
            var splitsRefreshRate  = RandomizeRefreshRates ? Random(SplitsRefreshRate) : SplitsRefreshRate;

            segmentCache = new InMemorySegmentCache(new ConcurrentDictionary <string, Segment>(ConcurrencyLevel, InitialCapacity));
            var segmentChangeFetcher = new ApiSegmentChangeFetcher(segmentSdkApiClient);

            selfRefreshingSegmentFetcher = new SelfRefreshingSegmentFetcher(segmentChangeFetcher, gates, segmentRefreshRate, segmentCache, NumberOfParalellSegmentTasks);
            var splitChangeFetcher = new ApiSplitChangeFetcher(splitSdkApiClient);
            var splitParser        = new InMemorySplitParser(selfRefreshingSegmentFetcher, segmentCache);

            splitCache   = new InMemorySplitCache(new ConcurrentDictionary <string, ParsedSplit>(ConcurrencyLevel, InitialCapacity));
            splitFetcher = new SelfRefreshingSplitFetcher(splitChangeFetcher, splitParser, gates, splitsRefreshRate, splitCache);

            _trafficTypeValidator = new TrafficTypeValidator(_log, splitCache);
        }
Ejemplo n.º 9
0
        public LocalhostClient(string filePath,
                               ISplitLogger log = null) : base(GetLogger(log))
        {
            _fullPath = LookupFilePath(filePath);

            if (_fullPath.ToLower().EndsWith(SplitFileYaml) || _fullPath.ToLower().EndsWith(SplitFileYml))
            {
                _localhostFileService = new YamlLocalhostFileService();
            }
            else
            {
                _log.Warn("Localhost mode: .split/.splits mocks will be deprecated soon in favor of YAML files, which provide more targeting power. Take a look in our documentation.");

                _localhostFileService = new LocalhostFileService();
            }

            var directoryPath = Path.GetDirectoryName(_fullPath);

            _watcher = new FileSystemWatcher(directoryPath != string.Empty ? directoryPath : Directory.GetCurrentDirectory(), Path.GetFileName(_fullPath))
            {
                NotifyFilter = NotifyFilters.LastWrite
            };

            _watcher.Changed            += new FileSystemEventHandler(OnFileChanged);
            _watcher.EnableRaisingEvents = true;

            var splits = ParseSplitFile(_fullPath);

            _splitCache = new InMemorySplitCache(splits);

            _blockUntilReadyService = new NoopBlockUntilReadyService();
            _manager = new SplitManager(_splitCache, _blockUntilReadyService);

            ApiKey    = "localhost";
            Destroyed = false;

            _trafficTypeValidator = new TrafficTypeValidator(_splitCache);

            BuildEvaluator();

            _impressionsManager = new ImpressionsManager(null, null, null, false, ImpressionsMode.Debug);
        }
Ejemplo n.º 10
0
        private void BuildSplitFetcher()
        {
            var segmentRefreshRate = _config.RandomizeRefreshRates ? Random(_config.SegmentRefreshRate) : _config.SegmentRefreshRate;
            var splitsRefreshRate  = _config.RandomizeRefreshRates ? Random(_config.SplitsRefreshRate) : _config.SplitsRefreshRate;

            _segmentCache = new InMemorySegmentCache(new ConcurrentDictionary <string, Segment>(_config.ConcurrencyLevel, InitialCapacity));

            var segmentChangeFetcher = new ApiSegmentChangeFetcher(_segmentSdkApiClient);
            var segmentTaskQueue     = new SegmentTaskQueue();

            _selfRefreshingSegmentFetcher = new SelfRefreshingSegmentFetcher(segmentChangeFetcher, _gates, segmentRefreshRate, _segmentCache, _config.NumberOfParalellSegmentTasks, segmentTaskQueue);

            var splitChangeFetcher = new ApiSplitChangeFetcher(_splitSdkApiClient);

            _splitParser  = new InMemorySplitParser((SelfRefreshingSegmentFetcher)_selfRefreshingSegmentFetcher, _segmentCache);
            _splitCache   = new InMemorySplitCache(new ConcurrentDictionary <string, ParsedSplit>(_config.ConcurrencyLevel, InitialCapacity));
            _splitFetcher = new SelfRefreshingSplitFetcher(splitChangeFetcher, _splitParser, _gates, splitsRefreshRate, _splitCache);

            _trafficTypeValidator = new TrafficTypeValidator(_splitCache);
        }