feat: image variants engine
This commit is contained in:
1 parent
f0845de643
commit
f1d56ef50e
80 files changed
+7312
-84
No files matched your search
@@ -0,0 +1,44 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
const (
|
||||
EnvImageVariantMaxSourceBytes = "IMAGE_VARIANT_MAX_SOURCE_BYTES"
|
||||
DefaultImageVariantMaxSourceBytes = "10485760"
|
||||
|
||||
EnvImageVariantMaxSourcePixels = "IMAGE_VARIANT_MAX_SOURCE_PIXELS"
|
||||
DefaultImageVariantMaxSourcePixels = "50000000"
|
||||
|
||||
EnvImageVariantMaxConcurrentRenders = "IMAGE_VARIANT_MAX_CONCURRENT_RENDERS"
|
||||
DefaultImageVariantMaxConcurrentRenders = "4"
|
||||
)
|
||||
|
||||
func imageVariantMaxSourceBytesFromEnv() (int64, error) {
|
||||
raw := envOrDefault(EnvImageVariantMaxSourceBytes, DefaultImageVariantMaxSourceBytes)
|
||||
value, err := strconv.ParseInt(raw, 10, 64)
|
||||
if err != nil || value < 1 {
|
||||
return 0, fmt.Errorf("%s must be a whole number of bytes greater than zero, got %q", EnvImageVariantMaxSourceBytes, raw)
|
||||
}
|
||||
return value, nil
|
||||
}
|
||||
|
||||
func imageVariantMaxSourcePixelsFromEnv() (int64, error) {
|
||||
raw := envOrDefault(EnvImageVariantMaxSourcePixels, DefaultImageVariantMaxSourcePixels)
|
||||
value, err := strconv.ParseInt(raw, 10, 64)
|
||||
if err != nil || value < 1 {
|
||||
return 0, fmt.Errorf("%s must be a whole number of pixels greater than zero, got %q", EnvImageVariantMaxSourcePixels, raw)
|
||||
}
|
||||
return value, nil
|
||||
}
|
||||
|
||||
func imageVariantMaxConcurrentRendersFromEnv() (int, error) {
|
||||
raw := envOrDefault(EnvImageVariantMaxConcurrentRenders, DefaultImageVariantMaxConcurrentRenders)
|
||||
value, err := strconv.Atoi(raw)
|
||||
if err != nil || value < 1 {
|
||||
return 0, fmt.Errorf("%s must be a whole number of renders greater than zero, got %q", EnvImageVariantMaxConcurrentRenders, raw)
|
||||
}
|
||||
return value, nil
|
||||
}
|
||||
Reference in new issue
Block a user