public override async Task OnBatchAsync(IEnumerable <T> batch, IFeedbackSender feedbackSender, CancellationToken cancellationToken) { var invocationSuccess = false; var exceptions = new List <Exception>(); var tryCount = 0; while (tryCount == 0 || (!invocationSuccess && ShouldRetry(tryCount, exceptions))) { if (tryCount > 0 && InvokeRetryWaitMilliseconds > 0) { await Task.Delay(InvokeRetryWaitMilliseconds, cancellationToken).ConfigureAwait(false); } tryCount++; invocationSuccess = await TryInvokeBatchAsync(batch, exceptions, cancellationToken).ConfigureAwait(false); } if (invocationSuccess) { feedbackSender.Ack(); } else if (ShouldRequeue(exceptions)) { feedbackSender.Nack(true); } else { feedbackSender.Nack(false); } }
public PlayerFeedbackController( IQueryHandler queryHandler, IFeedbackSender feedbackSender, IClock clock ) { _queryHandler = queryHandler; _feedbackSender = feedbackSender; _clock = clock; }
public FeedbackLoader(Config config, IFeedbackSender sender) { this.config = config; this.sender = sender; var template = File.ReadAllText("Content/template.html"); _indexHtml = template.Replace(MARKDOWN_REPLACE_TEXT, File.ReadAllText("Content/Feedback/feedback.html")); _errorHtml = _indexHtml.Replace(MESSAGE_REPLACE_TEXT, File.ReadAllText("Content/Feedback/feedback_error.html")); _successHtml = _indexHtml.Replace(MESSAGE_REPLACE_TEXT, File.ReadAllText("Content/Feedback/feedback_success.html")); }
public override Task OnBatchAsync(IEnumerable <T> batch, IFeedbackSender feedbackSender, CancellationToken cancellationToken) { if (_batchCallbackAction == null) { throw new Exception("Undefined batch callback action"); } try { _batchCallbackAction(batch); feedbackSender.Ack(); } catch (Exception e) { feedbackSender.Nack(true); } return(Task.FromResult(0)); }
public override async Task OnBatchAsync(IEnumerable <T> batch, IFeedbackSender feedbackSender, CancellationToken cancellationToken) { if (_batchCallbackFunc == null) { throw new Exception("Undefined batch callback function"); } try { using (var tokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken)) { tokenSource.CancelAfter(_processingTimeout); await _batchCallbackFunc(batch, tokenSource.Token).ConfigureAwait(false); } feedbackSender.Ack(); } catch (Exception e) { feedbackSender.Nack(true); } }
public void Configure(IApplicationBuilder app) { _loader = new PageLoader(); _favicon = new FaviconLoader(); _feebackSender = new FeedbackSmtpSender(new FeedbackSmtpSender.Config { from = "", to = "", subject = "Hello from DumBlog" }); //_feebackSender = new FeedbackDiscordSender(new FeedbackDiscordSender.Config //{ // clientId = "", // secret = "", // channelId = "", // code = "", // redirectUrl = "" //}); _feeback = new FeedbackLoader(new FeedbackLoader.Config { captcha = (DateTime.Now.Year + 1).ToString(), }, _feebackSender); app.Run(HttpRequestDelegate); }
public MockEngineFactory(string root, IFeedbackSender sender) { Root = root; _sender = sender; }
public override async Task OnMessageAsync(T message, RabbitMQConsumerContext consumerContext, IFeedbackSender feedbackSender, CancellationToken cancellationToken) { try { using (var tokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken)) { tokenSource.CancelAfter(_processingTimeout); await _callbackFunc(message, consumerContext, tokenSource.Token).ConfigureAwait(false); } feedbackSender.Ack(); } catch (Exception e) { feedbackSender.Nack(true); } }
public abstract Task OnBatchAsync(IEnumerable <T> batch, IFeedbackSender feedbackSender, CancellationToken cancellationToken);
public abstract Task OnMessageAsync(T message, RabbitMQConsumerContext consumerContext, IFeedbackSender feedbackSender, CancellationToken cancellationToken);
static FeedbackFileSender() { Instance = new FeedbackFileSender("feedback.txt"); }
public override Task OnMessageAsync(T message, RabbitMQConsumerContext consumerContext, IFeedbackSender feedbackSender, CancellationToken cancellationToken) { try { _callbackAction(message, consumerContext); feedbackSender.Ack(); } catch (Exception e) { feedbackSender.Nack(true); } return(Task.FromResult(0)); }
public override async Task OnMessageAsync(T message, RabbitMQConsumerContext consumerContext, IFeedbackSender feedbackSender, CancellationToken cancellationToken) { var invocationSuccess = false; var exceptions = new List <Exception>(); var tryCount = 0; while (tryCount == 0 || (!invocationSuccess && ShouldRetry(tryCount, exceptions))) { if (tryCount > 0 && InvokeRetryWaitMilliseconds > 0) { await Task.Delay(InvokeRetryWaitMilliseconds, cancellationToken).ConfigureAwait(false); } tryCount++; invocationSuccess = await TryInvokeAsync(message, consumerContext, exceptions, cancellationToken).ConfigureAwait(false); } if (invocationSuccess) { feedbackSender.Ack(); } else if (ShouldRequeue(exceptions)) { feedbackSender.Nack(true); Logger.LogWarning(new AggregateException(exceptions), $"Message successfully processed, but exceptions were thrown after {tryCount} tries"); } else { feedbackSender.Nack(false); Logger.LogError(new AggregateException(exceptions), $"Unable to successfully process message after {tryCount} tries"); } }