Can I schedule a one-shot action in openwhisk?

218 views Asked by At

I'm playing a bit with openwhisk in IBM Bluemix and now I'm looking for a way to shedule a one shot action.

I know I can run actions at fixed intervals, in a "cron" fashion using 'feed /whisk.system/alarms/alarm'. What I am looking for is similar to the at linux command.

The closest I figured out involves another server used to generate events, but I would like to be as "serverless" as possible.

Another non desirable solution would be using js setTimeout but... I suppose that would waste execution time. (And possibly hitting execution time limit)

Thanks in advance.

1

There are 1 answers

0
csantanapr On BEST ANSWER

Use a cron schedule with appropriate fields and the maxTriggers parameter set to 1.

The maxTriggers parameter ensures that, after a single event, the trigger won't be called again.

One-off triggers can be created from the command-line.

Here's an example for a trigger to run once at 1st January @ 00:00.

wsk trigger create new_year --feed /whisk.system/alarms/alarm
  -p cron '0 0 1 0 *' 
  -p maxTriggers 1 
  -p trigger_payload '{"message":"Happy New Year!"}'

There is an open issue in the open-source repo to provide better support for these kind of events. https://github.com/apache/incubator-openwhisk-package-alarms/issues/89