From eb065178c9f0575db391047a7045eda248cf3dcf Mon Sep 17 00:00:00 2001 From: tudor <7089284+tudddorrr@users.noreply.github.com> Date: Mon, 16 Sep 2024 19:02:10 +0100 Subject: [PATCH] add continuity replay exception --- .../Runtime/Utils/ContinuityManager.cs | 14 ++++++++++- .../Utils/ContinuityReplayException.cs | 23 +++++++++++++++++++ .../Utils/ContinuityReplayException.cs.meta | 11 +++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 Packages/com.trytalo.talo/Runtime/Utils/ContinuityReplayException.cs create mode 100644 Packages/com.trytalo.talo/Runtime/Utils/ContinuityReplayException.cs.meta diff --git a/Packages/com.trytalo.talo/Runtime/Utils/ContinuityManager.cs b/Packages/com.trytalo.talo/Runtime/Utils/ContinuityManager.cs index c8b2fec..3cc985b 100644 --- a/Packages/com.trytalo.talo/Runtime/Utils/ContinuityManager.cs +++ b/Packages/com.trytalo.talo/Runtime/Utils/ContinuityManager.cs @@ -81,6 +81,7 @@ public async void ProcessRequests() if (!HasRequests() || !await Talo.HealthCheck.Ping()) return; var queue = new List(_requests.Take(10)); + var exceptions = new List(); for (var i = 0; i < queue.Count; i++) { @@ -98,7 +99,18 @@ public async void ProcessRequests() headers.Add(new HttpHeader("X-Talo-Continuity-Timestamp", request.timestamp.ToString())); } - await _api.Replay(uri, request.method, request.content, headers); + try + { + await _api.Replay(uri, request.method, request.content, headers); + } catch (Exception e) + { + exceptions.Add(e); + } + } + + if (exceptions.Count > 0) + { + throw new ContinuityReplayException(exceptions); } } } diff --git a/Packages/com.trytalo.talo/Runtime/Utils/ContinuityReplayException.cs b/Packages/com.trytalo.talo/Runtime/Utils/ContinuityReplayException.cs new file mode 100644 index 0000000..3ba3299 --- /dev/null +++ b/Packages/com.trytalo.talo/Runtime/Utils/ContinuityReplayException.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; + +namespace TaloGameServices +{ + public class ContinuityReplayException : Exception + { + private List _exceptions; + public List Exceptions => _exceptions; + + public ContinuityReplayException(List exceptions) + : base($"{exceptions.Count} requests failed after being replayed") + { + _exceptions = exceptions; + } + + public ContinuityReplayException(List exceptions, Exception inner) + : base($"{exceptions.Count} requests failed after being replayed", inner) + { + _exceptions = exceptions; + } + } +} diff --git a/Packages/com.trytalo.talo/Runtime/Utils/ContinuityReplayException.cs.meta b/Packages/com.trytalo.talo/Runtime/Utils/ContinuityReplayException.cs.meta new file mode 100644 index 0000000..390c9be --- /dev/null +++ b/Packages/com.trytalo.talo/Runtime/Utils/ContinuityReplayException.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 655c3136079e8478fb4a6df9b5f4531c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: