Skip to content

Commit

Permalink
Rename WorkflowConfiguration.StopWhenNoWork -> WorkflowConfiguration.…
Browse files Browse the repository at this point in the history
…StopWhenNoImmediateWork
  • Loading branch information
kbilsted committed Nov 1, 2023
1 parent 24507c7 commit ca31cc7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Demos/GreenFeetWorkFlow.Tests/AdoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class WorkerTests
private readonly WorkflowConfiguration cfg = new WorkflowConfiguration(
new WorkerConfig()
{
StopWhenNoWork = true
StopWhenNoImmediateWork = true
},
NumberOfWorkers: 1);

Expand Down
2 changes: 1 addition & 1 deletion src/Demos/GreenFeetWorkFlow.Tests/RuntimeDataTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class RuntimeDataTests
TestHelper helper = new TestHelper();

private readonly WorkflowConfiguration cfg = new WorkflowConfiguration(
new WorkerConfig() { StopWhenNoWork = true },
new WorkerConfig() { StopWhenNoImmediateWork = true },
NumberOfWorkers: 1);

[SetUp]
Expand Down
6 changes: 3 additions & 3 deletions src/Demos/GreenFeetWorkFlow.Tests/TestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void CreateAndRunEngineForPerformance(Step[] steps, int workerCount, para

var workflowConfiguration = new WorkflowConfiguration(new WorkerConfig()
{
StopWhenNoWork = false
StopWhenNoImmediateWork = false
}, NumberOfWorkers: workerCount);

Engine.Start(workflowConfiguration, stoppingToken: cts.Token);
Expand All @@ -101,7 +101,7 @@ public void CreateAndRunEngine(Step[] steps, int workerCount, params (string, IS

var workflowConfiguration = new WorkflowConfiguration(new WorkerConfig()
{
StopWhenNoWork = workerCount == 1,
StopWhenNoImmediateWork = workerCount == 1,
}, NumberOfWorkers: workerCount);

if (workerCount == 1)
Expand All @@ -125,7 +125,7 @@ public void CreateAndRunEngineWithAttributes(Step[] steps, int workerCount)
Engine.Data.AddStepsAsync(steps).GetAwaiter().GetResult();

var workflowConfiguration = new WorkflowConfiguration(new WorkerConfig()
{ StopWhenNoWork = workerCount == 1 },
{ StopWhenNoImmediateWork = workerCount == 1 },
NumberOfWorkers: workerCount);

Engine.Start(workflowConfiguration, stoppingToken: cts.Token);
Expand Down
2 changes: 1 addition & 1 deletion src/Product/GreenFeetWorkFlow/Worker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async Task ExecuteLoop()
StoppingToken.WaitHandle.WaitOne(workerConfig.DelayTechnicalTransientError);
continue;
case WorkerRunStatus.NoWorkDone:
if (workerConfig.StopWhenNoWork)
if (workerConfig.StopWhenNoImmediateWork)
{
if (logger.DebugLoggingEnabled)
logger.LogDebug($"{nameof(Worker)}: Stopping worker thread due to no work",
Expand Down
5 changes: 3 additions & 2 deletions src/Product/GreenFeetWorkFlow/WorkflowConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ public class LoggerConfiguration
public record WorkerConfig()
{
/// <summary>
/// stop the engine when there is no work to carry out now (only none or future step exists)
/// stop the engine when there is no immediate work to carry out now (it will stop if eg. future step exists).
/// Useful for testing
/// </summary>
public bool StopWhenNoWork { get; set; } = false;
public bool StopWhenNoImmediateWork { get; set; } = false;

public TimeSpan DelayNoReadyWork { get; set; } = TimeSpan.FromSeconds(3);
public TimeSpan DelayTechnicalTransientError { get; set; } = TimeSpan.FromMinutes(2);
Expand Down

0 comments on commit ca31cc7

Please sign in to comment.