Skip to content

Instantly share code, notes, and snippets.

@sfmskywalker
Last active December 7, 2020 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sfmskywalker/d2d5c8150c93c5ba128b45acd65d19c9 to your computer and use it in GitHub Desktop.
Save sfmskywalker/d2d5c8150c93c5ba128b45acd65d19c9 to your computer and use it in GitHub Desktop.
class ThisIsMyMonday : IWorkflow
{
private ITrashCleanupService _cleanupService;
private IDogWalkingService _dogWalkingService;
private IDishCleaningService _dishCleaningService;
public CleanTrash(ITrashCleanupService cleanupService, IDogWalkingService dogWalkingService, IDishCleaningService dishCleaningService)
{
_cleanupService = cleanupService;
_dogWalkingService = dogWalkingService;
_dishCleaningService = dishCleaningService;
}
public void Build(IWorkflowBuilder workflow)
{
workflow
.Cron("0 0 8 ? * MON *")
.Then(CleanoutTrash)
.Timer(Duration.FromHours(2)) // Sleep for 2 hours
.Then(WalkTheDog)
.Then(DoTheDishes);
}
private ValueTask CleanoutTrash(ActivityExecutionContext context) => _cleanupService.CleanupTrashAsync(context.CancellationToken);
private ValueTask WalkTheDog(ActivityExecutionContext context) => _dogWalkingService.WalkTheDogAsync(context.CancellationToken);
private ValueTask DoTheDishes(ActivityExecutionContext context) => _dishCleaningService.DoDishesAsync(context.CancellationToken);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment