Skip to content

Commit 1b9f309

Browse files
author
Bill Prin
committedMay 28, 2015
Fix style on DeferSampleServlet
1 parent c2b6935 commit 1b9f309

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed
 

‎taskqueue/deferred/src/main/java/com/google/cloud/taskqueue/samples/DeferSampleServlet.java

+17-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
* limitations under the License.
1515
*/
1616

17+
/**
18+
* This package demonstrates how to use the task queue with Java.
19+
*/
1720
package com.google.cloud.taskqueue.samples;
1821

1922
import javax.servlet.http.HttpServlet;
@@ -33,7 +36,15 @@
3336
*/
3437
public class DeferSampleServlet extends HttpServlet {
3538

39+
/**
40+
* Number of ms long we will arbitrarily delay.
41+
*/
42+
static final int DELAY_MS = 5000;
43+
3644
//[START defer]
45+
/**
46+
* A hypothetical expensive operation we want to defer on a background task.
47+
*/
3748
public static class ExpensiveOperation implements DeferredTask {
3849
@Override
3950
public void run() {
@@ -42,6 +53,11 @@ public void run() {
4253
}
4354
}
4455

56+
/**
57+
* Basic demonstration of adding a deferred task.
58+
* @param request servlet request
59+
* @param resp servlet response
60+
*/
4561
@Override
4662
public void doGet(HttpServletRequest request, HttpServletResponse
4763
resp) throws IOException {
@@ -50,7 +66,7 @@ public void doGet(HttpServletRequest request, HttpServletResponse
5066

5167
// Wait 5 seconds to run for demonstration purposes
5268
queue.add(TaskOptions.Builder.withPayload(new ExpensiveOperation())
53-
.etaMillis(System.currentTimeMillis() + 5000));
69+
.etaMillis(System.currentTimeMillis() + DELAY_MS));
5470

5571
resp.setContentType("text/plain");
5672
resp.getWriter().println("Task is backgrounded on queue!");

0 commit comments

Comments
 (0)
Please sign in to comment.