Skip to content

Commit 0d01474

Browse files
committed
Reset the settings timer when we actually talk to the server.
1 parent b0b5b95 commit 0d01474

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

Source/Shared/ExceptionlessClient.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ public ExceptionlessClient(ExceptionlessConfiguration configuration) {
3939
_queue = new Lazy<IEventQueue>(() => {
4040
// config can't be changed after the queue starts up.
4141
Configuration.LockConfig();
42-
return Configuration.Resolver.GetEventQueue();
42+
43+
var q = Configuration.Resolver.GetEventQueue();
44+
q.EventsPosted += (sender, args) => {
45+
_updateSettingsTimer.Change(Configuration.UpdateSettingsWhenIdleInterval, Configuration.UpdateSettingsWhenIdleInterval);
46+
};
47+
48+
return q;
4349
});
4450

4551
_submissionClient = new Lazy<ISubmissionClient>(() => Configuration.Resolver.GetSubmissionClient());
@@ -181,7 +187,6 @@ public void SubmitEvent(Event ev, ContextData pluginContextData = null) {
181187
}
182188

183189
OnSubmittedEvent(new EventSubmittedEventArgs(this, ev, pluginContextData));
184-
_updateSettingsTimer.Change(Configuration.UpdateSettingsWhenIdleInterval, Configuration.UpdateSettingsWhenIdleInterval);
185190
}
186191

187192
/// <summary>Creates a new instance of <see cref="Event" />.</summary>

Source/Shared/Queue/DefaultEventQueue.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ public void Process() {
7171
bool deleteBatch = true;
7272

7373
try {
74-
var response = _client.PostEvents(batch.Select(b => b.Item2), _config, _serializer);
74+
var events = batch.Select(b => b.Item2).ToList();
75+
var response = _client.PostEvents(events, _config, _serializer);
7576
if (response.Success) {
7677
_log.FormattedInfo(typeof(DefaultEventQueue), "Sent {0} events to \"{1}\".", batch.Count, _config.ServerUrl);
7778
} else if (response.ServiceUnavailable) {
@@ -104,6 +105,8 @@ public void Process() {
104105
SuspendProcessing();
105106
deleteBatch = false;
106107
}
108+
109+
OnEventsPosted(new EventsPostedEventArgs { Events = events, Response = response });
107110
} catch (AggregateException ex) {
108111
_log.Error(typeof(DefaultEventQueue), ex, String.Concat("An error occurred while submitting events: ", ex.Flatten().Message));
109112
SuspendProcessing();
@@ -162,6 +165,12 @@ public void SuspendProcessing(TimeSpan? duration = null, bool discardFutureQueue
162165
} catch (Exception) { }
163166
}
164167

168+
public event EventHandler<EventsPostedEventArgs> EventsPosted;
169+
170+
protected virtual void OnEventsPosted(EventsPostedEventArgs e) {
171+
EventsPosted?.Invoke(this, e);
172+
}
173+
165174
private bool IsQueueProcessingSuspended {
166175
get { return _suspendProcessingUntil.HasValue && _suspendProcessingUntil.Value > DateTime.Now; }
167176
}

Source/Shared/Queue/IEventQueue.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Threading.Tasks;
34
using Exceptionless.Models;
5+
using Exceptionless.Submission;
46

57
namespace Exceptionless.Queue {
68
public interface IEventQueue : IDisposable {
79
void Enqueue(Event ev);
810
Task ProcessAsync();
911
void SuspendProcessing(TimeSpan? duration = null, bool discardFutureQueuedItems = false, bool clearQueue = false);
12+
event EventHandler<EventsPostedEventArgs> EventsPosted;
13+
}
14+
15+
public class EventsPostedEventArgs : EventArgs {
16+
public SubmissionResponse Response { get; set; }
17+
public ICollection<Event> Events { get; set; }
1018
}
1119
}

0 commit comments

Comments
 (0)