Move defaultMaxResizeBytes to pkg/constants

Change-Id: Ibb5f82b6f33a4417649f1538a996f1fe7eac885e
This commit is contained in:
Brad Fitzpatrick 2014-01-06 08:08:47 -08:00
parent d21aa1dba2
commit 34ed712a4a
4 changed files with 16 additions and 19 deletions

View File

@ -19,9 +19,14 @@ limitations under the License.
// This is a leaf package, without dependencies.
package constants
// MaxBlobSize is the size of a single blob in Camlistore.
//
// TODO: formalize this in the specs. This value of 16 MB is less than
// App Engine's 32 MB request limit, much more than Venti's limit, and
// much more than the ~64 KB & 256 KB chunks that the FileWriter make
// MaxBlobSize is the max size of a single blob in Camlistore, in bytes.
const MaxBlobSize = 16 << 20
// DefaultMaxResizeMem is the default maximum number of bytes that
// will be allocated at peak for uncompressed pixel data while
// generating thumbnails or other resized images.
//
// If a single image is larger than the configured size for an
// ImageHandler, we'll never successfully resize it. 256M is a max
// image of ~9.5kx9.5k*3.
const DefaultMaxResizeMem = 256 << 20

View File

@ -44,17 +44,7 @@ import (
_ "camlistore.org/third_party/github.com/nf/cr2"
)
const (
imageDebug = false
// This is the default maximum concurrent number of bytes we allocate for
// uncompressed pixel data while generating thumbnails.
// If a single image is larger than the configured size for an
// ImageHandler, we'll never successfully resize it.
// 256M is a max image of ~9.5kx9.5k*3.
// TODO(wathiede) move to pkg/constants when https://camlistore.org/r/1536
// lands.
defaultMaxResizeBytes = 256 << 20
)
const imageDebug = false
var (
imageBytesServedVar = expvar.NewInt("image-bytes-served")

View File

@ -38,7 +38,8 @@ import (
"camlistore.org/pkg/auth"
"camlistore.org/pkg/blob"
"camlistore.org/pkg/blobserver"
"camlistore.org/pkg/client" // just for NewUploadHandleFromString. move elsewhere?
"camlistore.org/pkg/client"
"camlistore.org/pkg/constants" // just for NewUploadHandleFromString. move elsewhere?
"camlistore.org/pkg/fileembed"
"camlistore.org/pkg/httputil"
"camlistore.org/pkg/jsonconfig"
@ -101,7 +102,7 @@ func newPublishFromConfig(ld blobserver.Loader, conf jsonconfig.Obj) (h http.Han
bootstrapSignRoot := conf.OptionalString("devBootstrapPermanodeUsing", "")
rootNode := conf.OptionalList("rootPermanode")
ph.sourceRoot = conf.OptionalString("sourceRoot", "")
ph.resizeSem = syncutil.NewSem(int64(conf.OptionalInt("maxResizeBytes", defaultMaxResizeBytes)))
ph.resizeSem = syncutil.NewSem(int64(conf.OptionalInt("maxResizeBytes", constants.DefaultMaxResizeMem)))
if err = conf.Validate(); err != nil {
return
}

View File

@ -31,6 +31,7 @@ import (
"camlistore.org/pkg/blob"
"camlistore.org/pkg/blobserver"
"camlistore.org/pkg/constants"
"camlistore.org/pkg/fileembed"
"camlistore.org/pkg/httputil"
"camlistore.org/pkg/jsonconfig"
@ -120,7 +121,7 @@ func uiFromConfig(ld blobserver.Loader, conf jsonconfig.Obj) (h http.Handler, er
JSONSignRoot: conf.OptionalString("jsonSignRoot", ""),
sourceRoot: conf.OptionalString("sourceRoot", ""),
resizeSem: syncutil.NewSem(int64(conf.OptionalInt("maxResizeBytes",
defaultMaxResizeBytes))),
constants.DefaultMaxResizeMem))),
}
pubRoots := conf.OptionalList("publishRoots")
cachePrefix := conf.OptionalString("cache", "")