Esempio n. 1
0
        internal Channel(string name, int maxLogsPerBatch, TimeSpan batchTimeInterval, int maxParallelBatches,
                         string appSecret, IIngestion ingestion, IStorage storage)
        {
            Name = name;
            _maxParallelBatches = maxParallelBatches;
            _maxLogsPerBatch    = maxLogsPerBatch;
            _appSecret          = appSecret;
            _ingestion          = ingestion;
            _storage            = storage;
            _batchTimeInterval  = batchTimeInterval;
            _batchScheduled     = false;
            _enabled            = true;
            DeviceInformationHelper.InformationInvalidated += (sender, e) => InvalidateDeviceCache();
            var lockHolder = _mutex.GetLock();

            Task.Run(() => _storage.CountLogsAsync(Name)).ContinueWith(task =>
            {
                if (!task.IsFaulted && !task.IsCanceled)
                {
                    _pendingLogCount = task.Result;
                }
                lockHolder.Dispose();
                CheckPendingLogs(_mutex.State);
            });
        }
 protected ServiceCall(IIngestion ingestion, IList <Log> logs, string appSecret, Guid installId)
 {
     Ingestion = ingestion;
     Logs      = logs;
     AppSecret = appSecret;
     InstallId = installId;
 }
 public RetryableIngestion(IIngestion decoratedApi, Func <Task>[] retryIntervals) : base(decoratedApi)
 {
     if (retryIntervals == null)
     {
         throw new ArgumentNullException(nameof(retryIntervals));
     }
     _retryIntervals = retryIntervals;
 }
Esempio n. 4
0
        private void SetChannelWithTimeSpanAndIngestion(TimeSpan timeSpan, IIngestion ingestion)
        {
            _storage = new MockStorage();
            var appSecret = Guid.NewGuid().ToString();

            _channel = new Channel(ChannelName, MaxLogsPerBatch, timeSpan, MaxParallelBatches,
                                   appSecret, ingestion, _storage);
            SetupEventCallbacks();
        }
        public void InitializeRetryableTest()
        {
            _adapter            = new Mock <IHttpNetworkAdapter>();
            _retryableIngestion = new RetryableIngestion(new IngestionHttp(_adapter.Object), Intervals);
            AppCenter.Instance  = null;
#pragma warning disable 612
            AppCenter.SetApplicationSettingsFactory(new MockApplicationSettingsFactory(_settingsMock));
            _settingsMock.Setup(settings => settings.GetValue(AppCenter.AllowedNetworkRequestsKey, It.IsAny <bool>())).Returns(true);
#pragma warning restore 612
        }
 public RetryableIngestion(IIngestion decoratedApi, TimeSpan[] retryIntervals) : base(decoratedApi)
 {
     if (retryIntervals == null)
     {
         throw new ArgumentNullException(nameof(retryIntervals));
     }
     _retryIntervals = new Func <Task> [retryIntervals.Length];
     for (int i = 0; i < retryIntervals.Length; i++)
     {
         _retryIntervals[i] = GetDelayFunc(retryIntervals, i);
     }
 }
Esempio n. 7
0
        public RetryableIngestion(IIngestion decoratedApi)
            : base(decoratedApi)
        {
            var random = new Random();

            _retryIntervals = DefaultIntervals.Select(defaultInterval =>
            {
                var interval = (int)(defaultInterval.TotalMilliseconds / 2.0);
                interval    += random.Next(interval);
                return(TimeSpan.FromMilliseconds(interval));
            }).ToArray();
        }
Esempio n. 8
0
 internal Channel(string name, int maxLogsPerBatch, TimeSpan batchTimeInterval, int maxParallelBatches,
                  string appSecret, IIngestion ingestion, IStorage storage)
 {
     _mutex = new StatefulMutex(_stateKeeper);
     Name   = name;
     _maxParallelBatches = maxParallelBatches;
     _maxLogsPerBatch    = maxLogsPerBatch;
     _appSecret          = appSecret;
     _ingestion          = ingestion;
     _storage            = storage;
     _batchTimeInterval  = batchTimeInterval;
     _batchScheduled     = false;
     _enabled            = true;
     DeviceInformationHelper.InformationInvalidated += (sender, e) => InvalidateDeviceCache();
     Task.Run(CountFromDiskAsync);
 }
        public void InitializeRetryableTest()
        {
            _adapter   = new Mock <IHttpNetworkAdapter>();
            _intervals = new[]
            {
                new TestInterval(),
                new TestInterval(),
                new TestInterval()
            };
            var retryIntervals = new Func <Task> [_intervals.Length];

            for (int i = 0; i < _intervals.Length; i++)
            {
                retryIntervals[i] = _intervals[i].Wait;
            }
            _retryableIngestion = new RetryableIngestion(new IngestionHttp(_adapter.Object), retryIntervals);
        }
Esempio n. 10
0
 public NetworkStateIngestion(IIngestion decoratedApi) :
     this(decoratedApi, new NetworkStateAdapter())
 {
 }
 public NetworkStateIngestion(IIngestion decoratedApi, INetworkStateAdapter networkStateAdapter)
     : base(decoratedApi)
 {
     _networkStateAdapter = networkStateAdapter;
 }
Esempio n. 12
0
 public RetryableIngestion(IIngestion decoratedApi, TimeSpan[] retryIntervals)
     : base(decoratedApi)
 {
     _retryIntervals = retryIntervals ?? throw new ArgumentNullException(nameof(retryIntervals));
 }
 internal ChannelGroup(IIngestion ingestion, IStorage storage, string appSecret)
 {
     _ingestion = ingestion;
     _storage   = storage;
     AppSecret  = appSecret;
 }
 public RetryableIngestion(IIngestion decoratedApi)
     : this(decoratedApi, DefaultIntervals)
 {
 }
Esempio n. 15
0
 public void InitializeRetryableTest()
 {
     _adapter            = new Mock <IHttpNetworkAdapter>();
     _retryableIngestion = new RetryableIngestion(new IngestionHttp(_adapter.Object), Intervals);
 }
 public MockServiceCall(IIngestion ingestion, IList <Log> logs, string appSecret, Guid installId) : base(ingestion, logs, appSecret, installId)
 {
 }
Esempio n. 17
0
 protected IngestionDecorator(IIngestion decoratedApi)
 {
     DecoratedApi = decoratedApi;
 }
Esempio n. 18
0
 public NetworkStateIngestion(IIngestion decoratedApi, INetworkStateAdapter networkState)
     : base(decoratedApi)
 {
     _networkState = networkState;
     _networkState.NetworkAddressChanged += HandleNetworkAddressChanged;
 }
Esempio n. 19
0
 public NetworkStateIngestion(IIngestion decoratedApi, INetworkStateAdapter networkStateAdapter)
     : base(decoratedApi)
 {
     _networkStateAdapter = networkStateAdapter;
     _networkStateAdapter.NetworkStatusChanged += OnNetworkStateChange;
 }