Database Reference
In-Depth Information
destination tables for these jobs be in a specific location, as opposed to being
anonymous, because they are going to be read or queried while rendering
the dashboard, as shown in Listing 8.6 .
Listing 8.6 : Dashboard cache management (dashboard.py)
# Structure representing a query to be cached.
BackgroundQuery = namedtuple('BackgroundQuery', [
'query_job',
'max_age',
])
# Scheduled task to trigger dashboard refreshes.
class _Trigger(webapp2.RequestHandler):
# max_age is the interval be handled.
def get(self, max_age):
logging.info("Triggering: " + max_age)
for index in xrange(len(BACKGROUND_QUERIES)):
cached = BACKGROUND_QUERIES[int(index)]
# Only trigger if it is the special value 'all'
or if the
# configuration specifies an interval matching
the input interval.
if (max_age == 'all' or cached.max_age ==
max_age):
taskqueue.add(url='/dashboard/update',
params={'index': index})
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('ok')
# Handles a dashboard cache update for a given
configuration.
class _Update(webapp2.RequestHandler):
# max_age is the interval be handled.
def post(self):
index = self.request.get('index')
logging.info("Dashboard update: " + index)
 
 
Search WWH ::




Custom Search