| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package backend | 5 package backend |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "github.com/julienschmidt/httprouter" | 8 "github.com/julienschmidt/httprouter" |
| 9 "github.com/luci/luci-go/appengine/gaemiddleware" | 9 "github.com/luci/luci-go/appengine/gaemiddleware" |
| 10 "github.com/luci/luci-go/appengine/logdog/coordinator" | 10 "github.com/luci/luci-go/appengine/logdog/coordinator" |
| 11 "github.com/luci/luci-go/server/middleware" | 11 "github.com/luci/luci-go/server/middleware" |
| 12 ) | 12 ) |
| 13 | 13 |
| 14 const ( | 14 const ( |
| 15 // defaultMultiTaskBatchSize is the default value for Backend's | 15 // defaultMultiTaskBatchSize is the default value for Backend's |
| 16 // multiTaskBatchSize parameter. | 16 // multiTaskBatchSize parameter. |
| 17 defaultMultiTaskBatchSize = 100 | 17 defaultMultiTaskBatchSize = 100 |
| 18 ) | 18 ) |
| 19 | 19 |
| 20 // Backend is the base struct for all Backend handlers. It is mostly used to | 20 // Backend is the base struct for all Backend handlers. It is mostly used to |
| 21 // configure testing parameters. | 21 // configure testing parameters. |
| 22 type Backend struct { | 22 type Backend struct { |
| 23 // The backing Coordinator service base. |
| 24 coordinator.ServiceBase |
| 25 |
| 23 // multiTaskBatchSize is the number of batch tasks to create at a time. | 26 // multiTaskBatchSize is the number of batch tasks to create at a time. |
| 24 multiTaskBatchSize int | 27 multiTaskBatchSize int |
| 25 | |
| 26 // s is the backing Coordinator service base. | |
| 27 s coordinator.Service | |
| 28 } | 28 } |
| 29 | 29 |
| 30 func (b *Backend) getMultiTaskBatchSize() int { | 30 func (b *Backend) getMultiTaskBatchSize() int { |
| 31 if v := b.multiTaskBatchSize; v > 0 { | 31 if v := b.multiTaskBatchSize; v > 0 { |
| 32 return v | 32 return v |
| 33 } | 33 } |
| 34 return defaultMultiTaskBatchSize | 34 return defaultMultiTaskBatchSize |
| 35 } | 35 } |
| 36 | 36 |
| 37 // InstallHandlers installs handlers for the Backend. | 37 // InstallHandlers installs handlers for the Backend. |
| 38 func (b *Backend) InstallHandlers(r *httprouter.Router, h middleware.Base) { | 38 func (b *Backend) InstallHandlers(r *httprouter.Router, h middleware.Base) { |
| 39 » r.GET("/archive/cron/terminal", h(gaemiddleware.RequireCron(b.HandleArch
iveCron))) | 39 » r.GET("/archive/cron", h(gaemiddleware.RequireCron(b.HandleArchiveCron))
) |
| 40 » r.GET("/archive/cron/nonterminal", h(gaemiddleware.RequireCron(b.HandleA
rchiveCronNT))) | |
| 41 » r.GET("/archive/cron/purge", h(b.HandleArchiveCronPurge)) | |
| 42 } | 40 } |
| OLD | NEW |