Home

Awesome

<!-- # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # -->

Apache OpenWhisk Alarm Package

License Build Status

The /whisk.system/alarms package can be used to fire a trigger at a specified frequency. Alarms are useful for setting up recurring jobs or tasks, such as invoking a system backup action every hour.

The package includes the following feeds.

EntityTypeParametersDescription
/whisk.system/alarmspackage-Alarms and periodic utility.
/whisk.system/alarms/intervalfeedminutes, trigger_payload, startDate, stopDateFire Trigger event on an interval based schedule.
/whisk.system/alarms/oncefeeddate, trigger_payload, deleteAfterFireFire Trigger event once on a specific date.
/whisk.system/alarms/alarmfeedcron, trigger_payload, startDate, stopDateFire Trigger event on a time-based schedule using cron.

Firing a trigger event periodically on an interval based schedule

The /whisk.system/alarms/interval feed configures the Alarm service to fire a Trigger event on an interval based schedule. The parameters are as follows:

The following example creates a trigger that is fired once every 2 minutes. The Trigger fires as soon as possible, and will stop firing January 31, 2019, 23:59:00 UTC.

wsk trigger create interval \
  --feed /whisk.system/alarms/interval \
  --param minutes 2 \
  --param trigger_payload "{\"name\":\"Odin\",\"place\":\"Asgard\"}" \
  --param stopDate "2019-01-31T23:59:00.000Z"

Each generated event includes parameters, which are the properties that are specified by the trigger_payload value. In this case, each Trigger event has the parameters name=Odin and place=Asgard.

Firing a trigger event once

The /whisk.system/alarms/once feed configures the Alarm service to fire a trigger event on a specified date. The parameters are as follows:

The following is an example of creating a trigger that will be fired once on December 25, 2019, 12:30:00 UTC. After the Trigger fires it will be deleted as well as all of its associated rules.

wsk trigger create fireOnce \
  --feed /whisk.system/alarms/once \
  --param trigger_payload "{\"name\":\"Odin\",\"place\":\"Asgard\"}" \
  --param date "2019-12-25T12:30:00.000Z" \
  --param deleteAfterFire "rules"

Firing a Trigger on a time-based schedule using cron

The /whisk.system/alarms/alarm feed configures the Alarm service to fire a Trigger event at a specified frequency. The parameters are as follows:

The following is an example of creating a trigger that fires once every 2 minutes with name and place values in the trigger event. The Trigger will not start firing until January 1, 2019, 00:00:00 UTC and will stop firing January 31, 2019, 23:59:00 UTC.

wsk trigger create periodic \
  --feed /whisk.system/alarms/alarm \
  --param cron "*/2 * * * *" \
  --param trigger_payload "{\"name\":\"Odin\",\"place\":\"Asgard\"}" \
  --param startDate "2019-01-01T00:00:00.000Z" \
  --param stopDate "2019-01-31T23:59:00.000Z"

Note: The parameter maxTriggers is deprecated and will be removed soon. To stop the Trigger, use the stopDate parameter.

The delay is determined by the hash value of the Trigger's name, so it keeps the same interval before and after the (re)deployment.

Note This option can be helpful to avoid thundering herds when the second-unit errors are not critical.

Building from Source

To build this package from source, execute the command ./gradlew distDocker