Example #1
0
        public async Task <Trace> Create(ISettings settings, Trace trace)
        {
            IRequest request = _service.CreateRequest(new Uri(settings.BaseAddress), HttpMethod.Post, trace)
                               .AddPath("Trace")
                               .AddJwtAuthorizationToken(settings.GetToken)
            ;
            IResponse <Trace> response = await Policy
                                         .HandleResult <IResponse <Trace> >(res => !res.IsSuccessStatusCode)
                                         .WaitAndRetryAsync(new[] { TimeSpan.FromSeconds(0.2), TimeSpan.FromSeconds(0.5) })
                                         .ExecuteAsync(() => _service.Send <Trace>(request))
            ;

            _restUtil.CheckSuccess(response);
            return(response.Value);
        }
Example #2
0
        public async Task <LogModels.Exception> Create(ISettings settings, LogModels.Exception exception)
        {
            IRequest request = _service.CreateRequest(new Uri(settings.BaseAddress), HttpMethod.Post, exception)
                               .AddPath("Exception")
                               .AddJwtAuthorizationToken(settings.GetToken)
            ;
            IResponse <LogModels.Exception> response = await Policy
                                                       .HandleResult <IResponse <LogModels.Exception> >(res => !res.IsSuccessStatusCode)
                                                       .WaitAndRetryAsync(3, retryAttempt => TimeSpan.FromSeconds(2.0 + Math.Pow(2, retryAttempt)))
                                                       .ExecuteAsync(() => _service.Send <LogModels.Exception>(request))
            ;

            _restUtil.CheckSuccess(response);
            return(response.Value);
        }