Exemple #1
0
 public Synchronizer(ISplitFetcher splitFetcher,
                     ISelfRefreshingSegmentFetcher segmentFetcher,
                     IImpressionsLog impressionsLog,
                     IEventsLog eventsLog,
                     IImpressionsCountSender impressionsCountSender,
                     IWrapperAdapter wrapperAdapter,
                     IStatusManager statusManager,
                     ITelemetrySyncTask telemetrySyncTask,
                     ITasksManager tasksManager,
                     ISplitCache splitCache,
                     IBackOff backOff,
                     int onDemandFetchMaxRetries,
                     int onDemandFetchRetryDelayMs,
                     ISegmentCache segmentCache,
                     ISplitLogger log = null)
 {
     _splitFetcher              = splitFetcher;
     _segmentFetcher            = segmentFetcher;
     _impressionsLog            = impressionsLog;
     _eventsLog                 = eventsLog;
     _impressionsCountSender    = impressionsCountSender;
     _wrapperAdapter            = wrapperAdapter;
     _statusManager             = statusManager;
     _telemetrySyncTask         = telemetrySyncTask;
     _tasksManager              = tasksManager;
     _splitCache                = splitCache;
     _backOffSplits             = backOff;
     _backOffSegments           = backOff;
     _onDemandFetchMaxRetries   = onDemandFetchMaxRetries;
     _onDemandFetchRetryDelayMs = onDemandFetchRetryDelayMs;
     _segmentCache              = segmentCache;
     _log = log ?? WrapperAdapter.GetLogger(typeof(Synchronizer));
     _defaultFetchOptions = new FetchOptions();
 }
Exemple #2
0
 public SplitsWorker(ISplitCache splitCache,
                     ISynchronizer synchronizer,
                     ISplitLogger log = null)
 {
     _splitCache   = splitCache;
     _synchronizer = synchronizer;
     _log          = log ?? WrapperAdapter.GetLogger(typeof(SplitsWorker));
 }
Exemple #3
0
 public RedisSplitManager(ISplitCache splitCache,
                          IBlockUntilReadyService blockUntilReadyService,
                          ILog log = null)
 {
     _splitCache             = splitCache;
     _blockUntilReadyService = blockUntilReadyService;
     _log = log ?? LogManager.GetLogger(typeof(RedisSplitManager));
     _splitNameValidator = new SplitNameValidator(_log);
 }
 public SplitsWorker(ISplitCache splitCache,
                     ISynchronizer synchronizer,
                     ISplitLogger log = null)
 {
     _splitCache   = splitCache;
     _synchronizer = synchronizer;
     _log          = log ?? WrapperAdapter.GetLogger(typeof(SplitsWorker));
     _queue        = new BlockingCollection <long>(new ConcurrentQueue <long>());
 }
Exemple #5
0
 public SplitManager(ISplitCache splitCache,
                     IBlockUntilReadyService blockUntilReadyService,
                     ISplitLogger log = null)
 {
     _splitCache             = splitCache;
     _log                    = log ?? WrapperAdapter.GetLogger(typeof(SplitManager));
     _splitNameValidator     = new SplitNameValidator(_log);
     _blockUntilReadyService = blockUntilReadyService;
 }
Exemple #6
0
 public SelfRefreshingSplitFetcher(ISplitChangeFetcher splitChangeFetcher,
                                   SplitParser splitParser, IReadinessGatesCache gates, int interval, ISplitCache splitCache = null)
 {
     this.splitChangeFetcher = splitChangeFetcher;
     this.splitParser        = splitParser;
     this.gates      = gates;
     this.interval   = interval;
     this.splitCache = splitCache;
 }
Exemple #7
0
 public Evaluator(ISplitCache splitCache,
                  ISplitParser splitParser,
                  ISplitter splitter = null,
                  ISplitLogger log   = null)
 {
     _splitCache  = splitCache;
     _splitParser = splitParser;
     _splitter    = splitter ?? new Splitter();
     _log         = log ?? WrapperAdapter.GetLogger(typeof(Evaluator));
 }
