Skip to content

Commit 0e19378

Browse files
committed
Refactor life cycle builder internals
1 parent b506f3f commit 0e19378

File tree

8 files changed

+77
-77
lines changed

8 files changed

+77
-77
lines changed

src/InEngine.Core/Queuing/Enqueue.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@ namespace InEngine.Core.Queuing
99
{
1010
public static class Enqueue
1111
{
12-
public static IQueueLifeCycleActions Command(Expression<Action> expressionAction)
12+
public static IQueueLifeCycleBuilder Command(Expression<Action> expressionAction)
1313
{
14-
return new QueueLifeCycleActions(new Lambda(expressionAction.ToExpressionNode()));
14+
return new QueueLifeCycleBuilder(new Lambda(expressionAction.ToExpressionNode()));
1515
}
1616

17-
public static IQueueLifeCycleActions Command(AbstractCommand command)
17+
public static IQueueLifeCycleBuilder Command(AbstractCommand command)
1818
{
19-
return new QueueLifeCycleActions(command);
19+
return new QueueLifeCycleBuilder(command);
2020
}
2121

22-
public static IQueueLifeCycleActions Command<T>(T command) where T : AbstractCommand
22+
public static IQueueLifeCycleBuilder Command<T>(T command) where T : AbstractCommand
2323
{
24-
return new QueueLifeCycleActions(command);
24+
return new QueueLifeCycleBuilder(command);
2525
}
2626

27-
public static IQueueLifeCycleActions Commands(IList<AbstractCommand> commands)
27+
public static IQueueLifeCycleBuilder Commands(IList<AbstractCommand> commands)
2828
{
29-
return new QueueLifeCycleActions(new Chain() { Commands = commands });
29+
return new QueueLifeCycleBuilder(new Chain() { Commands = commands });
3030
}
3131
}
3232
}

src/InEngine.Core/Queuing/LifeCycle/IQueueLifeCycleActions.cs

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
3+
namespace InEngine.Core.Queuing.LifeCycle
4+
{
5+
public interface IQueueLifeCycleBuilder : IDispatch
6+
{
7+
AbstractCommand Command { get; set; }
8+
IQueueLifeCycleBuilder PingBefore(string url);
9+
IQueueLifeCycleBuilder PingAfter(string url);
10+
IQueueLifeCycleBuilder WriteOutputTo(string output);
11+
IQueueLifeCycleBuilder AppendOutputTo(string output);
12+
IQueueLifeCycleBuilder EmailOutputTo(string emailAddress);
13+
IQueueLifeCycleBuilder WithRetries(int maximumRetries);
14+
}
15+
}

src/InEngine.Core/Queuing/LifeCycle/QueueLifeCycleActions.cs renamed to src/InEngine.Core/Queuing/LifeCycle/QueueLifeCycleBuilder.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,79 +2,79 @@
22

