Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for rescheduling and resetting the already scheduled timer. #22

Closed
gurmitteotia opened this issue Sep 26, 2018 · 3 comments
Closed
Assignees
Projects

Comments

@gurmitteotia
Copy link
Owner

gurmitteotia commented Sep 26, 2018

As discussed in this ticket it make sense to have Timer.Reset and Timer.Reschedule API available to library users. These API are quite generic and could be useful in many scenarios.

Suggested API

Case 1:

  public class OrderWorkflow : Workflow
    {
        public OrderWorkflow()
        {
            ScheduleTimer("GracePeriod").FireAfter(TimeSpan.FromMinutes(30));
           
            ScheduleActivity<ShipOrder>().AfterTimer("GracePeriod");
        }

       [WorkflowEvent(EventName.Signal)]
        public WorkflowAction Signal(WorkflowSignaledEvent @event)
        {
         //This reschedule timer with by taking the timeout from FireAfter API
          var timer = Timer("GracePeriod");
           if (@event.SignalName == "change_time")
                if (timer.IsActive) timer.Reset(); 
            return Ignore;
        }
    }

Case 2:

  public class OrderWorkflow : Workflow
    {
        public OrderWorkflow()
        {
            ScheduleTimer("GracePeriod").FireAfter(TimeSpan.FromMinutes(30));
           
            ScheduleActivity<ShipOrder>().AfterTimer("GracePeriod");
        }

       [WorkflowEvent(EventName.Signal)]
        public WorkflowAction Signal(WorkflowSignaledEvent @event)
        {
         //This reschedule timer with given timeout.
          var timer = Timer("GracePeriod");
           if (@event.SignalName == "change_time")
                if (timer.IsActive) timer.Reschedule(TimeSpan.FromMinutes(20))); 
            return Ignore;
        }
    }
@alexzm1
Copy link

alexzm1 commented Nov 12, 2018

Any plans on releasing this change in the short term?

@gurmitteotia gurmitteotia changed the title Add support of rescheduling and resetting the already scheduled timer. Add support for rescheduling and resetting the already scheduled timer. Nov 13, 2018
@gurmitteotia
Copy link
Owner Author

I can take this up for next release. Anyway I'm going to focus on timers and signals in next few releases.
This ticket will also set the stage for next big ticket.

@gurmitteotia gurmitteotia added this to To Do in Guflow via automation Nov 13, 2018
@gurmitteotia gurmitteotia self-assigned this Nov 13, 2018
@gurmitteotia gurmitteotia moved this from To Do to In Progress in Guflow Nov 13, 2018
@gurmitteotia
Copy link
Owner Author

This feature is implemented in version 1.2.15.

Guflow automation moved this from In Progress to Done Nov 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Guflow
  
Done
Development

No branches or pull requests

2 participants