Exemple #8
0
 public SelfRefreshingSplitFetcher(ISplitChangeFetcher splitChangeFetcher,
                                   ISplitParser splitParser,
                                   IStatusManager statusManager,
                                   int interval,
                                   ITasksManager taskManager,
                                   ISplitCache splitCache = null)
 {
     _splitChangeFetcher = splitChangeFetcher;
     _splitParser        = splitParser;
     _statusManager      = statusManager;
     _interval           = interval;
     _splitCache         = splitCache;
     _taskManager        = taskManager;
 }
        public SelfRefreshingSplitFetcher(ISplitChangeFetcher splitChangeFetcher,
                                          ISplitParser splitParser,
                                          IReadinessGatesCache gates,
                                          int interval,
                                          ISplitCache splitCache = null)
        {
            _cancelTokenSource = new CancellationTokenSource();

            _splitChangeFetcher = splitChangeFetcher;
            _splitParser        = splitParser;
            _gates      = gates;
            _interval   = interval;
            _splitCache = splitCache;
        }
Exemple #10
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";
        }
        public JSONFileClient(string splitsFilePath,
                              string segmentsFilePath,
                              ISplitLogger log = null,
                              ISegmentCache segmentCacheInstance = null,
                              ISplitCache splitCacheInstance     = null,
                              IImpressionsLog impressionsLog     = null,
                              bool isLabelsEnabled = true,
                              IEventsLog eventsLog = null,
                              ITrafficTypeValidator trafficTypeValidator = null,
                              IImpressionsManager impressionsManager     = null) : base(GetLogger(log))
        {
            _segmentCache = segmentCacheInstance ?? new InMemorySegmentCache(new ConcurrentDictionary <string, Segment>());

            var segmentFetcher     = new JSONFileSegmentFetcher(segmentsFilePath, _segmentCache);
            var splitChangeFetcher = new JSONFileSplitChangeFetcher(splitsFilePath);
            var task = splitChangeFetcher.Fetch(-1);

            task.Wait();

            var splitChangesResult = task.Result;
            var parsedSplits       = new ConcurrentDictionary <string, ParsedSplit>();

            _splitParser = new InMemorySplitParser(segmentFetcher, _segmentCache);

            foreach (var split in splitChangesResult.splits)
            {
                parsedSplits.TryAdd(split.name, _splitParser.Parse(split));
            }

            _splitCache = splitCacheInstance ?? new InMemorySplitCache(new ConcurrentDictionary <string, ParsedSplit>(parsedSplits));

            _impressionsLog = impressionsLog;

            LabelsEnabled = isLabelsEnabled;

            _eventsLog            = eventsLog;
            _trafficTypeValidator = trafficTypeValidator;

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

            ApiKey = "localhost";

            BuildEvaluator(log);
            _impressionsManager = impressionsManager ?? new ImpressionsManager(impressionsLog, null, null, false, ImpressionsMode.Debug);
        }
        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";
        }
Exemple #13
0
        public JSONFileClient(string splitsFilePath,
                              string segmentsFilePath,
                              ILog log,
                              ISegmentCache segmentCacheInstance             = null,
                              ISplitCache splitCacheInstance                 = null,
                              IListener <KeyImpression> treatmentLogInstance = null,
                              bool isLabelsEnabled = true,
                              IListener <WrappedEvent> _eventListener    = null,
                              ITrafficTypeValidator trafficTypeValidator = null)  : base(log)
        {
            segmentCache = segmentCacheInstance ?? new InMemorySegmentCache(new ConcurrentDictionary <string, Segment>());

            var segmentFetcher     = new JSONFileSegmentFetcher(segmentsFilePath, segmentCache);
            var splitParser        = new InMemorySplitParser(segmentFetcher, segmentCache);
            var splitChangeFetcher = new JSONFileSplitChangeFetcher(splitsFilePath);
            var task = splitChangeFetcher.Fetch(-1);

            task.Wait();

            var splitChangesResult = task.Result;
            var parsedSplits       = new ConcurrentDictionary <string, ParsedSplit>();

            foreach (Split split in splitChangesResult.splits)
            {
                parsedSplits.TryAdd(split.name, splitParser.Parse(split));
            }

            splitCache         = splitCacheInstance ?? new InMemorySplitCache(new ConcurrentDictionary <string, ParsedSplit>(parsedSplits));
            impressionListener = treatmentLogInstance;
            splitter           = new Splitter();
            LabelsEnabled      = isLabelsEnabled;

            eventListener         = _eventListener;
            _trafficTypeValidator = trafficTypeValidator;

            _blockUntilReadyService = new NoopBlockUntilReadyService();
            manager = new SplitManager(splitCache, _blockUntilReadyService, log);

            ApiKey = "localhost";
        }
Exemple #14
0
        public TelemetrySyncTask(ITelemetryStorageConsumer telemetryStorage,
                                 ITelemetryAPI telemetryAPI,
                                 ISplitCache splitCache,
                                 ISegmentCache segmentCache,
                                 SelfRefreshingConfig configurationOptions,
                                 IFactoryInstantiationsService factoryInstantiationsService,
                                 IWrapperAdapter wrapperAdapter,
                                 ITasksManager tasksManager,
                                 ISplitLogger log = null)
        {
            _telemetryStorageConsumer = telemetryStorage;
            _telemetryAPI             = telemetryAPI;
            _splitCache                   = splitCache;
            _segmentCache                 = segmentCache;
            _configurationOptions         = configurationOptions;
            _factoryInstantiationsService = factoryInstantiationsService;
            _log            = log ?? WrapperAdapter.GetLogger(typeof(TelemetrySyncTask));
            _wrapperAdapter = wrapperAdapter;
            _tasksManager   = tasksManager;

            _cancellationTokenSource = new CancellationTokenSource();
        }
Exemple #15
0
        public JSONFileClient(string splitsFilePath, string segmentsFilePath, ISegmentCache segmentCacheInstance = null, ISplitCache splitCacheInstance = null, IImpressionListener treatmentLogInstance = null, bool isLabelsEnabled = true)
        {
            segmentCache = segmentCacheInstance ?? new InMemorySegmentCache(new ConcurrentDictionary <string, Segment>());
            var segmentFetcher     = new JSONFileSegmentFetcher(segmentsFilePath, segmentCache);
            var splitParser        = new InMemorySplitParser(segmentFetcher, segmentCache);
            var splitChangeFetcher = new JSONFileSplitChangeFetcher(splitsFilePath);
            var splitChangesResult = splitChangeFetcher.Fetch(-1);
            var parsedSplits       = new ConcurrentDictionary <string, ParsedSplit>();

            foreach (Split split in splitChangesResult.splits)
            {
                parsedSplits.TryAdd(split.name, splitParser.Parse(split));
            }
            splitCache         = splitCacheInstance ?? new InMemorySplitCache(new ConcurrentDictionary <string, ParsedSplit>(parsedSplits));
            impressionListener = treatmentLogInstance;
            splitter           = new Splitter();
            LabelsEnabled      = isLabelsEnabled;
            manager            = new SplitManager(splitCache);
        }
Exemple #16
0
 public TrafficTypeValidator(ISplitCache splitCache, ISplitLogger log = null)
 {
     _log        = log ?? WrapperAdapter.GetLogger(typeof(TrafficTypeValidator));
     _splitCache = splitCache;
 }
Exemple #17
0
 public SplitManager(ISplitCache splitCache)
 {
     this.splitCache = splitCache;
 }
Exemple #18
0
 public TrafficTypeValidator(ILog log, ISplitCache splitCache)
 {
     _log        = log;
     _splitCache = splitCache;
 }