gddo-server: Remove the gae_search flag.

Use app engine's main function to start the server by default. GAE
search is also enabled by default. API search is also using the new
search algorithm.

Developers will need to install Google Cloud SDK to use dev_appserver
in order to run the search api locally. The development setup will be
updated as soon as this CL is submitted.

Change-Id: Idae7a88949b2757977d0ab33628564451a1dddd3
Reviewed-on: https://go-review.googlesource.com/25360
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
Tuo Shan 2016-07-29 09:12:55 -07:00 коммит произвёл Alan Donovan
Родитель b828973d90
Коммит e0d34163be
4 изменённых файлов: 34 добавлений и 57 удалений

Просмотреть файл

@ -85,7 +85,6 @@ var (
RedisServer = "redis://127.0.0.1:6379" // URL of Redis server
RedisIdleTimeout = 250 * time.Second // Close Redis connections after remaining idle for this duration.
RedisLog = false // Log database commands
GAESearch = false // Use GAE Search API in the search function.
)
func dialDb() (c redis.Conn, err error) {
@ -274,7 +273,6 @@ func (db *Database) Put(pdoc *doc.Package, nextCrawl time.Time, hide bool) error
return err
}
if GAESearch {
id, n, err := pkgIDAndImportCount(c, pdoc.ImportPath)
if err != nil {
return err
@ -296,7 +294,6 @@ func (db *Database) Put(pdoc *doc.Package, nextCrawl time.Time, hide bool) error
return err
}
}
}
if nextCrawl.IsZero() {
// Skip crawling related packages if this is not a full save.
@ -607,7 +604,6 @@ func (db *Database) Delete(path string) error {
c := db.Pool.Get()
defer c.Close()
if GAESearch {
ctx := bgCtx()
id, err := redis.String(c.Do("HGET", "ids", path))
if err == redis.ErrNil {
@ -619,9 +615,8 @@ func (db *Database) Delete(path string) error {
if err := deleteIndex(ctx, id); err != nil {
return err
}
}
_, err := deleteScript.Do(c, path)
_, err = deleteScript.Do(c, path)
return err
}

Просмотреть файл

@ -51,11 +51,11 @@
<tr><td>
{{if .Path|isValidImportPath}}
<a href="/{{.Path}}">{{.Path|importPath}}</a>
{{if gaeSearch}}<ul class="list-inline">
<ul class="list-inline">
<li class="additional-info">{{.ImportCount}} imports</li>
{{if .Fork}}<li class="additional-info">· fork</li>{{end}}
{{if .Stars}}<li class="additional-info">· {{.Stars}} stars</li>{{end}}
</ul>{{end}}
</ul>
{{else}}{{.Path|importPath}}</td>
{{end}}
<td class="synopsis">{{.Synopsis|importPath}}</td></tr>

Просмотреть файл

@ -583,16 +583,8 @@ func serveHome(resp http.ResponseWriter, req *http.Request) error {
}
}
var (
pkgs []database.Package
err error
)
if database.GAESearch {
ctx := appengine.NewContext(req)
pkgs, err = database.Search(ctx, q)
} else {
pkgs, err = db.Query(q)
}
pkgs, err := database.Search(ctx, q)
if err != nil {
return err
}
@ -651,7 +643,8 @@ func serveAPISearch(resp http.ResponseWriter, req *http.Request) error {
if pkgs == nil {
var err error
pkgs, err = db.Query(q)
ctx := appengine.NewContext(req)
pkgs, err = database.Search(ctx, q)
if err != nil {
return err
}
@ -883,7 +876,6 @@ func init() {
flag.StringVar(&database.RedisServer, "db-server", database.RedisServer, "URI of Redis server.")
flag.DurationVar(&database.RedisIdleTimeout, "db-idle-timeout", database.RedisIdleTimeout, "Close Redis connections after remaining idle for this duration.")
flag.BoolVar(&database.RedisLog, "db-log", database.RedisLog, "Log database commands")
flag.BoolVar(&database.GAESearch, "gae_search", database.GAESearch, "Use GAE Search API in the search function.")
}
func main() {
@ -1038,10 +1030,6 @@ func main() {
gceLogger = newGCELogger(logc)
}
if database.GAESearch {
http.Handle("/", root)
appengine.Main()
} else {
log.Fatal(http.ListenAndServe(*httpAddr, root))
}
}

Просмотреть файл

@ -25,7 +25,6 @@ import (
ttemp "text/template"
"time"
"github.com/golang/gddo/database"
"github.com/golang/gddo/doc"
"github.com/golang/gddo/gosrc"
"github.com/golang/gddo/httputil"
@ -477,10 +476,6 @@ func gaAccountFn() string {
return gaAccount
}
func gaeSearchFn() bool {
return database.GAESearch
}
func noteTitleFn(s string) string {
return strings.Title(strings.ToLower(s))
}
@ -535,7 +530,6 @@ func parseHTMLTemplates(sets [][]string) error {
"comment": commentFn,
"equal": reflect.DeepEqual,
"gaAccount": gaAccountFn,
"gaeSearch": gaeSearchFn,
"host": hostFn,
"htmlComment": htmlCommentFn,
"importPath": importPathFn,