Database Reference
In-Depth Information
schedule: every 10 minutes
- description: hourly dashboard refresh
url: /dashboard/trigger/12h
schedule: every 12 hours
App Engine invokes the configured URLs at the appropriate time to kick
off the operation. You can see that we also included an entry for the table
creation task shown in Listing 8.5 . Keep in mind that these URLs need
to be locked down because we would not want end users to trigger these
operations. The simplest way to do this is in the dispatch configuration in
app.yaml .
- url: /dashboard/.*
script: dashboard.app
login: admin
Note that the development server does not run these automatically, but you
can use the administration console to trigger them for testing as described
in the “Service Account and Local Testing” feature above.
To avoid running expensive and slow queries each time the dashboard page
is requested, we have chosen to maintain a cache of results required by the
page in the dashboard dataset. The contents of this dataset are updated
periodically by using the scheduled task facility of AppEngine to run query
jobs that write their results to tables in this dataset. The page itself only uses
tables in this dataset to present a visual summary to the viewer.
The way we have chosen to organize updating our tables for the dashboard is
to define a list containing BackgroundQuery objects. Each object specifies
the query job configuration to be executed and a refresh interval. The
handler for the scheduled task scans the list for entries with a refresh
interval matching the interval specified as a request parameter to the task
and launches the job for each match.
For simplicity, the scheduled task does not bother to check the status of
these jobs because it does not need the result. Of course, there is the
possibility of transient failures. For cached results that are updated
frequently this may not matter because the job will be re-executed in a little
while. However, for longer intervals this may lead to unacceptable staleness,
so in a production application you would ideally wait for completion and,
if a transient error is detected, retry the query. It is important that the
Search WWH ::




Custom Search