33
namespace InEngine.Core.Queuing.LifeCycle
44
{
5-
public class QueueLifeCycleActions : IQueueLifeCycleActions
5+
public class QueueLifeCycleBuilder : IQueueLifeCycleBuilder
66
{
77
public AbstractCommand Command { get; set; }
88
public QueueAdapter QueueAdapter { get; set; }
99

10-
public QueueLifeCycleActions()
10+
public QueueLifeCycleBuilder()
1111
{}
1212

13-
public QueueLifeCycleActions(AbstractCommand command) : this()
13+
public QueueLifeCycleBuilder(AbstractCommand command) : this()
1414
{
1515
Command = command;
1616
}
1717

18-
public IQueueLifeCycleActions Before(Action<AbstractCommand> action)
18+
public IQueueLifeCycleBuilder Before(Action<AbstractCommand> action)
1919
{
2020
Command.CommandLifeCycle.BeforeAction = action;
2121
return this;
2222
}
2323

24-
public IQueueLifeCycleActions After(Action<AbstractCommand> action)
24+
public IQueueLifeCycleBuilder After(Action<AbstractCommand> action)
2525
{
2626
Command.CommandLifeCycle.AfterAction = action;
2727
return this;
2828
}
2929

30-
public IQueueLifeCycleActions PingBefore(string url)
30+
public IQueueLifeCycleBuilder PingBefore(string url)
3131
{
3232
Command.CommandLifeCycle.ShouldPingBefore = true;
3333
Command.CommandLifeCycle.PingBeforeUrl = url;
3434
return this;
3535
}
3636

37-
public IQueueLifeCycleActions PingAfter(string url)
37+
public IQueueLifeCycleBuilder PingAfter(string url)
3838
{
3939
Command.CommandLifeCycle.ShouldPingAfter = true;
4040
Command.CommandLifeCycle.PingAfterUrl = url;
4141
return this;
4242
}
4343

44-
public IQueueLifeCycleActions WriteOutputTo(string output)
44+
public IQueueLifeCycleBuilder WriteOutputTo(string output)
4545
{
4646
Command.CommandLifeCycle.ShouldWriteOutputToFile = true;
4747
Command.CommandLifeCycle.WriteOutputToFilePath = output;
4848
return this;
4949
}
5050

51-
public IQueueLifeCycleActions AppendOutputTo(string output)
51+
public IQueueLifeCycleBuilder AppendOutputTo(string output)
5252
{
5353
Command.CommandLifeCycle.ShouldAppendOutputToFile = true;
5454
Command.CommandLifeCycle.AppendOutputToFilePath = output;
5555
return this;
5656
}
5757

58-
public IQueueLifeCycleActions EmailOutputTo(string emailAddress)
58+
public IQueueLifeCycleBuilder EmailOutputTo(string emailAddress)
5959
{
6060
Command.CommandLifeCycle.ShouldEmailOutput = true;
6161
Command.CommandLifeCycle.EmailOutputToAddress = emailAddress;
6262
return this;
6363
}
6464

65-
public IQueueLifeCycleActions ToPrimaryQueue()
65+
public IQueueLifeCycleBuilder ToPrimaryQueue()
6666
{
6767
QueueAdapter = QueueAdapter.Make(false);
6868
return this;
6969
}
7070

71-
public IQueueLifeCycleActions ToSecondaryQueue()
71+
public IQueueLifeCycleBuilder ToSecondaryQueue()
7272
{
7373
QueueAdapter = QueueAdapter.Make(true);
7474
return this;
7575
}
7676

77-
public IQueueLifeCycleActions WithRetries(int maximumRetries)
77+
public IQueueLifeCycleBuilder WithRetries(int maximumRetries)
7878
{
7979
Command.CommandLifeCycle.MaximumRetries = maximumRetries;
8080
return this;

src/InEngine.Core/Scheduling/LifeCycle/IScheduleLifeCycleActions.cs

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
3+
namespace InEngine.Core.Scheduling.LifeCycle
4+
{
5+
public interface IScheduleLifeCycleBuilder
6+
{
7+
AbstractCommand Command { get; set; }
8+
IScheduleLifeCycleBuilder Before(Action<AbstractCommand> action);
9+
IScheduleLifeCycleBuilder After(Action<AbstractCommand> action);
10+
IScheduleLifeCycleBuilder PingBefore(string url);
11+
IScheduleLifeCycleBuilder PingAfter(string url);
12+
IScheduleLifeCycleBuilder WriteOutputTo(string output);
13+
IScheduleLifeCycleBuilder AppendOutputTo(string output);
14+
IScheduleLifeCycleBuilder EmailOutputTo(string emailAddress);
15+
}
16+
}

src/InEngine.Core/Scheduling/LifeCycle/LifeCycleActions.cs renamed to src/InEngine.Core/Scheduling/LifeCycle/ScheduleLifeCycleBuilder.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace InEngine.Core.Scheduling.LifeCycle
44
{
5-
public class LifeCycleActions : IScheduleLifeCycleActions
5+
public class ScheduleLifeCycleBuilder : IScheduleLifeCycleBuilder
66
{
77
public AbstractCommand Command {
88
get { return JobRegistration.Command; }
@@ -12,47 +12,47 @@ public AbstractCommand Command {
1212
public JobRegistration JobRegistration { get; set; }
1313

1414

15-
public IScheduleLifeCycleActions Before(Action<AbstractCommand> action)
15+
public IScheduleLifeCycleBuilder Before(Action<AbstractCommand> action)
1616
{
1717
JobRegistration.Command.CommandLifeCycle.BeforeAction = action;
1818
return this;
1919
}
2020

21-
public IScheduleLifeCycleActions After(Action<AbstractCommand> action)
21+
public IScheduleLifeCycleBuilder After(Action<AbstractCommand> action)
2222
{
2323
JobRegistration.Command.CommandLifeCycle.AfterAction = action;
2424
return this;
2525
}
2626

27-
public IScheduleLifeCycleActions PingBefore(string url)
27+
public IScheduleLifeCycleBuilder PingBefore(string url)
2828
{
2929
JobRegistration.Command.CommandLifeCycle.ShouldPingBefore = true;
3030
JobRegistration.Command.CommandLifeCycle.PingBeforeUrl = url;
3131
return this;
3232
}
3333

34-
public IScheduleLifeCycleActions PingAfter(string url)
34+
public IScheduleLifeCycleBuilder PingAfter(string url)
3535
{
3636
JobRegistration.Command.CommandLifeCycle.ShouldPingAfter = true;
3737
JobRegistration.Command.CommandLifeCycle.PingAfterUrl = url;
3838
return this;
3939
}
4040

41-
public IScheduleLifeCycleActions WriteOutputTo(string output)
41+
public IScheduleLifeCycleBuilder WriteOutputTo(string output)
4242
{
4343
JobRegistration.Command.CommandLifeCycle.ShouldWriteOutputToFile = true;
4444
JobRegistration.Command.CommandLifeCycle.WriteOutputToFilePath = output;
4545
return this;
4646
}
4747

48-
public IScheduleLifeCycleActions AppendOutputTo(string output)
48+
public IScheduleLifeCycleBuilder AppendOutputTo(string output)
4949
{
5050
JobRegistration.Command.CommandLifeCycle.ShouldAppendOutputToFile = true;
5151
JobRegistration.Command.CommandLifeCycle.AppendOutputToFilePath = output;
5252
return this;
5353
}
5454

55-
public IScheduleLifeCycleActions EmailOutputTo(string emailAddress)
55+
public IScheduleLifeCycleBuilder EmailOutputTo(string emailAddress)
5656
{
5757
JobRegistration.Command.CommandLifeCycle.ShouldEmailOutput = true;
5858
JobRegistration.Command.CommandLifeCycle.EmailOutputToAddress = emailAddress;

src/InEngine.Core/Scheduling/Occurence.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,78 +19,78 @@ public static TriggerBuilder MakeTriggerBuilder(AbstractCommand command)
1919
.WithIdentity($"{command.Name}:job:{command.ScheduleId}", command.SchedulerGroup);
2020
}
2121

22-
public LifeCycleActions RegisterJob(Action<DailyTimeIntervalScheduleBuilder> action)
22+
public ScheduleLifeCycleBuilder RegisterJob(Action<DailyTimeIntervalScheduleBuilder> action)
2323
{
24-
return new LifeCycleActions {
24+
return new ScheduleLifeCycleBuilder {
2525
JobRegistration = Schedule.RegisterJob(Command, JobDetail, MakeTriggerBuilder(Command).WithDailyTimeIntervalSchedule(action).Build())
2626
};
2727
}
2828

29-
public LifeCycleActions RegisterJob(string cronExpression)
29+
public ScheduleLifeCycleBuilder RegisterJob(string cronExpression)
3030
{
31-
return new LifeCycleActions {
31+
return new ScheduleLifeCycleBuilder {
3232
JobRegistration = Schedule.RegisterJob(Command, JobDetail, MakeTriggerBuilder(Command).WithCronSchedule(cronExpression).Build())
3333
};
3434
}
3535

36-
public LifeCycleActions RegisterJob(Action<SimpleScheduleBuilder> action)
36+
public ScheduleLifeCycleBuilder RegisterJob(Action<SimpleScheduleBuilder> action)
3737
{
38-
return new LifeCycleActions {
38+
return new ScheduleLifeCycleBuilder {
3939
JobRegistration = Schedule.RegisterJob(Command, JobDetail, MakeTriggerBuilder(Command).WithSimpleSchedule(action).Build())
4040
};
4141
}
4242

43-
public LifeCycleActions Cron(string cronExpression)
43+
public ScheduleLifeCycleBuilder Cron(string cronExpression)
4444
{
4545
return RegisterJob(cronExpression);
4646
}
4747

48-
public LifeCycleActions EverySecond()
48+
public ScheduleLifeCycleBuilder EverySecond()
4949
{
5050
return RegisterJob(x => x.WithIntervalInSeconds(1).RepeatForever());
5151
}
5252

53-
public LifeCycleActions EveryMinute()
53+
public ScheduleLifeCycleBuilder EveryMinute()
5454
{
5555
return RegisterJob(x => x.WithIntervalInMinutes(1).RepeatForever());
5656
}
5757

58-
public LifeCycleActions EveryFiveMinutes()
58+
public ScheduleLifeCycleBuilder EveryFiveMinutes()
5959
{
6060
return RegisterJob(x => x.WithIntervalInMinutes(5).RepeatForever());
6161
}
6262

63-
public LifeCycleActions EveryTenMinutes()
63+
public ScheduleLifeCycleBuilder EveryTenMinutes()
6464
{
6565
return RegisterJob(x => x.WithIntervalInMinutes(10).RepeatForever());
6666
}
6767

68-
public LifeCycleActions EveryFifteenMinutes()
68+
public ScheduleLifeCycleBuilder EveryFifteenMinutes()
6969
{
7070
return RegisterJob(x => x.WithIntervalInMinutes(15).RepeatForever());
7171
}
7272

73-
public LifeCycleActions EveryThirtyMinutes()
73+
public ScheduleLifeCycleBuilder EveryThirtyMinutes()
7474
{
7575
return RegisterJob(x => x.WithIntervalInMinutes(30).RepeatForever());
7676
}
7777

78-
public LifeCycleActions Hourly()
78+
public ScheduleLifeCycleBuilder Hourly()
7979
{
8080
return RegisterJob(x => x.WithIntervalInHours(1).RepeatForever());
8181
}
8282

83-
public LifeCycleActions HourlyAt(int minutesAfterTheHour)
83+
public ScheduleLifeCycleBuilder HourlyAt(int minutesAfterTheHour)
8484
{
8585
return RegisterJob($"0 {minutesAfterTheHour} * * * ?");
8686
}
8787

88-
public LifeCycleActions Daily()
88+
public ScheduleLifeCycleBuilder Daily()
8989
{
9090
return RegisterJob(x => x.WithIntervalInHours(24).RepeatForever());
9191
}
9292

93-
public LifeCycleActions DailyAt(int hours, int minutes, int seconds = 0)
93+
public ScheduleLifeCycleBuilder DailyAt(int hours, int minutes, int seconds = 0)
9494
{
9595
return RegisterJob(x => x.StartingDailyAt(new TimeOfDay(hours, minutes, seconds)));
9696
}

0 commit comments

Comments
 (0)