cog icon indicating copy to clipboard operation
cog copied to clipboard

Add support for scheduled command execution

Open imbriaco opened this issue 9 years ago • 0 comments

Allow command execution to be scheduled to run at a future time.

Requirements:

  • Support single execution at a scheduled time (ie: run X at 10:15AM)
  • Support periodic execution at defined intervals (ie: every 5 minutes run X)
  • Should be exposed to users directly and available to commands via a service interface.

Note, the examples below are for illustration purposes only. This feature requires additional research and an implementation plan before work can begin.

User Examples

Periodic execution:

imbriaco: !exec:every 5m graph -15m web.requests
cog: scheduled execution of `graph -15m web.requests` every 5 minutes with job ID imbriaco.456.
imbriaco: !exec:list
cog: Pending jobs: 
         imbriaco.456: `graph -15m web.requests`
                                every 15 minutes beginning 2016-05-10T15:05:11Z
imbriaco: !exec:cancel imbriaco.456
imbriaco: !exec:list
cog: No pending jobs.

Scheduled Execution:

At future time offset from current time:

imbriaco: !exec:at +10m echo Ten minutes have passed
cog: scheduled execution of `echo Ten minutes have passed` at 2016-05-10T15:16:01Z with job ID imbriaco.457.
... time passes ...
cog: Ten minutes have passed.
imbriaco: !exec:list
cog: No pending jobs.

At specific future time today:

imbriaco: !exec:at 15:30:00Z echo Ten minutes have passed

At specific future date and time:

imbriaco: !exec:at 2016-05-11T15:30:00Z echo Ten minutes have passed

Command Example

Commands should also be able to use this feature either as a service, either as a new service or via the executor service. For instance, a command that updates a statuspage.io site may want to be able to schedule a reminder every 10 minutes to update the status. The command would also want to be able to remove the scheduled reminder when the status event was closed.

Illustration:

  • imbriaco: !status red The site is down. We're working on it.
  • status command execution:
    • updates status site, assigns status_id of 123.
    • registers a reminder callback: exec:every 10m --name status.123 "status remind 123"
  • T+10 minutes:
    • cog executes status remind <status_id> which mentions imbriaco and asks for a status update in chat.
    • imbriaco: !status yellow We have done some things. The site is recovering.
  • T+15minutes:
    • site stabilizes, imbriaco runs !status green
    • status command executes:
      • updates status site and changes status to green
      • closes status event with ID 123
      • cancels scheduled command: exec:cancel status.123

imbriaco avatar May 10 '16 14:05 imbriaco