Skip to content

Commit d4f0363

Browse files
authored
feat: add support for gateway MaxRequestDuration option (#350)
1 parent 8582740 commit d4f0363

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

handlers.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ func setupGatewayHandler(cfg Config, nd *Node) (http.Handler, error) {
355355
NoDNSLink: len(cfg.DNSLinkGatewayDomains) > 0,
356356
MaxConcurrentRequests: cfg.MaxConcurrentRequests, // When exceeded, returns 429 with Retry-After: 60 (hardcoded in boxo)
357357
RetrievalTimeout: cfg.RetrievalTimeout,
358+
MaxRequestDuration: cfg.MaxRequestDuration,
358359
MaxRangeRequestFileSize: cfg.MaxRangeRequestFileSize,
359360
DiagnosticServiceURL: cfg.DiagnosticServiceURL,
360361
}

main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,12 @@ Generate an identity seed and launch a gateway:
498498
EnvVars: []string{"RAINBOW_RETRIEVAL_TIMEOUT"},
499499
Usage: "Maximum duration for initial content retrieval and time between writes",
500500
},
501+
&cli.DurationFlag{
502+
Name: "max-request-duration",
503+
Value: time.Hour,
504+
EnvVars: []string{"RAINBOW_MAX_REQUEST_DURATION"},
505+
Usage: "Maximum total time a request can take. Zero or negative values use the default (1 hour)",
506+
},
501507
&cli.Int64Flag{
502508
Name: "max-range-request-file-size",
503509
Value: 5368709120, // 5 GiB
@@ -758,6 +764,7 @@ share the same seed as long as the indexes are different.
758764
// Gateway limits
759765
MaxConcurrentRequests: cctx.Int("max-concurrent-requests"),
760766
RetrievalTimeout: cctx.Duration("retrieval-timeout"),
767+
MaxRequestDuration: cctx.Duration("max-request-duration"),
761768
MaxRangeRequestFileSize: cctx.Int64("max-range-request-file-size"),
762769
DiagnosticServiceURL: cctx.String("diagnostic-service-url"),
763770
}

setup.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ type Config struct {
193193
// Gateway limits
194194
MaxConcurrentRequests int
195195
RetrievalTimeout time.Duration
196+
MaxRequestDuration time.Duration
196197
MaxRangeRequestFileSize int64
197198
DiagnosticServiceURL string
198199
}

0 commit comments

Comments
 (0)