mirror of
https://github.com/golang/go
synced 2024-11-05 14:56:10 -07:00
godoc: add IndexInterval option
This will permit deleting some forked code elsewhere. R=golang-dev, crawshaw CC=golang-dev https://golang.org/cl/22010046
This commit is contained in:
parent
0b5928ea2a
commit
42513df8b8
@ -39,6 +39,12 @@ type Corpus struct {
|
||||
// zero value for IndexThrottle means 0.9.
|
||||
IndexThrottle float64
|
||||
|
||||
// IndexInterval specifies the time to sleep between reindexing
|
||||
// all the sources.
|
||||
// If zero, a default is used. If negative, the index is only
|
||||
// built once.
|
||||
IndexInterval time.Duration
|
||||
|
||||
// MaxResults optionally specifies the maximum results for indexing.
|
||||
// The default is 1000.
|
||||
MaxResults int
|
||||
|
@ -1167,7 +1167,8 @@ func (c *Corpus) RunIndexer() {
|
||||
// initialize the index from disk if possible
|
||||
if c.IndexFiles != "" {
|
||||
if err := c.readIndex(c.IndexFiles); err != nil {
|
||||
log.Printf("error reading index: %s", err)
|
||||
log.Printf("error reading index from file %s: %v", c.IndexFiles, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@ -1177,10 +1178,12 @@ func (c *Corpus) RunIndexer() {
|
||||
// index possibly out of date - make a new one
|
||||
c.UpdateIndex()
|
||||
}
|
||||
delay := 60 * time.Second // by default, try every 60s
|
||||
if false { // TODO(bradfitz): was: *testDir != "" {
|
||||
// in test mode, try once a second for fast startup
|
||||
delay = 1 * time.Second
|
||||
if c.IndexInterval < 0 {
|
||||
return
|
||||
}
|
||||
delay := 5 * time.Minute // by default, reindex every 5 minutes
|
||||
if c.IndexInterval > 0 {
|
||||
delay = c.IndexInterval
|
||||
}
|
||||
time.Sleep(delay)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user