-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
177/circuit breaker #419
177/circuit breaker #419
Changes from 8 commits
f3bfb04
19375d9
baf86b4
071678a
061b635
23094eb
2d12980
5ae75ac
72c4175
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
|
||
namespace Planar.Client.Entities | ||
{ | ||
public class JobCircuitBreaker | ||
{ | ||
public int FailureThreshold { get; set; } | ||
public int SuccessThreshold { get; set; } | ||
public TimeSpan? PauseSpan { get; set; } | ||
public int FailCounter { get; set; } | ||
public int SuccessCounter { get; set; } | ||
public DateTime? WillBeResetAt { get; set; } | ||
public DateTime? ActivatedAt { get; set; } | ||
public bool Activated => ActivatedAt.HasValue; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.1" /> | ||
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Align package versions across different target frameworks. The project file specifies different versions of Consider updating the version for - <PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.1" />
+ <PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" /> Also applies to: 33-33 |
||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,73 @@ | ||
using Planar; | ||
using IJobExecutionContext = Quartz.IJobExecutionContext; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using IJobExecutionContext = Quartz.IJobExecutionContext; | ||
|
||
namespace CommonJob; | ||
|
||
namespace CommonJob | ||
public class JobExecutionMetadata | ||
{ | ||
public class JobExecutionMetadata | ||
{ | ||
public StringBuilder Log { get; set; } = new StringBuilder(); | ||
public StringBuilder Log { get; set; } = new StringBuilder(); | ||
|
||
public List<ExceptionDto> Exceptions { get; set; } = new List<ExceptionDto>(); | ||
public List<ExceptionDto> Exceptions { get; set; } = new List<ExceptionDto>(); | ||
|
||
public int? EffectedRows { get; set; } | ||
public int? EffectedRows { get; set; } | ||
|
||
public byte Progress { get; set; } | ||
public byte Progress { get; set; } | ||
|
||
public bool HasWarnings { get; set; } | ||
public bool HasWarnings { get; set; } | ||
|
||
private static readonly object Locker = new(); | ||
private static readonly object Locker = new(); | ||
|
||
public string GetLog() | ||
public string GetLog() | ||
{ | ||
return Log.ToString(); | ||
} | ||
|
||
public string GetExceptionsText() | ||
{ | ||
var exceptions = Exceptions; | ||
if (exceptions == null || exceptions.Count == 0) | ||
{ | ||
return Log.ToString(); | ||
return string.Empty; | ||
} | ||
|
||
public string GetExceptionsText() | ||
if (exceptions.Count == 1) | ||
{ | ||
var exceptions = Exceptions; | ||
if (exceptions == null || exceptions.Count == 0) | ||
{ | ||
return string.Empty; | ||
} | ||
|
||
if (exceptions.Count == 1) | ||
{ | ||
return exceptions[0].ExceptionText ?? string.Empty; | ||
} | ||
return exceptions[0].ExceptionText ?? string.Empty; | ||
} | ||
|
||
var seperator = string.Empty.PadLeft(80, '-'); | ||
var sb = new StringBuilder(); | ||
sb.AppendLine($"There is {exceptions.Count} aggregate exception"); | ||
exceptions.ForEach(e => sb.AppendLine($" - {e.Message}")); | ||
var seperator = string.Empty.PadLeft(80, '-'); | ||
var sb = new StringBuilder(); | ||
sb.AppendLine($"There is {exceptions.Count} aggregate exception"); | ||
exceptions.ForEach(e => sb.AppendLine($" - {e.Message}")); | ||
sb.AppendLine(seperator); | ||
exceptions.ForEach(e => | ||
{ | ||
sb.AppendLine(e.ExceptionText); | ||
sb.AppendLine(seperator); | ||
exceptions.ForEach(e => | ||
{ | ||
sb.AppendLine(e.ExceptionText); | ||
sb.AppendLine(seperator); | ||
}); | ||
}); | ||
|
||
return sb.ToString(); | ||
} | ||
return sb.ToString(); | ||
} | ||
|
||
public Exception? UnhandleException { get; set; } | ||
public Exception? UnhandleException { get; set; } | ||
|
||
public bool IsRunningFail => !IsRunningSuccess; | ||
public bool IsRunningSuccess => UnhandleException == null; | ||
public bool IsRunningFail => !IsRunningSuccess; | ||
public bool IsRunningSuccess => UnhandleException == null; | ||
|
||
public static JobExecutionMetadata GetInstance(IJobExecutionContext context) | ||
public static JobExecutionMetadata GetInstance(IJobExecutionContext context) | ||
{ | ||
lock (Locker) | ||
{ | ||
lock (Locker) | ||
if (context.Result is not JobExecutionMetadata result) | ||
{ | ||
if (context.Result is not JobExecutionMetadata result) | ||
{ | ||
result = new JobExecutionMetadata(); | ||
context.Result = result; | ||
} | ||
|
||
return result; | ||
result = new JobExecutionMetadata(); | ||
context.Result = result; | ||
} | ||
|
||
return result; | ||
Comment on lines
+60
to
+70
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thread-safe singleton implementation in The method However, the use of |
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,12 @@ properties: # Job Properties | |
username: null # local or network username (any OS) [up to 100 characters] | ||
password: null # The active directory password (only on windows OS) [up to 100 characters] | ||
|
||
circuit breaker: | ||
enabled: true # Boolean [true/false]. Enable/Disable the circuit breaker | ||
failure threshold: 5 # The number of failures that will trip the circuit breaker [2 to 100] | ||
success threshold: 1 # The number of successes that will reset the circuit breaker [1 to 100] | ||
pause span: 01:00:00 # The time span which the circuit breaker will pause the job execution. set null value for permanent pause. minimum value is 5 minutes | ||
|
||
Comment on lines
+21
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Review of the new 'circuit breaker' configuration section. The new 'circuit breaker' section has been added correctly with the following properties:
Suggestions:
Would you like me to help with adding validation logic or updating the documentation? |
||
simple triggers: # List of simple triggers | ||
- name: every-minute-trigger # Name of trigger [mandatory, only alphanumeric, dashes & underscore, 5 to 50 characters] | ||
start: 2021-09-19 00:00:00 # Start date | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add XML documentation comments for public class and properties.
The
JobCircuitBreaker
class is well-structured for its intended purpose, encapsulating the state of a circuit breaker effectively. However, it lacks XML documentation comments, which are essential for public classes and properties to ensure they are used correctly by other developers.Consider adding documentation comments above each property and the class definition itself to describe their purpose and usage. This will enhance maintainability and clarity, especially important in a public API context.