Skip to content

Commit

Permalink
rename option to CronWorkerOption
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan committed Apr 10, 2024
1 parent fb16c98 commit 99c1af8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/Hosting/Hosting/src/Workers/CronWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public abstract class CronWorker : Worker, IDisposable
{
private readonly ILogger _logger;
private readonly Random _delayGenerator = new();
private readonly SchedulerOption? _option;
private readonly CronWorkerOption? _option;
private Timer? _timer;
private CancellationTokenSource? _cancellationTokenSource;

Expand All @@ -22,7 +22,7 @@ protected CronWorker(ILogger logger) : base(logger)
_logger = logger;
}

protected CronWorker(SchedulerOption option, ILogger logger) : base(logger)
protected CronWorker(CronWorkerOption option, ILogger logger) : base(logger)
{
_option = option;
_logger = logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

using Exceptions;

public record SchedulerOption
public record CronWorkerOption
{
public bool AllowExtraDelay { get; }
public uint MinDelayInSecond { get; }
public uint MaxDelayInSecond { get; } = 120;

public SchedulerOption(bool allowExtraDelay)
public CronWorkerOption(bool allowExtraDelay)
{
AllowExtraDelay = allowExtraDelay;
}

public SchedulerOption(bool allowExtraDelay, uint minDelayInSecond, uint maxDelayInSecond)
public CronWorkerOption(bool allowExtraDelay, uint minDelayInSecond, uint maxDelayInSecond)
{
AllowExtraDelay = allowExtraDelay;
MinDelayInSecond = minDelayInSecond;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ public async Task RunAsync_RunEveryTwoSeconds()
}

[Fact]
public void SchedulerOption_MinGreaterThanMax_ThrowException()
public void CronWorkerOption_MinGreaterThanMax_ThrowException()
{
Assert.Throws<InvalidSchedulerOptionException>(() =>
{ new SchedulerOption(true, 2, 1); });
{ new CronWorkerOption(true, 2, 1); });
}

[Fact]
public async Task RunAsync_RunEveryTwoSeconds_return()
{
var everyTwoSecondCron = "*/2 * * * * *";
var option = new SchedulerOption(true, 2, 3);
var option = new CronWorkerOption(true, 2, 3);

var mockLogger = new Mock<ILogger>();
var scheduler = new TestSchedulerWithOption(everyTwoSecondCron, option, mockLogger.Object);
Expand Down Expand Up @@ -78,7 +78,7 @@ public class TestSchedulerWithOption : CronWorker
{
public DateTime? FirstExecutionTime { get; set; }

public TestSchedulerWithOption(string cron, SchedulerOption option, ILogger logger) : base(option, logger)
public TestSchedulerWithOption(string cron, CronWorkerOption option, ILogger logger) : base(option, logger)
{
CronSchedule = cron;
}
Expand Down

0 comments on commit 99c1af8

Please sign in to comment.