mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-08 00:22:14 +01:00
fix: rework api and webhook module timeout properties (fixes #396)
This commit is contained in:
@@ -143,7 +143,7 @@ func webhookMiddleware(w Webhook) api.Middleware {
|
||||
|
||||
client: &retryablehttp.Client{
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: c.Get("writeTimeout").(time.Duration),
|
||||
Timeout: w.clientTimeout,
|
||||
},
|
||||
RetryMax: w.maxRetry,
|
||||
RetryWaitMin: w.retryMinWait,
|
||||
|
||||
@@ -324,6 +324,7 @@ func TestWebhookMiddlewareAsynchronousProcess(t *testing.T) {
|
||||
maxRetry: 0,
|
||||
retryMinWait: 0,
|
||||
retryMaxWait: 0,
|
||||
clientTimeout: time.Duration(30) * time.Second,
|
||||
disable: false,
|
||||
}
|
||||
}
|
||||
@@ -397,7 +398,6 @@ func TestWebhookMiddlewareAsynchronousProcess(t *testing.T) {
|
||||
c.Set("traceHeader", "Gotenberg-Trace")
|
||||
c.Set("trace", "foo")
|
||||
c.Set("startTime", time.Now())
|
||||
c.Set("writeTimeout", time.Duration(10)*time.Second)
|
||||
|
||||
ctx := &api.MockContext{Context: &api.Context{}}
|
||||
ctx.SetLogger(zap.NewNop())
|
||||
|
||||
@@ -25,6 +25,7 @@ type Webhook struct {
|
||||
maxRetry int
|
||||
retryMinWait time.Duration
|
||||
retryMaxWait time.Duration
|
||||
clientTimeout time.Duration
|
||||
disable bool
|
||||
}
|
||||
|
||||
@@ -55,7 +56,7 @@ func (Webhook) Descriptor() gotenberg.ModuleDescriptor {
|
||||
err = multierr.Append(err, fs.MarkDeprecated("api-disable-webhook", "use webhook-disable instead"))
|
||||
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("create deprecated flags for webhook module: %v", err))
|
||||
panic(fmt.Errorf("create deprecated flags for the webhook module: %v", err))
|
||||
}
|
||||
|
||||
// New flags.
|
||||
@@ -66,6 +67,7 @@ func (Webhook) Descriptor() gotenberg.ModuleDescriptor {
|
||||
fs.Int("webhook-max-retry", 4, "Set the maximum number of retries for the webhook feature")
|
||||
fs.Duration("webhook-retry-min-wait", time.Duration(1)*time.Second, "Set the minimum duration to wait before trying to call the webhook again")
|
||||
fs.Duration("webhook-retry-max-wait", time.Duration(30)*time.Second, "Set the maximum duration to wait before trying to call the webhook again")
|
||||
fs.Duration("webhook-client-timeout", time.Duration(30)*time.Second, "Set the time limit for requests to the webhook")
|
||||
fs.Bool("webhook-disable", false, "Disable the webhook feature")
|
||||
|
||||
return fs
|
||||
@@ -84,6 +86,7 @@ func (w *Webhook) Provision(ctx *gotenberg.Context) error {
|
||||
w.maxRetry = flags.MustDeprecatedInt("api-webhook-max-retry", "webhook-max-retry")
|
||||
w.retryMinWait = flags.MustDeprecatedDuration("api-webhook-retry-min-wait", "webhook-retry-min-wait")
|
||||
w.retryMaxWait = flags.MustDeprecatedDuration("api-webhook-retry-min-wait", "webhook-retry-max-wait")
|
||||
w.clientTimeout = flags.MustDuration("webhook-client-timeout")
|
||||
w.disable = flags.MustDeprecatedBool("api-disable-webhook", "webhook-disable")
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user