Start of making canLongPoll configurable for App Engine to set it to false, for now.

Change-Id: Ib4d7a306276a7292e7d8a8838c3b026d38b5fb6b
This commit is contained in:
Brad Fitzpatrick 2011-10-10 18:04:20 -07:00
parent cfb2765395
commit 11acecce92
3 changed files with 19 additions and 10 deletions

View File

@ -117,7 +117,11 @@ func handleStat(conn http.ResponseWriter, req *http.Request, storage blobserver.
configer, _ := storage.(blobserver.Configer)
ret := commonUploadResponse(configer, req)
if configer != nil {
ret["canLongPoll"] = true
} else {
ret["canLongPoll"] = configer.Config().CanLongPoll
}
ret["stat"] = statRes
ret["canLongPoll"] = true
httputil.ReturnJson(conn, ret)
}

View File

@ -39,8 +39,8 @@ type BlobStatter interface {
// waitSeconds is the max time to wait for the blobs to exist,
// or 0 for no delay.
StatBlobs(dest chan<- blobref.SizedBlobRef,
blobs []*blobref.BlobRef,
waitSeconds int) os.Error
blobs []*blobref.BlobRef,
waitSeconds int) os.Error
}
type StatReceiver interface {
@ -75,9 +75,9 @@ type BlobEnumerator interface {
// after and waitSeconds can't be used together. One must be
// its zero value.
EnumerateBlobs(dest chan<- blobref.SizedBlobRef,
after string,
limit uint,
waitSeconds int) os.Error
after string,
limit uint,
waitSeconds int) os.Error
}
// Cache is the minimal interface expected of a blob cache.
@ -95,6 +95,7 @@ type BlobReceiveConfiger interface {
type Config struct {
Writable, Readable bool
IsQueue bool // supports deletes
CanLongPoll bool
// the "http://host:port" and optional path (but without trailing slash) to have "/camli/*" appended
URLBase string

View File

@ -118,13 +118,17 @@ func makeCamliHandler(prefix, baseURL string, storage blobserver.Storage) http.H
}
baseURL = strings.TrimRight(baseURL, "/")
canLongPoll := true
// TODO(bradfitz): set to false if this is App Engine, or provide some way to disable
storageConfig := &storageAndConfig{
storage,
&blobserver.Config{
Writable: true,
Readable: true,
IsQueue: false,
URLBase: baseURL + prefix[:len(prefix)-1],
Writable: true,
Readable: true,
IsQueue: false,
URLBase: baseURL + prefix[:len(prefix)-1],
CanLongPoll: canLongPoll,
},
}
return http.HandlerFunc(func(conn http.ResponseWriter, req *http.Request) {