예제 #1
0
        private void Run()
        {
            if (_variationsCountMap.Any())
            {
                IDictionary <string, AtomicLong> copyOfVariationsCountMap;
                lock (_variationsCountMap)
                {
                    copyOfVariationsCountMap = new Dictionary <string, AtomicLong>(_variationsCountMap);
                    _variationsCountMap.Clear();
                }

                Logger.Debug($"{copyOfVariationsCountMap.Count} flag counts will be sent to the server.");

                foreach (var pair in copyOfVariationsCountMap)
                {
                    var temp    = pair.Key.Split(':');
                    var flagKey = temp[0];
                    var mapKey  = temp[1];

                    var e = new UnlaunchEvent
                    {
                        type = UnlaunchConstants.FlagInvocationsCountEventType,
                        key  = flagKey
                    };
                    e.properties.Add(mapKey, pair.Value.Get());

                    try
                    {
                        _eventHandler.Handle(e);
                        _eventHandler.Flush();
                    }
                    catch (Exception ex)
                    {
                        Logger.Error("An error occurred sending event counts to the service", ex);
                    }
                }
            }
        }
예제 #2
0
        public bool Handle(UnlaunchEvent unlaunchEvent)
        {
            if (!_enabled || unlaunchEvent == null || _closed.Get())
            {
                return(false);
            }

            try
            {
                _queue.Enqueue(unlaunchEvent);
                if (_queue.Count >= _maxBufferSize)
                {
                    Logger.Debug("maximum buffer sized reached. flushing.");
                    CreateFlushEventsTask();
                }

                return(true);
            }
            catch (ThreadInterruptedException)
            {
                Logger.Warn($"Interrupted while adding event to the queue {unlaunchEvent}. ({_name})");
                return(false);
            }
        }
예제 #3
0
 public bool Handle(UnlaunchEvent unlaunchEvent)
 {
     IncrementFlagVariation(unlaunchEvent.key, unlaunchEvent.secondaryKey);
     return(true);
 }