示例#1
0
        public SelfRefreshingSegment(string name, ISegmentChangeFetcher segmentChangeFetcher, ISegmentCache segmentCache)
        {
            Name = name;

            _segmentChangeFetcher = segmentChangeFetcher;
            _segmentCache         = segmentCache;
        }
示例#2
0
 public SelfRefreshingSegment(string name, ISegmentChangeFetcher segmentChangeFetcher, IReadinessGatesCache gates, ISegmentCache segmentCache)
 {
     this.name = name;
     this.segmentChangeFetcher = segmentChangeFetcher;
     this.segmentCache         = segmentCache;
     this.gates = gates;
 }
示例#3
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();
 }
示例#4
0
 public SegmentsWorker(ISegmentCache segmentCache,
                       ISynchronizer synchronizer,
                       ISplitLogger log = null)
 {
     _segmentCache = segmentCache;
     _synchronizer = synchronizer;
     _log          = log ?? WrapperAdapter.GetLogger(typeof(SegmentsWorker));
 }
示例#5
0
        public SelfRefreshingSegment(string name, ISegmentChangeFetcher segmentChangeFetcher, IReadinessGatesCache gates, ISegmentCache segmentCache)
        {
            Name = name;

            _segmentChangeFetcher = segmentChangeFetcher;
            _segmentCache         = segmentCache;
            _gates = gates;
            _gates.RegisterSegment(name);
        }
示例#6
0
 public JSONFileSegmentFetcher(string filePath, ISegmentCache segmentsCache) : base(segmentsCache)
 {
     if (!string.IsNullOrEmpty(filePath))
     {
         var json = File.ReadAllText(filePath);
         var segmentChangesResult = JsonConvert.DeserializeObject <SegmentChange>(json);
         added = segmentChangesResult.added;
     }
 }
示例#7
0
 public SegmentsWorker(ISegmentCache segmentCache,
                       ISynchronizer synchronizer,
                       ISplitLogger log = null)
 {
     _segmentCache = segmentCache;
     _synchronizer = synchronizer;
     _log          = log ?? WrapperAdapter.GetLogger(typeof(SegmentsWorker));
     _queue        = new BlockingCollection <SegmentQueueDto>(new ConcurrentQueue <SegmentQueueDto>());
 }
示例#8
0
        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);
        }
示例#9
0
        public SelfRefreshingSegmentFetcher(ISegmentChangeFetcher segmentChangeFetcher,
                                            IReadinessGatesCache gates,
                                            int interval,
                                            ISegmentCache segmentsCache,
                                            int numberOfParallelSegments) : base(segmentsCache)
        {
            _cancelTokenSource = new CancellationTokenSource();

            _segmentChangeFetcher = segmentChangeFetcher;
            _segments             = new ConcurrentDictionary <string, SelfRefreshingSegment>();
            _worker         = new SegmentTaskWorker(numberOfParallelSegments);
            _interval       = interval;
            _gates          = gates;
            _wrappedAdapter = new WrapperAdapter();

            StartWorker();
        }
示例#10
0
 public SelfRefreshingSegmentFetcher(ISegmentChangeFetcher segmentChangeFetcher,
                                     IStatusManager statusManager,
                                     int interval,
                                     ISegmentCache segmentsCache,
                                     int numberOfParallelSegments,
                                     ISegmentTaskQueue segmentTaskQueue,
                                     ITasksManager tasksManager,
                                     IWrapperAdapter wrapperAdapter) : base(segmentsCache)
 {
     _segmentChangeFetcher = segmentChangeFetcher;
     _segments             = new ConcurrentDictionary <string, SelfRefreshingSegment>();
     _worker           = new SegmentTaskWorker(numberOfParallelSegments, segmentTaskQueue);
     _interval         = interval;
     _statusManager    = statusManager;
     _wrappedAdapter   = wrapperAdapter;
     _segmentTaskQueue = segmentTaskQueue;
     _tasksManager     = tasksManager;
 }
示例#11
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);
        }
示例#12
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";
        }
示例#13
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();
        }
示例#14
0
 public SegmentFetcher(ISegmentCache segmentCache)
 {
     _segmentCache = segmentCache;
 }
示例#15
0
 public UserDefinedSegmentMatcher(string segmentName, ISegmentCache segmentsCache)
 {
     this.segmentName   = segmentName;
     this.segmentsCache = segmentsCache;
 }
示例#16
0
 public InMemorySplitParser(ISegmentFetcher segmentFetcher, ISegmentCache segmentsCache)
 {
     this.segmentFetcher = segmentFetcher;
     this.segmentsCache  = segmentsCache;
 }
示例#17
0
 public SegmentFetcher(ISegmentCache segmentCache)
 {
     this.segmentCache = segmentCache ?? new InMemorySegmentCache(new ConcurrentDictionary <string, Segment>());
 }
示例#18
0
 public RedisSplitParser(ISegmentCache segmentsCache)
 {
     this.segmentsCache = segmentsCache;
 }
示例#19
0
 public SelfRefreshingSegmentFetcher(ISegmentChangeFetcher segmentChangeFetcher, IReadinessGatesCache gates, int interval, ISegmentCache segmentsCache, int numberOfParallelSegments) : base(segmentsCache)
 {
     this.segmentChangeFetcher = segmentChangeFetcher;
     this.segments             = new ConcurrentDictionary <string, SelfRefreshingSegment>();
     worker        = new SegmentTaskWorker(numberOfParallelSegments);
     this.interval = interval;
     this.gates    = gates;
     StartWorker();
 }