api/ui: Allow per-scratch TTL down to 1m
Format / gofmt (push) Successful in 26s
Format / gofmt (pull_request) Successful in 26s
CI / Build (push) Successful in 33s
CI / Build (pull_request) Successful in 33s
CI / Go Tests (push) Successful in 35s
CI / Go Tests (pull_request) Successful in 35s
Format / gofmt (push) Successful in 26s
Format / gofmt (pull_request) Successful in 26s
CI / Build (push) Successful in 33s
CI / Build (pull_request) Successful in 33s
CI / Go Tests (push) Successful in 35s
CI / Go Tests (pull_request) Successful in 35s
#4
This commit is contained in:
@@ -44,9 +44,12 @@ const (
|
||||
defaultAPIWriteRequestsPerMinute = 30
|
||||
defaultAPIWriteRateLimitBurst = 10
|
||||
defaultHSTSEnabled = true
|
||||
maxDefaultTTLLimit = 24 * time.Hour
|
||||
minCleanupInterval = 10 * time.Second
|
||||
envPrefix = "SCRATCHBOX_"
|
||||
// MinScratchTTL / MaxScratchTTL bound optional per-scratch TTL on POST /api/scratch
|
||||
// and also cap limits.default_ttl.
|
||||
MinScratchTTL = time.Minute
|
||||
MaxScratchTTL = 24 * time.Hour
|
||||
minCleanupInterval = 10 * time.Second
|
||||
envPrefix = "SCRATCHBOX_"
|
||||
)
|
||||
|
||||
// envSuffixes is the single source of truth for every SCRATCHBOX_* environment
|
||||
@@ -138,7 +141,7 @@ type AccessLogConfig struct {
|
||||
|
||||
type LimitsConfig struct {
|
||||
MaxUploadSize string `yaml:"max_upload_size" comment:"Maximum upload request body size. Supports B, KB, MB, GB and KiB, MiB, GiB (case-insensitive). Defaults to bytes when unit is omitted (example: 1048576)."`
|
||||
DefaultTTL string `yaml:"default_ttl" comment:"Default expiration for new scratches. Must be > 0 and <= 24h."`
|
||||
DefaultTTL string `yaml:"default_ttl" comment:"Default expiration for new scratches when POST /api/scratch omits ttl. Must be > 0 and <= 24h."`
|
||||
RawCacheMaxSize string `yaml:"raw_cache_max_size" comment:"Maximum total decompressed bytes cached in memory for /api/raw range requests. Supports B, KB, MB, GB and KiB, MiB, GiB. Set this above limits.max_upload_size based on your expected concurrent large downloads."`
|
||||
RawCacheMaxEntries int `yaml:"raw_cache_max_entries" comment:"Maximum number of decompressed /api/raw entries retained in memory cache. Use this as a secondary cap alongside raw_cache_max_size."`
|
||||
MaxUploadSizeBytes int64 `yaml:"-"`
|
||||
@@ -326,8 +329,8 @@ func (c *Config) Validate() error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("limits.default_ttl invalid: %w", err)
|
||||
}
|
||||
if ttl <= 0 || ttl > maxDefaultTTLLimit {
|
||||
return fmt.Errorf("limits.default_ttl must be in (0, %s]", maxDefaultTTLLimit)
|
||||
if ttl <= 0 || ttl > MaxScratchTTL {
|
||||
return fmt.Errorf("limits.default_ttl must be in (0, %s]", MaxScratchTTL)
|
||||
}
|
||||
c.Limits.DefaultTTLDuration = ttl
|
||||
|
||||
|
||||
Reference in New Issue
Block a user