This add-on is operated by CompassPoint Technologies
Simple and flexible job scheduling for your application
Temporize Scheduler
Last updated May 30, 2024
Table of Contents
Temporize is an add-on that provides flexible job scheduling for one-time and recurring tasks.
Temporize handles job scheduling for your application by storing and managing events that correspond to actions that your application intends to execute in the future. At the appropriate time, Temporize calls back to your application at the provided URL to signal that some work must be completed. If your application provided state information with the scheduling request, it will be posted back in the request entity. Whether your job has to be run every minute, the last Thursday of each month, or one time 10 months from now, Temporize will securely store and handle your application events at the right time.
By outsourcing the critical task of job scheduling you can save valuable development time, as well as infrastructure costs associated with building, deploying and running a dedicated enterprise job scheduling system.
Temporize is accessible via a simple REST API. Our API can be used with standard libraries in Java, Ruby, Python, Node.js, Clojure, Scala and more.
There are a few setup steps required to use the add-on:
- Provision the add-on for your application, as outlined below.
- Setup an HTTP endpoint in your application to receive event notifications.
- Use the interactive REST API documentation and sample code as a reference for calling the Temporize service to schedule events.
Basic concepts
Temporize works by calling back to your application via HTTP POST according to a schedule constructed by you or your application. this section describes some of the basic concepts involved when scheduling events with Temporize.
Event type
There are two event types in Temporize, single and recurring.
- Single - A single event is scheduled to occur at a single point of time in the future.
- Recurring - A recurring event is scheduled to occur according to recurring schedule, defined by a Cron expression.
Single events
A single event is defined by a date and time when it should be run. Temporize uses ISO8601 formatted date/time values (ex. 20130214T074238Z) both when specifying when to run a single event, and when returning event information through the API. More information is available in the Wikipedia article on ISO8601.
Recurring events
A recurring event is defined by a Cron schedule which provides great flexibility for defining repeating events. The format for a recurring schedule is a series of fields which represent a set of times.
NOTE: Cron expressions are always evaluated with respect to UTC time.
Cron expressions
The Temporize format follows the standard Cron expression format.
Here are some sample expressions for recurring schedules:
- 0 12 * * ? - Runs every day at 12:00PM
- 15 10 ? * MON-FRI - Runs at 10:15AM every Monday through Friday
- 0/5 14 * * ? - Runs every five minutes between 2:00PM and 2:59PM daily
Retrying callbacks
A callback can fail for many different reasons. Your application may be down or in the process of restarting, there may be a problem in the network connection, the application process may be hung, etc… Temporize treats any error during a connection attempt, any response that takes longer than 30 seconds, or any HTTP response code other than 2xx as a failure. When this happens, Temporize will attempt to retry the callback five times, at one hour intervals. Once the application has responded successfully (with a 2xx response code) the retries will be canceled. In addition, if the time of a retry is later than the next scheduled occurrence of a recurring event, the retry will be canceled in order to prevent unexpected duplicate callbacks.
Excessive failures
To prevent slow or broken callbacks from impacting other customers, we limit the number of times a event can fail due to error conditions or slow connections. If a recurring event fails 5 times in a row, whether due to an error condition or a slow response, it is automatically paused and execution suspended. In this case the event can be manually restarted once the problem in the customer application is rectified.
Plans and usage
We offer several addon plans to support different requirements. Each tier has usage limits that affect the number of events which may be scheduled, as well as the number of times those events can run per day.
For each plan, there is a limit on the total number of events that can be scheduled. Once this many events are scheduled, attempts to create additional events will fail.
A plan also has limits on how many events can run in a single day. Thanks to the power and flexibility of Cron expressions recurring events are highly variable in the number of times they may run in a given day, week, month or year. To simplify usage tracking, we calculate usage by determining the average number of times per day a recurring event will execute over the next month. If the total of all the averages from all events exceeds the usage limit, attempts to create new events will fail. Each month we re-evaluate the events and will alert you if they exceed plan limits.
Available plans
Please see our plan page for available plans.
Provision the add-on
Temporize can be attached to a Heroku application via the CLI:
$ heroku addons:create temporize
-----> Adding temporize to sharp-mountain-4005... done, v18 (free)
Once Temporize has been added a TEMPORIZE_URL setting will be available in the app configuration and will contain the canonical URL used to access the newly provisioned Temporize service instance. This can be confirmed using the heroku config:get command.
$ heroku config:get TEMPORIZE_URL
https://user:pass@api.temporize.net
After installing Temporize the application should be configured to fully integrate with the add-on. Note: A list of all plans available can be found on our plan page at Heroku.
Using from Ruby
Any Ruby application can use the service with freely available libraries. The following example uses HTTParty to consume the Temporize REST API.
require 'rubygems'
require 'httparty'
require 'cgi'
require 'time'
class Temporize
include HTTParty
base_uri 'https://api.temporize.net/v1'
format :json
attr_accessor :credentials
def initialize(username, password)
@credentials = {:username => username, :password => password}
end
# Check that we can call web service
def test
Temporize.get("/test")
end
# Check authentication
def auth
Temporize.get("/auth", :basic_auth => credentials)
end
# Schedule a test event to run right away
def single
date = Time.now.utc.iso8601
url = CGI::escape("http://example.com/callback") # Replace with your callback URL
Temporize.post("/events/#{date}/#{url}", :basic_auth => credentials)
end
# Schedule a test event to run once a day at 10:05AM GMT
def recurring
cron = CGI::escape("5 10 * * ?")
url = CGI::escape("http://example.com/callback") # Replace with your callback URL
Temporize.post("/events/#{cron}/#{url}", :basic_auth => credentials)
end
end
Using from the command line
The Temporize API is fully accessible from the command line using an HTTP client such as Curl:
$ curl https://user:pass@api.temporize.net/v1/events
["QUzSPKFxTiWb48EZeQ4KUv","htN8esKtQKqgfpNA5rcDbQ"]
$ curl https://user:pass@api.temporize.net/v1/events/QUzSPKFxTiWb48EZeQ4KUv
{
"id": "QUzSPKFxTiWb48EZeQ4KUv",
"account": "eiKKvxfVSmyqHcV4E6xYvQ",
"user": "eiKKvxfVSmyqHcV4E6xYvQ",
"status": "Active",
"retries": 5,
"url": "http://api.temporize.net/v1/test",
"when": "2014-02-13T20:12:43Z"
}
Migrating plans
Application owners should carefully manage the migration timing to ensure proper application function during the migration process. Use the heroku addons:upgrade command to migrate to a new plan.
$ heroku addons:upgrade temporize:newplan
-----> Upgrading temporize:newplan to sharp-mountain-4005... done, v18 ($49/mo)
Your plan has been updated to: temporize:newplan
Removing the addon
Temporize can be removed via the CLI.
This will destroy all associated data and cannot be undone!
$ heroku addons:destroy temporize
-----> Removing temporize from sharp-mountain-4005... done, v20 (free)
Support
All Temporize support and runtime issues should be submitted via on of the Heroku Support channels. Any non-support related issues or product feedback is welcome at: support@temporize.net