mirror of
https://github.com/C9Glax/tranga-website.git
synced 2025-07-06 02:44:17 +02:00
Implemented Queue, so that taskManager is not held up with other Connector-tasks.
Tasks are now executed in another Thread. Replaced TrangaTask.isBeingExecuted bool with 3-states: Waiting, Enqueued, Running Added Queue size to CLI output.
This commit is contained in:
@ -15,7 +15,14 @@ public class TrangaTask
|
||||
public Task task { get; }
|
||||
public Publication? publication { get; }
|
||||
public string language { get; }
|
||||
[JsonIgnore]public bool isBeingExecuted { get; set; }
|
||||
[JsonIgnore]public ExecutionState state { get; set; }
|
||||
|
||||
public enum ExecutionState
|
||||
{
|
||||
Waiting,
|
||||
Enqueued,
|
||||
Running
|
||||
};
|
||||
|
||||
public TrangaTask(Task task, string? connectorName, Publication? publication, TimeSpan reoccurrence, string language = "")
|
||||
{
|
||||
@ -36,7 +43,7 @@ public class TrangaTask
|
||||
/// <returns>True if elapsed time since last execution is greater than set interval</returns>
|
||||
public bool ShouldExecute()
|
||||
{
|
||||
return DateTime.Now.Subtract(this.lastExecuted) > reoccurrence;
|
||||
return DateTime.Now.Subtract(this.lastExecuted) > reoccurrence && state is ExecutionState.Waiting;
|
||||
}
|
||||
|
||||
public enum Task
|
||||
@ -49,6 +56,6 @@ public class TrangaTask
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{task}\t{lastExecuted}\t{reoccurrence}\t{(isBeingExecuted ? "running" : "waiting")}\t{connectorName}\t{publication?.sortName}";
|
||||
return $"{task}\t{lastExecuted}\t{reoccurrence}\t{state}\t{connectorName}\t{publication?.sortName}";
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user