Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Unified Diff: chrome/common/extensions/docs/server2/handler.py

Issue 679813004: Docserver: Add _query_commit handler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: documentation Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/extensions/docs/server2/app.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/docs/server2/handler.py
diff --git a/chrome/common/extensions/docs/server2/handler.py b/chrome/common/extensions/docs/server2/handler.py
index 392b0f1a3bcc2d4fd6a315e14cd1388f4da94e9f..a0e044e753aab96ad34bc124736999020b42f372 100644
--- a/chrome/common/extensions/docs/server2/handler.py
+++ b/chrome/common/extensions/docs/server2/handler.py
@@ -5,8 +5,10 @@
import time
from appengine_wrappers import taskqueue
+from commit_tracker import CommitTracker
from cron_servlet import CronServlet
from instance_servlet import InstanceServlet
+from object_store_creator import ObjectStoreCreator
from patch_servlet import PatchServlet
from refresh_servlet import RefreshServlet
from servlet import Servlet, Request, Response
@@ -16,12 +18,53 @@ from test_servlet import TestServlet
_DEFAULT_SERVLET = InstanceServlet.GetConstructor()
-_FORCE_CRON_TARGET = 'force_cron'
+class _EnqueueServlet(Servlet):
+ '''This Servlet can be used to manually enqueue tasks on the default
+ taskqueue. Useful for when an admin wants to manually force a specific
+ DataSource refresh, but the refresh operation takes longer than the 60 sec
+ timeout of a non-taskqueue request. For example, you might query
+
+ /_enqueue/_refresh/content_providers/cr-native-client?commit=123ff65468dcafff0
+
+ which will enqueue a task (/_refresh/content_providers/cr-native-client) to
+ refresh the NaCl documentation cache for commit 123ff65468dcafff0.
+
+ Access to this servlet should always be restricted to administrative users.
+ '''
+ def __init__(self, request):
+ Servlet.__init__(self, request)
+
+ def Get(self):
+ queue = taskqueue.Queue()
+ queue.add(taskqueue.Task(url='/%s' % self._request.path,
+ params=self._request.arguments))
+ return Response.Ok('Task enqueued.')
+
+
+class _QueryCommitServlet(Servlet):
+ '''Provides read access to the commit ID cache within the server. For example:
+
+ /_query_commit/master
+
+ will return the commit ID stored under the commit key "master" within the
+ commit cache. Currently "master" is the only named commit we cache, and it
+ corresponds to the commit ID whose data currently populates the data cache
+ used by live instances.
+ '''
+ def __init__(self, request):
+ Servlet.__init__(self, request)
+
+ def Get(self):
+ object_store_creator = ObjectStoreCreator(start_empty=False)
+ commit_tracker = CommitTracker(object_store_creator)
+ return Response.Ok(commit_tracker.Get(self._request.path).Get())
_SERVLETS = {
'cron': CronServlet,
+ 'enqueue': _EnqueueServlet,
'patch': PatchServlet,
+ 'query_commit': _QueryCommitServlet,
'refresh': RefreshServlet,
'test': TestServlet,
}
@@ -36,16 +79,6 @@ class Handler(Servlet):
if not '/' in servlet_path:
servlet_path += '/'
servlet_name, servlet_path = servlet_path.split('/', 1)
- if servlet_name == _FORCE_CRON_TARGET:
- queue = taskqueue.Queue()
- queue.purge()
- time.sleep(2)
- queue.add(taskqueue.Task(url='/_cron'))
- return Response.Ok('Cron job started.')
- if servlet_name == 'enqueue':
- queue = taskqueue.Queue()
- queue.add(taskqueue.Task(url='/%s'%servlet_path))
- return Response.Ok('Task enqueued.')
servlet = _SERVLETS.get(servlet_name)
if servlet is None:
return Response.NotFound('"%s" servlet not found' % servlet_path)
« no previous file with comments | « chrome/common/extensions/docs/server2/app.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698